/** Reaction to buttons and combo boxes. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmdCtrlProp.equals(cmd)) { try { Class c = Class.forName("aurora.hwc.control.Panel" + myController.getClass().getSimpleName()); AbstractPanelController cp = (AbstractPanelController) c.newInstance(); cp.initialize(myController, null); } catch (Exception ex) { } } if (cmdCtrlList.equals(cmd)) { JComboBox cb = (JComboBox) e.getSource(); if (cb.getSelectedIndex() > 0) { myController = (AbstractControllerComplex) listCControllers.getSelectedItem(); buttonProp.setEnabled(true); } else { buttonProp.setEnabled(false); myController = null; } myMonitor.setMyController(myController); } return; }
/** Reaction to Add/Delete buttons. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmdAdd.equals(cmd)) { Zone z = ((ControllerSWARM) controller).new Zone(); Vector<AbstractNetworkElement> ml = ((AbstractControllerComplex) controller).getMyMonitor().getPredecessors(); Vector<AbstractNetworkElement> cl = ((AbstractControllerComplex) controller).getMyMonitor().getSuccessors(); if (ml.size() > 0) z.bottleneck = (AbstractLinkHWC) ml.firstElement(); if (cl.size() > 0) { z.setFromOnramp((AbstractLinkHWC) cl.firstElement()); z.setToOnramp((AbstractLinkHWC) cl.firstElement()); } z.initialize(); zones.add(z); zoneTM.fireTableStructureChanged(); setUpBottleneckColumn(); setUpFromOnrampColumn(); setUpToOnrampColumn(); } if (cmdDelete.equals(cmd)) { try { int[] selected = zonetab.getSelectedRows(); if ((selected != null) && (selected.length > 0)) for (int i = 0; i < selected.length; i++) { int idx = selected[i] - i; if ((idx >= 0) && (idx < zones.size())) { zones.remove(idx); zoneTM.fireTableStructureChanged(); setUpBottleneckColumn(); setUpFromOnrampColumn(); setUpToOnrampColumn(); } } } catch (Exception ex) { } } return; }