summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Negara <snegara@google.com>2015-05-14 16:43:28 -0700
committerStas Negara <snegara@google.com>2015-05-14 16:44:54 -0700
commit2261ef5a7b1ec50777b059defff86b61380e68a9 (patch)
treed09abaf91457a0d73bca20140d035218509a8e12
parent54fcf098f463a4e541aecf7df53cafcd43adab15 (diff)
downloadtesting-2261ef5a7b1ec50777b059defff86b61380e68a9.tar.gz
Disable screenshot comparison action for the root node.
Change-Id: Id3938e9e170ade13d7379114cbd788150777d22c
-rw-r--r--src/com/google/gct/testing/ShowScreenshotsAction.java44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/com/google/gct/testing/ShowScreenshotsAction.java b/src/com/google/gct/testing/ShowScreenshotsAction.java
index fe38be6..3d9ccb2 100644
--- a/src/com/google/gct/testing/ShowScreenshotsAction.java
+++ b/src/com/google/gct/testing/ShowScreenshotsAction.java
@@ -19,6 +19,7 @@ import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gct.testing.results.GoogleCloudTestProxy;
+import com.google.gct.testing.results.GoogleCloudTestProxy.GoogleCloudRootTestProxy;
import com.google.gct.testing.results.GoogleCloudTestResultsViewer;
import com.google.gct.testing.results.GoogleCloudTestTreeView;
import com.google.gct.testing.results.GoogleCloudTestingResultsForm;
@@ -52,6 +53,7 @@ public class ShowScreenshotsAction extends AnAction {
public ShowScreenshotsAction() {
super(TEXT, DESCRIPTION, ICON);
+ getTemplatePresentation().setEnabled(false);
}
@Override
@@ -62,7 +64,7 @@ public class ShowScreenshotsAction extends AnAction {
}
final GoogleCloudTestResultsViewer resultsViewer = sender.getResultsViewer();
- final GoogleCloudTestProxy.GoogleCloudRootTestProxy rootNode = ((GoogleCloudTestingResultsForm)resultsViewer).getTestsRootNode();
+ final GoogleCloudRootTestProxy rootNode = ((GoogleCloudTestingResultsForm)resultsViewer).getTestsRootNode();
AbstractTestProxy selectedLeaf = getFirstLeaf(((GoogleCloudTestingResultsForm)resultsViewer).getTreeView().getSelectedTest());
@@ -154,35 +156,19 @@ public class ShowScreenshotsAction extends AnAction {
}
@Override
- public void update(final AnActionEvent e) {
- final Presentation presentation = e.getPresentation();
+ public void update(AnActionEvent actionEvent) {
+ GoogleCloudTestTreeView sender = actionEvent.getData(GoogleCloudTestTreeView.CLOUD_TEST_RUNNER_VIEW);
- // visible only in SMTRunnerTestTreeView
- //presentation.setVisible(e.getData(SMTRunnerTestTreeView.SM_TEST_RUNNER_VIEW) != null);
- // enabled if some proxy is selected
- presentation.setEnabled(getSelectedTestProxy(e) != null);
- }
+ if (sender == null) {
+ return;
+ }
- //@Override
- //public void update(AnActionEvent e) {
- // e.getPresentation().setEnabled(isEnabled(e.getDataContext()));
- //}
- //
- //private boolean isEnabled(DataContext dataContext) {
- // if (myModel == null) {
- // return false;
- // }
- //
- // if (CommonDataKeys.PROJECT.getData(dataContext) == null) {
- // return false;
- // }
- //
- // return !myModel.getRoot().isInProgress();
- //}
-
-
- @Nullable
- private static Object getSelectedTestProxy(final AnActionEvent e) {
- return AbstractTestProxy.DATA_KEY.getData(e.getDataContext());
+ AbstractTestProxy selectedNode = ((GoogleCloudTestingResultsForm)sender.getResultsViewer()).getTreeView().getSelectedTest();
+ if (selectedNode == null || selectedNode instanceof GoogleCloudRootTestProxy) {
+ actionEvent.getPresentation().setEnabled(false);
+ } else {
+ actionEvent.getPresentation().setEnabled(true);
+ }
}
+
}