public int submit() {
   String newName = produktgruppeFormular.nameField.getText();
   if (isProdGrAlreadyKnown(newName)) {
     // not allowed: changing name to one that is already registered in DB
     JOptionPane.showMessageDialog(
         this,
         "Fehler: Produktgruppe '" + newName + "' bereits vorhanden!",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
     produktgruppeFormular.nameField.setText("");
     return 0;
   }
   Integer parentProdGrID =
       produktgruppeFormular.parentProdGrIDs.get(
           produktgruppeFormular.parentProdGrBox.getSelectedIndex());
   Vector<Integer> idsNew = produktgruppeFormular.idsOfNewProdGr(parentProdGrID);
   Integer topID = idsNew.get(0);
   Integer subID = idsNew.get(1);
   Integer subsubID = idsNew.get(2);
   Integer mwstID =
       produktgruppeFormular.mwstIDs.get(produktgruppeFormular.mwstBox.getSelectedIndex());
   Integer pfandID =
       produktgruppeFormular.pfandIDs.get(produktgruppeFormular.pfandBox.getSelectedIndex());
   return insertNewProdGr(topID, subID, subsubID, newName, mwstID, pfandID);
 }
 /**
  * Establishes combo box editor for 'from onramp' column.
  *
  * @param clmn
  */
 private void setUpToOnrampColumn() {
   JComboBox combo = new JComboBox();
   Vector<AbstractNetworkElement> nes =
       ((AbstractControllerComplex) controller).getMyMonitor().getSuccessors();
   for (int i = 0; i < nes.size(); i++)
     if ((nes.get(i).getType() & TypesHWC.MASK_LINK) > 0) combo.addItem(nes.get(i));
   TableColumn clmn = zonetab.getColumnModel().getColumn(3);
   clmn.setCellEditor(new DefaultCellEditor(combo));
   clmn.setCellRenderer(new DefaultTableCellRenderer());
   return;
 }
 public void setValueAt(Object value, int row, int col) {
   if (rowData.size() > row && row >= 0) {
     Object[] data = (Object[]) rowData.get(row);
     data[col] = value;
   }
   fireTableCellUpdated(row, col);
 }
Beispiel #4
0
 public Object getValueAt(int rowIndex, int columnIndex) {
   if (timeList != null) {
     if (rowIndex < timeList.size()) {
       JCTimeObject ctObj = (JCTimeObject) timeList.get(rowIndex);
       if (columnIndex == 0) {
         return ctObj.toString();
       }
     }
   }
   return null;
 }
 public Object getValueAt(int rowIndex, int columnIndex) {
   SkeletonProperty sp = (SkeletonProperty) m_props.get(rowIndex);
   switch (columnIndex) {
     case 0:
       return sp.getIdName();
     case 1:
       return sp.getLabel();
     case 2:
       return sp.getDescription();
     case 3:
       return sp.getType();
     case 4:
       return sp.getValue();
     default:
       return "";
   }
 }
 public void handle(Throwable exception) {
   try {
     if (exception instanceof NullPointerException) {
       synchronized (lock) {
         JTable table = ui.getList();
         DefaultTableModel model = (DefaultTableModel) table.getModel();
         Vector<?> data = model.getDataVector();
         for (int i = 0; i < data.size(); i++) {
           Object row = data.get(i);
           if (row == null) data.remove(i);
         }
       }
     }
     exception.printStackTrace();
   } catch (Throwable exception2) {
     exception.printStackTrace();
   }
 }
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
   SkeletonProperty sp = (SkeletonProperty) m_props.get(rowIndex);
   switch (columnIndex) {
     case 0:
       sp.setIdName(aValue.toString());
       break;
     case 1:
       sp.setLabel(aValue.toString());
       break;
     case 2:
       sp.setDescription(aValue.toString());
       break;
     case 3:
       sp.setType(aValue.toString());
       break;
     case 4:
       sp.setValue(aValue.toString());
       break;
   }
 }
 /** Fills the panel with SWARM specific fields. */
 public void fillPanel() {
   // Zone initialization
   ControllerSWARM z = (ControllerSWARM) controller;
   Vector<Zone> cz = z.zones;
   for (int i = 0; i < cz.size(); i++) zones.add(cz.get(i).clone());
   // Parameter initialization
   density_sample_size = z.P.SWARM_DENSITY_SAMPLE_SIZE;
   epsilon = z.P.epsilon;
   forecast_lead_time = z.P.SWARM_FORECAST_LEAD_TIME;
   input_var_lane = z.P.input_var_lane;
   meas_var_lane = z.P.meas_var_lane;
   phi = z.P.swarm_phi;
   psi = z.P.swarm_psi;
   sat_den_multiplier = z.P.SWARM_SAT_DEN_NUMBER;
   sat_smoother = z.P.sat_smoother;
   slope_sample_size = z.P.SWARM_SLOPE_SAMPLE_SIZE;
   // Components
   JPanel comp = new JPanel(new FlowLayout());
   comp.setBorder(BorderFactory.createTitledBorder("Components"));
   cbsw1.setSelected(z.P.SWARM1);
   comp.add(cbsw1);
   comp.add(new JLabel("  "));
   cbsw2a.setSelected(z.P.SWARM2A);
   comp.add(cbsw2a);
   comp.add(new JLabel("  "));
   cbsw2b.setSelected(z.P.SWARM2B);
   comp.add(cbsw2b);
   comp.add(new JLabel("  "));
   cbdynbott.setEnabled(false);
   comp.add(cbdynbott);
   add(comp);
   // Zones
   JPanel zone = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   zone.setBorder(BorderFactory.createTitledBorder("Zones"));
   zonetab.setPreferredScrollableViewportSize(new Dimension(400, 30));
   setUpBottleneckColumn();
   setUpFromOnrampColumn();
   setUpToOnrampColumn();
   c.fill = GridBagConstraints.HORIZONTAL;
   c.ipady = 45;
   c.weightx = 0.5;
   c.gridwidth = 3;
   c.gridx = 0;
   c.gridy = 0;
   zone.add(new JScrollPane(zonetab), c);
   c.ipady = 0;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridx = 0;
   zone.add(buttonAdd, c);
   c.gridx = 1;
   zone.add(buttonDelete, c);
   // configure buttons
   buttonAdd.setEnabled(true);
   buttonAdd.setActionCommand(cmdAdd);
   buttonAdd.addActionListener(this);
   buttonDelete.setEnabled(true);
   buttonDelete.setActionCommand(cmdDelete);
   buttonDelete.addActionListener(this);
   add(zone);
   // Parameters
   JPanel param = new JPanel(new GridLayout(1, 0));
   param.setBorder(BorderFactory.createTitledBorder("Parameters"));
   final JTable paramtab = new JTable(paramTM);
   paramtab.setPreferredScrollableViewportSize(new Dimension(500, 160));
   param.add(new JScrollPane(paramtab));
   add(param);
   return;
 }
 /** Fills the panel with simple signal specific fields. */
 protected void fillPanel() {
   if (controller != null) {
     Vector<CycleDataRow> cd = ((ControllerSimpleSignal) controller).getCycleTable();
     for (int i = 0; i < cd.size(); i++) {
       CycleDataRow cdr =
           ((ControllerSimpleSignal) controller)
           .new CycleDataRow(cd.get(i).getTime(), cd.get(i).getGreen(), cd.get(i).getRed());
       cycledata.add(cdr);
     }
   }
   // offset
   JPanel pO = new JPanel(new BorderLayout());
   pO.setBorder(BorderFactory.createTitledBorder("Offset (sec.)"));
   offset =
       new JSpinner(
           new SpinnerNumberModel(
               ((ControllerSimpleSignal) controller).getOffset() * conversion, 0.0, 99999.99, 10));
   offset.setEditor(new JSpinner.NumberEditor(offset, "####0.##"));
   pO.add(offset);
   add(pO);
   // table
   JPanel tabpanel = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   tabpanel.setBorder(BorderFactory.createTitledBorder("Cycle Schedule"));
   cycletable = new JTable(cycletablemodel);
   cycletable.setPreferredScrollableViewportSize(new Dimension(200, 50));
   cycletable.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             int row = cycletable.rowAtPoint(new Point(e.getX(), e.getY()));
             if ((row > cycledata.size() - 1) || (row < 0)) return;
             try {
               WindowEdit winEdit = new WindowEdit(null, cycledata.get(row));
               winEdit.setVisible(true);
               cycletablemodel.deleterow(row);
               cycletablemodel.addrow(winEdit.getMyRow());
             } catch (Exception excp) {
             }
           }
         }
       });
   c.fill = GridBagConstraints.HORIZONTAL;
   c.ipady = 100;
   c.weightx = 0.5;
   c.gridwidth = 3;
   c.gridx = 0;
   c.gridy = 0;
   tabpanel.add(new JScrollPane(cycletable), c);
   c.ipady = 0;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridx = 0;
   tabpanel.add(buttonAdd, c);
   c.gridx = 1;
   tabpanel.add(buttonDelete, c);
   add(tabpanel);
   // configure buttons
   buttonAdd.setEnabled(true);
   buttonAdd.addActionListener(new ButtonAddListener());
   buttonDelete.setEnabled(true);
   buttonDelete.addActionListener(new ButtonDeleteListener());
   return;
 }