Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running tests locally after deadline (change icons color when deadline has passed) #89

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
//plz remove everything that isn't needed here. --kviiri
public final class PastebinAction extends AbstractExerciseSensitiveAction {

private static final Logger log = Logger.getLogger(RequestReviewAction.class.getName());
private static final Logger log = Logger.getLogger(PastebinAction.class.getName());
private TmcSettings settings;
private CourseDb courseDb;
private ProjectMediator projectMediator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import fi.helsinki.cs.tmc.model.ProjectMediator;
import fi.helsinki.cs.tmc.runners.CheckstyleRunHandler;
import fi.helsinki.cs.tmc.runners.TestRunHandler;
import java.awt.Component;
import java.awt.Graphics;
import java.beans.PropertyChangeEvent;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.netbeans.api.project.Project;
import org.openide.nodes.Node;
import org.openide.util.NbBundle.Messages;
Expand All @@ -20,12 +26,18 @@ public class RunTestsLocallyAction extends AbstractExerciseSensitiveAction imple
private TestRunHandler testRunHandler;
private Project project;

private static final String GREEN_EYE = "testProjectGreen24.png";
private static final String RED_EYE = "testProjectRed24.png";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer more descriptive file and variable names, like ICON_TEST_RETURNABLE and icon_test_returnable.png etc.


public RunTestsLocallyAction() {
this.courseDb = CourseDb.getInstance();
this.projectMediator = ProjectMediator.getInstance();
this.checkstyleRunHandler = new CheckstyleRunHandler();
this.testRunHandler = new TestRunHandler();
putValue("noIconInMenu", Boolean.TRUE);

URL imgURL = getClass().getResource(GREEN_EYE);
setIcon(new ImageIcon(imgURL, ""));
}

@Override
Expand Down Expand Up @@ -55,14 +67,28 @@ public String getName() {

@Override
protected String iconResource() {
// The setting in layer.xml doesn't work with NodeAction
return "org/netbeans/modules/project/ui/resources/testProject.png";
return null;
}

private Icon getIcon(Exercise exercise) {
String name = GREEN_EYE;
if (exercise != null) {
name = exercise.isReturnable() ? GREEN_EYE : RED_EYE;
}
System.out.println("exercise: " + exercise + " color: " + name);
URL imgURL = getClass().getResource(name);
return new ImageIcon(imgURL, "");
}

private void updateIcon(Exercise exercise) {
setIcon(getIcon(exercise));
}

@Override
protected boolean enabledFor(Exercise exercise) {
// Overridden to not care about the deadline
return exercise.isReturnable();
// This gets always called when changing projects related to tmc
updateIcon(exercise);
return true;
}

@Override
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.