|
@@ -18,6 +18,9 @@ import javax.swing.SwingUtilities;
|
|
|
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolCollector;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolSensor;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatCollector;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatSensor;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.util.IntegerInputValidator;
|
|
|
|
|
@@ -84,7 +87,7 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
* Bottom TabbedPane for different Sensor Collector settings.
|
|
|
*/
|
|
|
JTabbedPane tbConfigureDevice;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Allows editing/creation of a smartDevice
|
|
|
*
|
|
@@ -161,11 +164,7 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
tfYposition.setColumns(10);
|
|
|
tfYposition.setText("" + newDevice.getY());
|
|
|
tfYposition.setInputVerifier(new IntegerInputValidator(visualisationRadius, maxY - visualisationRadius));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
cmbDevice = new JComboBox<String>();
|
|
|
cmbDevice.setBounds(0, 112, 365, 22);
|
|
|
panelGeneral.add(cmbDevice);
|
|
@@ -176,7 +175,8 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
cmbDevice.getSelectedIndex();
|
|
|
int selectedIndex = cmbDevice.getSelectedIndex();
|
|
|
if (lastSmartDeviceIndex != selectedIndex && selectedIndex != -1) {
|
|
|
- SmartDevice importedDevice = controller.getNetworkController().changeDeviceType(newDevice, controller.getImportController().getSmartDevices().get(selectedIndex));
|
|
|
+ SmartDevice importedDevice = controller.getNetworkController().changeDeviceType(newDevice,
|
|
|
+ controller.getImportController().getSmartDevices().get(selectedIndex));
|
|
|
if (importedDevice == null) {
|
|
|
System.out.println("Warning invalid SmartDevice changed");
|
|
|
cmbDevice.setSelectedIndex(lastSmartDeviceIndex);
|
|
@@ -190,10 +190,7 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
}
|
|
|
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
JButton btnImportSmartDevice = new JButton("Import Smart Device");
|
|
|
btnImportSmartDevice.setBounds(418, 111, 199, 25);
|
|
|
panelGeneral.add(btnImportSmartDevice);
|
|
@@ -212,38 +209,41 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
JOptionPane.showMessageDialog(this, "Import failed: " + e1.getMessage());
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Bottom TabbedPane for different Sensor Collector settings.
|
|
|
*/
|
|
|
tbConfigureDevice = new JTabbedPane(JTabbedPane.TOP);
|
|
|
tbConfigureDevice.setBounds(10, 147, 607, 230);
|
|
|
panelGeneral.add(tbConfigureDevice);
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/*
|
|
|
- * Other Tabs
|
|
|
+ * Other Tabs
|
|
|
*/
|
|
|
LinkEditorPanel panelLinks = new LinkEditorPanel(newDevice, control);
|
|
|
tabbedPane.addTab("Links", null, panelLinks, "Edit Links of the SmartDevice");
|
|
|
|
|
|
PortEditorPanel panelConnections = new PortEditorPanel(newDevice, control);
|
|
|
- tabbedPane.addTab("Connections", null, panelConnections.getSplitPane(), "Edit Connections/Ports/Timings of the SmartDevice");
|
|
|
+ tabbedPane.addTab("Connections", null, panelConnections.getSplitPane(),
|
|
|
+ "Edit Connections/Ports/Timings of the SmartDevice");
|
|
|
panelConnections.setEnabled(true);
|
|
|
|
|
|
/**
|
|
|
- for(Port p:newDevice.getPorts()){
|
|
|
- panelConnectionsScroll.add(new JLabel("Port "+p.getPortNumber()+": "+p.getConnection().getProtocol().getName()+" state:"+Port.statusToString(p.getStatus())+" triggerIntervall:"+p.getTriggerInterval()));
|
|
|
- panelConnectionsScroll.add(new JLabel("Port "+p.getPortNumber()+": "+p.getConnection().getProtocol().getName()+" state:"+Port.statusToString(p.getStatus())+" triggerIntervall:"+p.getTriggerInterval()));
|
|
|
- panelConnectionsScroll.add(new JLabel("Port "+p.getPortNumber()+": "+p.getConnection().getProtocol().getName()+" state:"+Port.statusToString(p.getStatus())+" triggerIntervall:"+p.getTriggerInterval()));
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
+ * for(Port p:newDevice.getPorts()){ panelConnectionsScroll.add(new
|
|
|
+ * JLabel("Port "+p.getPortNumber()+": "
|
|
|
+ * +p.getConnection().getProtocol().getName()+" state:"
|
|
|
+ * +Port.statusToString(p.getStatus())+" triggerIntervall:"
|
|
|
+ * +p.getTriggerInterval())); panelConnectionsScroll.add(new JLabel(
|
|
|
+ * "Port "+p.getPortNumber()+": "
|
|
|
+ * +p.getConnection().getProtocol().getName()+" state:"
|
|
|
+ * +Port.statusToString(p.getStatus())+" triggerIntervall:"
|
|
|
+ * +p.getTriggerInterval())); panelConnectionsScroll.add(new JLabel(
|
|
|
+ * "Port "+p.getPortNumber()+": "
|
|
|
+ * +p.getConnection().getProtocol().getName()+" state:"
|
|
|
+ * +Port.statusToString(p.getStatus())+" triggerIntervall:"
|
|
|
+ * +p.getTriggerInterval())); }
|
|
|
+ */
|
|
|
+
|
|
|
JButton btnCreateDevice = new JButton("Verify & Create SmartDevice");
|
|
|
btnCreateDevice.addActionListener(a -> validateAndAddDevice());
|
|
|
getContentPane().add(btnCreateDevice, BorderLayout.SOUTH);
|
|
@@ -251,17 +251,19 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
tabbedPane.setSelectedIndex(0);
|
|
|
refreshGUI();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Sets focus to the name text field
|
|
|
*/
|
|
|
- public void setNameFocus(){
|
|
|
+ public void setNameFocus() {
|
|
|
tfName.setFocusable(true);
|
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
|
- public void run() {
|
|
|
- tfName.requestFocusInWindow();
|
|
|
- }
|
|
|
- });
|
|
|
+ public void run() {
|
|
|
+ tfName.requestFocusInWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Validate the input Fields, and add the new SmartDevice to the model and
|
|
|
* panel
|
|
@@ -319,8 +321,8 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
this.dispose();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public void refreshGUI(){
|
|
|
+
|
|
|
+ public void refreshGUI() {
|
|
|
mutex = true;
|
|
|
// Update selected Device Type
|
|
|
cmbDevice.removeAllItems();
|
|
@@ -335,40 +337,47 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
}
|
|
|
cmbDevice.setSelectedIndex(lastSmartDeviceIndex);
|
|
|
|
|
|
+ /**
|
|
|
+ * Update Sensor/Collector Configuration
|
|
|
+ * TODO: Maybe allow custom UIs in SmartDevice, and maybe add new Class for the panel to clean up this large class
|
|
|
+ */
|
|
|
tbConfigureDevice.removeAll();
|
|
|
tbConfigureDevice.setVisible(false);
|
|
|
- if(newDevice instanceof FloatSensor)
|
|
|
- initializesSensorConfigurationPanel();
|
|
|
- if(tbConfigureDevice.getTabCount()>0)
|
|
|
+ initializeFloatSensorConfigurationPanel();
|
|
|
+ initializeBoolSensorConfigurationPanel();
|
|
|
+ initializeFloatCollectorConfigurationPanel();
|
|
|
+ initializeBoolCollectorConfigurationPanel();
|
|
|
+ if (tbConfigureDevice.getTabCount() > 0)
|
|
|
tbConfigureDevice.setVisible(true);
|
|
|
-
|
|
|
+
|
|
|
mutex = false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Initializes a panel for Float Sensors
|
|
|
*/
|
|
|
- private void initializesSensorConfigurationPanel(){
|
|
|
- if(!(newDevice instanceof FloatSensor))return;
|
|
|
+ private void initializeFloatSensorConfigurationPanel() {
|
|
|
+ if (!(newDevice instanceof FloatSensor))
|
|
|
+ return;
|
|
|
FloatSensor sensor = (FloatSensor) newDevice;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Configure FloatSensor Tab
|
|
|
*/
|
|
|
JPanel pnlFloatSensor = new JPanel();
|
|
|
tbConfigureDevice.addTab("FloatSensor", null, pnlFloatSensor, null);
|
|
|
pnlFloatSensor.setLayout(null);
|
|
|
-
|
|
|
+
|
|
|
JLabel lblInformationname = new JLabel("InformationName:");
|
|
|
lblInformationname.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblInformationname.setBounds(10, 10, 200, 20);
|
|
|
pnlFloatSensor.add(lblInformationname);
|
|
|
-
|
|
|
+
|
|
|
JTextField tfInfoName = new JTextField();
|
|
|
tfInfoName.setBounds(220, 10, 220, 20);
|
|
|
tfInfoName.setColumns(10);
|
|
|
tfInfoName.setText(sensor.getFSinfoName());
|
|
|
- tfInfoName.addActionListener(a->{
|
|
|
+ tfInfoName.addActionListener(a -> {
|
|
|
sensor.setFSinfoName(tfInfoName.getText());
|
|
|
});
|
|
|
tfInfoName.addFocusListener(new FocusAdapter() {
|
|
@@ -378,102 +387,306 @@ public class SmartDeviceCreationPopUp extends JDialog {
|
|
|
}
|
|
|
});
|
|
|
pnlFloatSensor.add(tfInfoName);
|
|
|
-
|
|
|
+
|
|
|
JLabel lblValue = new JLabel("Value:");
|
|
|
lblValue.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblValue.setBounds(10, 40, 200, 20);
|
|
|
pnlFloatSensor.add(lblValue);
|
|
|
-
|
|
|
+
|
|
|
JTextField tfValue = new JTextField();
|
|
|
tfValue.setColumns(10);
|
|
|
tfValue.setBounds(220, 40, 220, 20);
|
|
|
- tfValue.setText(""+sensor.getFSval());
|
|
|
+ tfValue.setText("" + sensor.getFSval());
|
|
|
tfValue.addFocusListener(new FocusAdapter() {
|
|
|
@Override
|
|
|
public void focusLost(FocusEvent e) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
float val = Float.parseFloat(tfValue.getText());
|
|
|
tfValue.setBackground(Color.WHITE);
|
|
|
sensor.setFSval(val);
|
|
|
- }catch (Exception ef) {
|
|
|
+ } catch (Exception ef) {
|
|
|
tfValue.setBackground(Color.RED);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- tfValue.addActionListener(a->{
|
|
|
- try{
|
|
|
+ tfValue.addActionListener(a -> {
|
|
|
+ try {
|
|
|
float val = Float.parseFloat(tfValue.getText());
|
|
|
tfValue.setBackground(Color.WHITE);
|
|
|
sensor.setFSval(val);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
tfValue.setBackground(Color.RED);
|
|
|
}
|
|
|
});
|
|
|
pnlFloatSensor.add(tfValue);
|
|
|
-
|
|
|
+
|
|
|
JLabel lblMinimum = new JLabel("Minimum:");
|
|
|
lblMinimum.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblMinimum.setBounds(10, 70, 200, 20);
|
|
|
pnlFloatSensor.add(lblMinimum);
|
|
|
-
|
|
|
+
|
|
|
JTextField tfMinimum = new JTextField();
|
|
|
tfMinimum.setColumns(10);
|
|
|
tfMinimum.setBounds(220, 70, 220, 20);
|
|
|
- tfMinimum.setText(""+sensor.getFSmin());
|
|
|
+ tfMinimum.setText("" + sensor.getFSmin());
|
|
|
tfMinimum.addFocusListener(new FocusAdapter() {
|
|
|
@Override
|
|
|
public void focusLost(FocusEvent e) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
float val = Float.parseFloat(tfMinimum.getText());
|
|
|
tfMinimum.setBackground(Color.WHITE);
|
|
|
sensor.setFSmin(val);
|
|
|
- }catch (Exception ef) {
|
|
|
+ } catch (Exception ef) {
|
|
|
tfMinimum.setBackground(Color.RED);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- tfMinimum.addActionListener(a->{
|
|
|
- try{
|
|
|
+ tfMinimum.addActionListener(a -> {
|
|
|
+ try {
|
|
|
float val = Float.parseFloat(tfMinimum.getText());
|
|
|
tfMinimum.setBackground(Color.WHITE);
|
|
|
sensor.setFSmin(val);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
tfMinimum.setBackground(Color.RED);
|
|
|
}
|
|
|
});
|
|
|
pnlFloatSensor.add(tfMinimum);
|
|
|
-
|
|
|
+
|
|
|
JLabel lblMaximum = new JLabel("Maximum:");
|
|
|
lblMaximum.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblMaximum.setBounds(10, 100, 200, 20);
|
|
|
pnlFloatSensor.add(lblMaximum);
|
|
|
-
|
|
|
+
|
|
|
JTextField tfMaxmimum = new JTextField();
|
|
|
tfMaxmimum.setColumns(10);
|
|
|
tfMaxmimum.setBounds(220, 100, 220, 20);
|
|
|
- tfMaxmimum.setText(""+sensor.getFSmax());
|
|
|
+ tfMaxmimum.setText("" + sensor.getFSmax());
|
|
|
tfMaxmimum.addFocusListener(new FocusAdapter() {
|
|
|
@Override
|
|
|
public void focusLost(FocusEvent e) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
float val = Float.parseFloat(tfMaxmimum.getText());
|
|
|
tfMaxmimum.setBackground(Color.WHITE);
|
|
|
sensor.setFSmax(val);
|
|
|
- }catch (Exception er) {
|
|
|
+ } catch (Exception er) {
|
|
|
tfMaxmimum.setBackground(Color.RED);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- tfMaxmimum.addActionListener(a->{
|
|
|
- try{
|
|
|
+ tfMaxmimum.addActionListener(a -> {
|
|
|
+ try {
|
|
|
float val = Float.parseFloat(tfMaxmimum.getText());
|
|
|
tfMaxmimum.setBackground(Color.WHITE);
|
|
|
sensor.setFSmax(val);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
tfMaxmimum.setBackground(Color.RED);
|
|
|
}
|
|
|
});
|
|
|
pnlFloatSensor.add(tfMaxmimum);
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Initializes a panel for Bool Sensors
|
|
|
+ */
|
|
|
+ private void initializeBoolSensorConfigurationPanel() {
|
|
|
+ if (!(newDevice instanceof BoolSensor))
|
|
|
+ return;
|
|
|
+ BoolSensor sensor = (BoolSensor) newDevice;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Configure FloatSensor Tab
|
|
|
+ */
|
|
|
+ JPanel pnlFloatSensor = new JPanel();
|
|
|
+ tbConfigureDevice.addTab("BoolSensor", null, pnlFloatSensor, null);
|
|
|
+ pnlFloatSensor.setLayout(null);
|
|
|
+
|
|
|
+ JLabel lblInformationname = new JLabel("InformationName:");
|
|
|
+ lblInformationname.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblInformationname.setBounds(10, 10, 200, 20);
|
|
|
+ pnlFloatSensor.add(lblInformationname);
|
|
|
+
|
|
|
+ JTextField tfInfoName = new JTextField();
|
|
|
+ tfInfoName.setBounds(220, 10, 220, 20);
|
|
|
+ tfInfoName.setColumns(10);
|
|
|
+ tfInfoName.setText(sensor.getBSinfoName());
|
|
|
+ tfInfoName.addActionListener(a -> {
|
|
|
+ sensor.setBSinfoName(tfInfoName.getText());
|
|
|
+ });
|
|
|
+ tfInfoName.addFocusListener(new FocusAdapter() {
|
|
|
+ @Override
|
|
|
+ public void focusLost(FocusEvent e) {
|
|
|
+ sensor.setBSinfoName(tfInfoName.getText());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ pnlFloatSensor.add(tfInfoName);
|
|
|
+
|
|
|
+ JLabel lblValue = new JLabel("Value:");
|
|
|
+ lblValue.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblValue.setBounds(10, 40, 200, 20);
|
|
|
+ pnlFloatSensor.add(lblValue);
|
|
|
+
|
|
|
+ JTextField tfValue = new JTextField();
|
|
|
+ tfValue.setColumns(10);
|
|
|
+ tfValue.setBounds(220, 40, 220, 20);
|
|
|
+ tfValue.setText("" + sensor.getBSval());
|
|
|
+ tfValue.addFocusListener(new FocusAdapter() {
|
|
|
+ @Override
|
|
|
+ public void focusLost(FocusEvent e) {
|
|
|
+ try {
|
|
|
+ boolean val = Boolean.parseBoolean(tfValue.getText());
|
|
|
+ tfValue.setBackground(Color.WHITE);
|
|
|
+ sensor.setBSval(val);
|
|
|
+ } catch (Exception ef) {
|
|
|
+ tfValue.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tfValue.addActionListener(a -> {
|
|
|
+ try {
|
|
|
+ boolean val = Boolean.parseBoolean(tfValue.getText());
|
|
|
+ tfValue.setBackground(Color.WHITE);
|
|
|
+ sensor.setBSval(val);
|
|
|
+ } catch (Exception ef) {
|
|
|
+ tfValue.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ pnlFloatSensor.add(tfValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Initializes a panel for Float Collectors
|
|
|
+ */
|
|
|
+ private void initializeFloatCollectorConfigurationPanel() {
|
|
|
+ if (!(newDevice instanceof FloatCollector))
|
|
|
+ return;
|
|
|
+ FloatCollector collector = (FloatCollector) newDevice;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Configure FloatSensor Tab
|
|
|
+ */
|
|
|
+ JPanel pnlFloatSensor = new JPanel();
|
|
|
+ tbConfigureDevice.addTab("FloatCollector", null, pnlFloatSensor, null);
|
|
|
+ pnlFloatSensor.setLayout(null);
|
|
|
+
|
|
|
+ JLabel lblInformationname = new JLabel("InformationName:");
|
|
|
+ lblInformationname.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblInformationname.setBounds(10, 10, 200, 20);
|
|
|
+ pnlFloatSensor.add(lblInformationname);
|
|
|
+
|
|
|
+ JTextField tfInfoName = new JTextField();
|
|
|
+ tfInfoName.setBounds(220, 10, 220, 20);
|
|
|
+ tfInfoName.setColumns(10);
|
|
|
+ tfInfoName.setText(collector.getFCinfoName());
|
|
|
+ tfInfoName.addActionListener(a -> {
|
|
|
+ collector.setFCinfoName(tfInfoName.getText());
|
|
|
+ });
|
|
|
+ tfInfoName.addFocusListener(new FocusAdapter() {
|
|
|
+ @Override
|
|
|
+ public void focusLost(FocusEvent e) {
|
|
|
+ collector.setFCinfoName(tfInfoName.getText());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ pnlFloatSensor.add(tfInfoName);
|
|
|
+
|
|
|
+ JLabel lblValue = new JLabel("Value:");
|
|
|
+ lblValue.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblValue.setBounds(10, 40, 200, 20);
|
|
|
+ pnlFloatSensor.add(lblValue);
|
|
|
+
|
|
|
+ JTextField tfValue = new JTextField();
|
|
|
+ tfValue.setColumns(10);
|
|
|
+ tfValue.setBounds(220, 40, 220, 20);
|
|
|
+ tfValue.setText("" + collector.getFCval());
|
|
|
+ tfValue.addFocusListener(new FocusAdapter() {
|
|
|
+ @Override
|
|
|
+ public void focusLost(FocusEvent e) {
|
|
|
+ try {
|
|
|
+ float val = Float.parseFloat(tfValue.getText());
|
|
|
+ tfValue.setBackground(Color.WHITE);
|
|
|
+ collector.setFCval(val);
|
|
|
+ } catch (Exception ef) {
|
|
|
+ tfValue.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tfValue.addActionListener(a -> {
|
|
|
+ try {
|
|
|
+ float val = Float.parseFloat(tfValue.getText());
|
|
|
+ tfValue.setBackground(Color.WHITE);
|
|
|
+ collector.setFCval(val);
|
|
|
+ } catch (Exception ef) {
|
|
|
+ tfValue.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ pnlFloatSensor.add(tfValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Initializes a panel for Bool Collectors
|
|
|
+ */
|
|
|
+ private void initializeBoolCollectorConfigurationPanel() {
|
|
|
+ if (!(newDevice instanceof BoolCollector))
|
|
|
+ return;
|
|
|
+ BoolCollector collector = (BoolCollector) newDevice;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Configure FloatSensor Tab
|
|
|
+ */
|
|
|
+ JPanel pnlFloatSensor = new JPanel();
|
|
|
+ tbConfigureDevice.addTab("BoolCollector", null, pnlFloatSensor, null);
|
|
|
+ pnlFloatSensor.setLayout(null);
|
|
|
+
|
|
|
+ JLabel lblInformationname = new JLabel("InformationName:");
|
|
|
+ lblInformationname.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblInformationname.setBounds(10, 10, 200, 20);
|
|
|
+ pnlFloatSensor.add(lblInformationname);
|
|
|
+
|
|
|
+ JTextField tfInfoName = new JTextField();
|
|
|
+ tfInfoName.setBounds(220, 10, 220, 20);
|
|
|
+ tfInfoName.setColumns(10);
|
|
|
+ tfInfoName.setText(collector.getBCinfoName());
|
|
|
+ tfInfoName.addActionListener(a -> {
|
|
|
+ collector.setBCinfoName(tfInfoName.getText());
|
|
|
+ });
|
|
|
+ tfInfoName.addFocusListener(new FocusAdapter() {
|
|
|
+ @Override
|
|
|
+ public void focusLost(FocusEvent e) {
|
|
|
+ collector.setBCinfoName(tfInfoName.getText());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ pnlFloatSensor.add(tfInfoName);
|
|
|
+
|
|
|
+ JLabel lblValue = new JLabel("Value:");
|
|
|
+ lblValue.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblValue.setBounds(10, 40, 200, 20);
|
|
|
+ pnlFloatSensor.add(lblValue);
|
|
|
+
|
|
|
+ JTextField tfValue = new JTextField();
|
|
|
+ tfValue.setColumns(10);
|
|
|
+ tfValue.setBounds(220, 40, 220, 20);
|
|
|
+ tfValue.setText("" + collector.getBCval());
|
|
|
+ tfValue.addFocusListener(new FocusAdapter() {
|
|
|
+ @Override
|
|
|
+ public void focusLost(FocusEvent e) {
|
|
|
+ try {
|
|
|
+ boolean val = Boolean.parseBoolean(tfValue.getText());
|
|
|
+ tfValue.setBackground(Color.WHITE);
|
|
|
+ collector.setBCval(val);
|
|
|
+ } catch (Exception ef) {
|
|
|
+ tfValue.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tfValue.addActionListener(a -> {
|
|
|
+ try {
|
|
|
+ boolean val = Boolean.parseBoolean(tfValue.getText());
|
|
|
+ tfValue.setBackground(Color.WHITE);
|
|
|
+ collector.setBCval(val);
|
|
|
+ } catch (Exception ef) {
|
|
|
+ tfValue.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ pnlFloatSensor.add(tfValue);
|
|
|
}
|
|
|
}
|