View Javadoc

1   // Copyright 2004-2005, FreeHEP.
2   package hep.wired.heprep.plugin;
3   
4   import org.freehep.util.Value;
5   import org.freehep.util.commanddispatcher.CommandProcessor;
6   import org.freehep.util.commanddispatcher.CommandState;
7   import org.freehep.util.commanddispatcher.BooleanCommandState;
8   
9   /***
10   * Defines a command handler for plugin commands.
11   *
12   * @author Mark Donszelmann
13   * @version $Id: WiredPluginCommandHandler.java 2130 2005-07-28 18:22:46Z duns $
14   */
15  public class WiredPluginCommandHandler extends CommandProcessor {
16  
17      private Value viewNo;
18      private WiredPlugin plugin;
19  
20      public WiredPluginCommandHandler(Value viewNo) {
21          this.viewNo = viewNo;
22          plugin = WiredPlugin.getPlugin();
23      }
24  
25      public void onNewWired4() {
26          plugin.showWired(plugin.createWiredView("View " + viewNo.getInt(), null), null, true);
27          viewNo.set(viewNo.getInt()+1);
28      }
29  
30      // Delegating handlers
31      public void enableInteraction(BooleanCommandState state) {
32          state.setEnabled(plugin.getCurrentPageContext() != null);
33          state.setSelected(plugin.getInteractionPanel().equals(plugin.getControl()));
34          setChanged();
35      }    
36  
37      public void onInteraction(boolean on) {
38          if (on) plugin.setControl(plugin.getInteractionPanel());
39      }
40  
41      public void enablePicking(BooleanCommandState state) {
42          state.setEnabled(plugin.getCurrentPageContext() != null);
43          state.setSelected(plugin.getHepRepInfoPanel().equals(plugin.getControl()));
44          setChanged();
45      }    
46   
47      public void onPicking(boolean on) {
48          if (on) plugin.setControl(plugin.getHepRepInfoPanel());
49      }    
50      
51      public void enableTreeSelection(BooleanCommandState state) {
52          state.setEnabled(plugin.getCurrentPageContext() != null);
53          state.setSelected(plugin.getTreePanel().equals(plugin.getControl()));
54          setChanged();
55      }    
56  
57      public void onTreeSelection(boolean on) {
58          if (on) plugin.setControl(plugin.getTreePanel());
59      }
60  
61      public void enableVariables(BooleanCommandState state) {
62          state.setEnabled(plugin.getCurrentPageContext() != null);
63          state.setSelected(plugin.getVariablePanel().equals(plugin.getControl()));
64          setChanged();
65      }    
66   
67      public void onVariables(boolean on) {
68          if (on) plugin.setControl(plugin.getVariablePanel());
69      }        
70  }