コード例 #1
0
 @Override
 public DataStore actionOnClose(DataStore ds) {
   final Object obj = ds.getObject(WizardMain.DS_CONFIGURATION_NAME);
   Cfg cfg = null;
   if (true == obj instanceof Cfg) {
     cfg = (Cfg) obj;
     final Vector<Integer> activeHeaters = new Vector<Integer>();
     for (int i = 0; i < tableData.getRowCount(); i++) {
       final Boolean active = (Boolean) tableData.getValueAt(i, USED_COLUMN);
       if (true == active.booleanValue()) {
         activeHeaters.add(i);
         final String function = (String) tableData.getValueAt(i, USED_FOR_COLUMN);
         cfg.addHeater(0, i, Heater_enum.valueOf(function));
         // if we can map the function then we can also map the sensor if the sensor is given
         final String Sensor = (String) tableData.getValueAt(i, USED_SENSOR_COLUMN);
         try {
           final int sensorIdx = Integer.parseInt(Sensor);
           cfg.addTemperatureSensor(0, sensorIdx, Heater_enum.valueOf(function));
         } catch (NumberFormatException e) {
           // unknown sensor -> no mapping
         }
       }
     }
     ds.putObject(WizardMain.DS_ACTIVE_HEATERS_NAME, activeHeaters);
   } else {
     log.error("Configuration Object missing from Data Store !");
   }
   return ds;
 }
コード例 #2
0
 @Override
 public DataStore actionOnShow(DataStore ds) {
   Object obj = ds.getObject(WizardMain.DS_DEVICE_INFORMATION_NAME);
   DeviceInformation di = null;
   if (true == obj instanceof DeviceInformation) {
     di = (DeviceInformation) obj;
     obj = ds.getObject(WizardMain.DS_ACTIVE_TEMPERATURE_SENSORS_NAME);
     if (true == obj instanceof Vector) {
       @SuppressWarnings("unchecked")
       final Vector<Integer> activeTempSensors = (Vector<Integer>) obj;
       // TODO Thread Start:
       if (activeTempSensors.size() > 0) {
         final TableColumnModel tcm = tab.getColumnModel();
         final TableColumn sensorColumn = tcm.getColumn(USED_SENSOR_COLUMN);
         final JComboBox<String> sensorBox = new JComboBox<String>();
         sensorBox.addItem(unknown);
         for (int i = 0; i < activeTempSensors.size(); i++) {
           final int sensorIdx = activeTempSensors.get(i);
           sensorBox.addItem("" + sensorIdx);
         }
         sensorColumn.setCellEditor(new DefaultCellEditor(sensorBox));
       }
       for (int i = 0; i < di.getNumberHeaters(); i++) {
         tableData.setValueAt(new Integer(i), i, 0);
         tableData.setValueAt(di.getHeaterConnectorName(i), i, 1);
         tableData.setValueAt(new Boolean(true), i, USED_COLUMN);
         tableData.setValueAt(unknown, i, USED_FOR_COLUMN);
         tableData.setValueAt(unknown, i, USED_SENSOR_COLUMN);
       }
       // Thread end
     } else {
       log.error("Protocol Object missing from Data Store !");
     }
   } else {
     log.error("DeviceInformation Object missing from Data Store !");
   }
   return ds;
 }