/* * SerialPortServicesView.java * * Copyright (c) 2003-2004 Digi International * This program and the information contained in it is confidential and * proprietary to Digi International and may not be used, copied, or re- * produced without the prior written permission of Digi International. * */ package com.digi.config.ui; import com.digi.config.core.*; import com.digi.config.util.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; import javax.swing.border.*; import javax.swing.text.*; import java.awt.*; import java.awt.event.*; import java.util.*; import java.io.*; import java.net.*; import java.text.*; /** * This class is a view panel that shows the port services * available for a serial port of the Digi Connect device. * * This view can be embedded in other panels as desired. */ public class SerialPortServicesView extends ConfigViewImpl { /** A KvpNode that holds just the fields used in this view */ KvpNode viewSettingTree; /** listens to the device for changes to kvpGroup */ DeviceChangeListener settingChangeListener; /** Panel that holds the view content */ GridContentPanel content; GridContentPanel tcpClientContent; GridContentPanel tcpConnectOnContent; GridContentPanel tcpConnectOnDataContent; GridContentPanel tcpConnectToContent; GridContentPanel udpClientContent; GridContentPanel udpSendOnContent; GridContentPanel udpSendOnDataContent; GridContentPanel udpSopCustomContent; GridContentPanel udpSatContent; GridContentPanel udpSabContent; GridContentPanel udpSendToContent; int MAXDESTINATIONS = 64; // Data fields currently used in this view KvpField tcpAutoConnectEnabledKvpField; KvpField tcpConnectTriggerKvpField; KvpField tcpConnectOnDataPatternKvpField; KvpField tcpConnectOnDataStripPatternKvpField; KvpField tcpConnectToAddressKvpField; KvpField tcpConnectToProtocolKvpField; KvpField tcpConnectToPortKvpField; KvpField udpClientEnabledKvpField; KvpField udpSendToEnabledKvpField[] = new KvpField[MAXDESTINATIONS]; KvpField udpSendToAddressKvpField[] = new KvpField[MAXDESTINATIONS]; KvpField udpSendToPortKvpField[] = new KvpField[MAXDESTINATIONS]; KvpField udpSendToDescKvpField[] = new KvpField[MAXDESTINATIONS]; KvpField udpSendOnDataEnabledKvpField; KvpField udpSendOnDataPatternKvpField; KvpField udpSendOnDataStripPatternKvpField; KvpField udpSatEnabledKvpField; KvpField udpSatValueKvpField; KvpField udpSabEnabledKvpField; KvpField udpSabValueKvpField; // UI Controls for each field JCheckBox tcpAutoConnectEnabled_UIC; JRadioButton tcpConnectOnAlways_UIC; JRadioButton tcpConnectOnData_UIC; JRadioButton tcpConnectOnDSR_UIC; JRadioButton tcpConnectOnDCD_UIC; JTextField tcpConnectOnDataPattern_UIC; JMenuItem tcpConnectOnDataPatternCR_UIC; JMenuItem tcpConnectOnDataPatternCRLF_UIC; JCheckBox tcpConnectOnDataStripPattern_UIC; JTextField tcpConnectToAddress_UIC; JComboBox tcpConnectToProtocol_UIC; JTextField tcpConnectToPort_UIC; JCheckBox udpClientEnabled_UIC; JCheckBox udpSendToEnabled_UIC[] = new JCheckBox[MAXDESTINATIONS]; JTextField udpSendToAddress_UIC[] = new JTextField[MAXDESTINATIONS]; JTextField udpSendToPort_UIC[] = new JTextField[MAXDESTINATIONS]; JTextField udpSendToDesc_UIC[] = new JTextField[MAXDESTINATIONS]; JCheckBox udpSendOnDataEnabled_UIC; JTextField udpSendOnDataPattern_UIC; JMenuItem udpSendOnDataPatternCR_UIC; JMenuItem udpSendOnDataPatternCRLF_UIC; JCheckBox udpSendOnDataStripPattern_UIC; JCheckBox udpSatEnabled_UIC; JTextField udpSatValue_UIC; JCheckBox udpSabEnabled_UIC; JTextField udpSabValue_UIC; /** * Basic constructor. Sets up the tree view and the edit panel. */ public SerialPortServicesView() throws Exception { // create the KvpNode and the kvpGroup change listener viewSettingTree = new KvpNode(); settingChangeListener = new DeviceChangeListener() { public void deviceChanged(DeviceChangeEvent e) { SystemLog.debug("SerialPortServicesView was notified that device kvpGroup changed"); refreshViewKvpNode(); refreshViewControls(); } }; // Create the panel that will hold the view controls content = new GridContentPanel(this.getName(),1); // create a listener that will detect when a user edits the field values and update the appropriate view setting fields ControlChangeAdapter fieldListener = new ControlChangeAdapter() { public void changePerformed(Object source, ActionEvent ae, FocusEvent fe) { if (source==tcpAutoConnectEnabled_UIC) { tcpAutoConnectEnabledKvpField.setStringValue(RciProtocol.toString(tcpAutoConnectEnabled_UIC.isSelected())); } else if (source==tcpConnectOnAlways_UIC) { if (tcpConnectOnAlways_UIC.isSelected()) tcpConnectTriggerKvpField.setStringValue("always"); } else if (source==tcpConnectOnData_UIC) { if (tcpConnectOnData_UIC.isSelected()) // tcpConnectTriggerKvpField.setStringValue("data"); if (tcpConnectOnDataPattern_UIC.getText().length()>0) { tcpConnectTriggerKvpField.setStringValue("string"); } else { tcpConnectTriggerKvpField.setStringValue("data"); } } else if (source==tcpConnectOnDSR_UIC) { if (tcpConnectOnDSR_UIC.isSelected()) tcpConnectTriggerKvpField.setStringValue("dsr"); } else if (source==tcpConnectOnDCD_UIC) { if (tcpConnectOnDCD_UIC.isSelected()) tcpConnectTriggerKvpField.setStringValue("dcd"); } else if (source==tcpConnectOnDataPattern_UIC) { tcpConnectOnDataPatternKvpField.setStringValue(tcpConnectOnDataPattern_UIC.getText()); if (tcpConnectOnDataPattern_UIC.getText().length()>0) { tcpConnectTriggerKvpField.setStringValue("string"); } else { tcpConnectTriggerKvpField.setStringValue("data"); } } else if (source==tcpConnectOnDataPatternCR_UIC) { tcpConnectOnDataPattern_UIC.replaceSelection("\\r"); tcpConnectOnDataPatternKvpField.setStringValue(tcpConnectOnDataPattern_UIC.getText()); tcpConnectTriggerKvpField.setStringValue("string"); } else if (source==tcpConnectOnDataPatternCRLF_UIC) { tcpConnectOnDataPattern_UIC.replaceSelection("\\r\\n"); tcpConnectOnDataPatternKvpField.setStringValue(tcpConnectOnDataPattern_UIC.getText()); tcpConnectTriggerKvpField.setStringValue("string"); } else if (source==tcpConnectOnDataStripPattern_UIC) { tcpConnectOnDataStripPatternKvpField.setStringValue(RciProtocol.toString(tcpConnectOnDataStripPattern_UIC.isSelected())); } else if (source==tcpConnectToAddress_UIC) { tcpConnectToAddressKvpField.setStringValue(tcpConnectToAddress_UIC.getText()); } else if (source==tcpConnectToProtocol_UIC) { tcpConnectToProtocolKvpField.setStringValue(tcpConnectToProtocol_UIC.getSelectedItem().toString()); } else if (source==tcpConnectToPort_UIC) { tcpConnectToPortKvpField.setStringValue(tcpConnectToPort_UIC.getText()); } else if (source==udpClientEnabled_UIC) { udpClientEnabledKvpField.setStringValue(RciProtocol.toString(udpClientEnabled_UIC.isSelected())); } else if (source==udpSendOnDataEnabled_UIC) { udpSendOnDataEnabledKvpField.setStringValue(RciProtocol.toString(udpSendOnDataEnabled_UIC.isSelected())); } else if (source==udpSendOnDataPattern_UIC) { udpSendOnDataPatternKvpField.setStringValue(udpSendOnDataPattern_UIC.getText()); } else if (source==udpSendOnDataPatternCR_UIC) { udpSendOnDataPattern_UIC.replaceSelection("\\r"); udpSendOnDataPatternKvpField.setStringValue(udpSendOnDataPattern_UIC.getText()); } else if (source==udpSendOnDataPatternCRLF_UIC) { udpSendOnDataPattern_UIC.replaceSelection("\\r\\n"); udpSendOnDataPatternKvpField.setStringValue(udpSendOnDataPattern_UIC.getText()); } else if (source==udpSendOnDataStripPattern_UIC) { udpSendOnDataStripPatternKvpField.setStringValue(RciProtocol.toString(udpSendOnDataStripPattern_UIC.isSelected())); } else if (source==udpSatEnabled_UIC) { udpSatEnabledKvpField.setStringValue(RciProtocol.toString(udpSatEnabled_UIC.isSelected())); } else if (source==udpSatValue_UIC) { udpSatValueKvpField.setStringValue(udpSatValue_UIC.getText()); // } else if (source==udpSabEnabled_UIC) { // udpSabEnabledKvpField.setStringValue(RciProtocol.toString(udpSabEnabled_UIC.isSelected())); } else if (source==udpSabValue_UIC) { udpSabValueKvpField.setStringValue(udpSabValue_UIC.getText()); } else { // Next, check to see if it was one of the destination list fields for (int i=0;i