diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/PastebinAction.java b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/PastebinAction.java index f46eded2..bbfe0317 100644 --- a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/PastebinAction.java +++ b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/PastebinAction.java @@ -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; diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java index dd81292e..418bc1cf 100644 --- a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java +++ b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java @@ -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; @@ -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"; + 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 @@ -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 diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectGreen.png b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectGreen.png new file mode 100644 index 00000000..f2b955b2 Binary files /dev/null and b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectGreen.png differ diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectGreen24.png b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectGreen24.png new file mode 100644 index 00000000..21e4a59e Binary files /dev/null and b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectGreen24.png differ diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectRed.png b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectRed.png new file mode 100644 index 00000000..26598f55 Binary files /dev/null and b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectRed.png differ diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectRed24.png b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectRed24.png new file mode 100644 index 00000000..f0345ae1 Binary files /dev/null and b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/testProjectRed24.png differ