()
| 30 | private Button button; |
| 31 | |
| 32 | public Commands() { |
| 33 | super("Commands"); |
| 34 | if (instance!=null) { |
| 35 | WindowManager.toFront(instance); |
| 36 | return; |
| 37 | } |
| 38 | instance = this; |
| 39 | WindowManager.addWindow(this); |
| 40 | list = new List(MAX_COMMANDS); |
| 41 | list.addItemListener(this); |
| 42 | String cmds = Prefs.get(CMDS_KEY, null); |
| 43 | if (cmds!=null) { |
| 44 | String[] cmd = cmds.split(","); |
| 45 | int len = cmd.length<=MAX_COMMANDS?cmd.length:MAX_COMMANDS; |
| 46 | boolean isDivider = false; |
| 47 | for (int i=0; i<len; i++) { |
| 48 | if (divider.equals(cmd[i])) { |
| 49 | isDivider = true; |
| 50 | break; |
| 51 | } |
| 52 | } |
| 53 | if (isDivider) { |
| 54 | for (int i=0; i<len; i++) |
| 55 | list.add(cmd[i]); |
| 56 | } else |
| 57 | cmds = null; |
| 58 | } |
| 59 | if (cmds==null) |
| 60 | reset(); |
| 61 | ImageJ ij = IJ.getInstance(); |
| 62 | addKeyListener(ij); |
| 63 | Executer.addCommandListener(this); |
| 64 | GUI.scale(list); |
| 65 | list.addKeyListener(ij); |
| 66 | GridBagLayout gridbag = new GridBagLayout(); |
| 67 | GridBagConstraints c = new GridBagConstraints(); |
| 68 | setLayout(gridbag); |
| 69 | c.insets = new Insets(0, 0, 0, 0); |
| 70 | c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.WEST; |
| 71 | add(list,c); |
| 72 | button = new Button("Edit"); |
| 73 | button.addActionListener(this); |
| 74 | button.addKeyListener(ij); |
| 75 | //c.insets = new Insets(2, 6, 6, 6); |
| 76 | c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.CENTER; |
| 77 | add(button, c); |
| 78 | pack(); |
| 79 | Dimension size = getSize(); |
| 80 | Point loc = Prefs.getLocation(LOC_KEY); |
| 81 | if (loc!=null) |
| 82 | setLocation(loc); |
| 83 | show(); |
| 84 | } |
| 85 | |
| 86 | public void actionPerformed(ActionEvent e) { |
| 87 | GenericDialog gd = new GenericDialog("Commands"); |
nothing calls this directly
no test coverage detected