Home | History | Annotate | Download | only in tko
      1 package autotest.tko;
      2 
      3 import autotest.common.ui.ContextMenu;
      4 
      5 import com.google.gwt.json.client.JSONObject;
      6 import com.google.gwt.user.client.Command;
      7 
      8 public class TestContextMenu extends ContextMenu {
      9     private static TestLabelManager labelManager = TestLabelManager.getManager();
     10     private TestSet tests;
     11     private TestSelectionListener listener;
     12 
     13     public TestContextMenu(TestSet tests, TestSelectionListener listener) {
     14         this.tests = tests;
     15         this.listener = listener;
     16     }
     17 
     18     public boolean addViewDetailsIfSingleTest() {
     19         if (!tests.isSingleTest()) {
     20             return false;
     21         }
     22 
     23         addItem("View test details", new Command() {
     24             public void execute() {
     25                 listener.onSelectTest(tests.getTestIndex());
     26             }
     27         });
     28         return true;
     29     }
     30 
     31     public void addLabelItems() {
     32         final JSONObject condition = tests.getCondition();
     33         addItem("Invalidate tests", new Command() {
     34             public void execute() {
     35                 labelManager.handleInvalidate(condition);
     36             }
     37         });
     38         addItem("Revalidate tests", new Command() {
     39             public void execute() {
     40                 labelManager.handleRevalidate(condition);
     41             }
     42         });
     43         addItem("Add label", new Command() {
     44             public void execute() {
     45                 labelManager.handleAddLabels(condition);
     46             }
     47         });
     48         addItem("Remove label", new Command() {
     49             public void execute() {
     50                 labelManager.handleRemoveLabels(condition);
     51             }
     52         });
     53     }
     54 }
     55