Example #1
0
 @Override
 @SuppressWarnings("unchecked")
 public TableCellEditor getCellEditor(int row, int column) {
   final Variable<? extends TrickViewFluent> variable = variables.get(convertRowIndexToModel(row));
   final TrickViewFluent value = variable.getValue();
   switch (convertColumnIndexToModel(column)) {
     default:
       return getDefaultEditor(String.class);
     case 1:
       return value.getCellEditor();
     case 2:
       return new DefaultCellEditor(
           new JComboBox(UnitType.getAll(variable.getUnits()).toArray()) {
             {
               setSelectedItem(variable.getUnits());
             }
           });
     case 3:
       return new DefaultCellEditor(
           new JComboBox(EnumSet.allOf(value.getFormatClass()).toArray()) {
             {
               setSelectedItem(value.getFormat());
             }
           });
   }
 }
Example #2
0
 private void setUnits(ArrayList<? extends Variable> variables, Object units) {
   for (Variable variable : variables) {
     for (String string : UnitType.getAll(variable.getUnits())) {
       if (string.equals(units)) {
         try {
           variable.sendUnitsToVariableServer(units.toString(), variableServerConnection);
         } catch (IOException ioException) {
           System.err.println(
               "Failed to set variable \"" + variable + "\" units to \"" + units + "\"");
           ioException.printStackTrace(System.err);
         }
         break;
       }
     }
   }
 }