use of com.example.commadapter.vehicle.exchange.commands.SetVehicleHostCommand in project opentcs-integration-example by openTCS.
the class ControlPanel method enableAdapterCheckBoxActionPerformed.
// GEN-LAST:event_sendOrderButtonActionPerformed
private void enableAdapterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_enableAdapterCheckBoxActionPerformed
if (enableAdapterCheckBox.isSelected()) {
String host = hostTextField.getText();
if (Strings.isNullOrEmpty(host)) {
enableAdapterCheckBox.setSelected(false);
JOptionPane.showMessageDialog(this, "IP address can not be empty.");
return;
}
String portString = portTextField.getText();
int port;
if (!Strings.isNullOrEmpty(portString)) {
port = Integer.valueOf(portString);
} else {
enableAdapterCheckBox.setSelected(false);
JOptionPane.showMessageDialog(this, "TCP port can not be empty.");
return;
}
String timeoutString = aliveTimeoutTextField.getText();
int timeout;
if (!Strings.isNullOrEmpty(timeoutString)) {
timeout = Integer.valueOf(aliveTimeoutTextField.getText());
} else {
enableAdapterCheckBox.setSelected(false);
JOptionPane.showMessageDialog(this, "Inactive after (ms) can not be empty.");
return;
}
sendAdapterCommand(new SetVehicleHostCommand(host));
sendAdapterCommand(new SetVehiclePortCommand(port));
sendAdapterCommand(new SetIdleTimeoutCommand(timeout));
}
enableCommAdapter(enableAdapterCheckBox.isSelected());
}
Aggregations