Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-08 17:19:58 +0000
committerUwe Stieber2011-12-08 17:19:58 +0000
commitceaf9c5dcd6d1a520b9b16200b0fe0cd4cbd0bf9 (patch)
treeccf3d9b428700fe77dc7775ea94927ccd53dbd6b /target_explorer/plugins
parentc54cb44b59b5f480017727e989329d369cb2d024 (diff)
downloadorg.eclipse.tcf-ceaf9c5dcd6d1a520b9b16200b0fe0cd4cbd0bf9.tar.gz
org.eclipse.tcf-ceaf9c5dcd6d1a520b9b16200b0fe0cd4cbd0bf9.tar.xz
org.eclipse.tcf-ceaf9c5dcd6d1a520b9b16200b0fe0cd4cbd0bf9.zip
Target Explorer: Move network and serial wire type controls to open source
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeNetwork.java33
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeSerial.java52
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/.options2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/META-INF/MANIFEST.MF10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/activator/UIPlugin.java71
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/common/NameControl.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/help/IContextHelpIds.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/tracing/ITraceIds.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.java39
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.properties39
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypeControl.java129
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypePanelControl.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkAddressControl.java58
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkCablePanel.java276
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkPortControl.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialLinePanel.java930
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialPortAddressDialog.java357
18 files changed, 2186 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF
index 27bdfda4c..ceeac7c35 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF
@@ -20,4 +20,5 @@ Export-Package: org.eclipse.tcf.te.core.activator;x-internal:=true,
org.eclipse.tcf.te.core.async,
org.eclipse.tcf.te.core.async.interfaces,
org.eclipse.tcf.te.core.nls;x-internal:=true,
+ org.eclipse.tcf.te.core.nodes.interfaces.wire,
org.eclipse.tcf.te.core.utils.text
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeNetwork.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeNetwork.java
new file mode 100644
index 000000000..658bcf386
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeNetwork.java
@@ -0,0 +1,33 @@
+/**
+ * INetworkWireType.java
+ * Created on Nov 11, 2011
+ *
+ * Copyright (c) 2011 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.core.nodes.interfaces.wire;
+
+/**
+ * The properties specific to the wire type "network".
+ */
+public interface IWireTypeNetwork {
+
+ /**
+ * The data container.
+ */
+ public static String PROPERTY_CONTAINER_NAME = "network"; //$NON-NLS-1$
+
+ /**
+ * The network address.
+ */
+ public static final String PROPERTY_NETWORK_ADDRESS = "address"; //$NON-NLS-1$
+
+ /**
+ * The network port.
+ */
+ public static final String PROPERTY_NETWORK_PORT = "port"; //$NON-NLS-1$
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeSerial.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeSerial.java
new file mode 100644
index 000000000..840985697
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/nodes/interfaces/wire/IWireTypeSerial.java
@@ -0,0 +1,52 @@
+/**
+ * INetworkWireType.java
+ * Created on Nov 11, 2011
+ *
+ * Copyright (c) 2011 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.core.nodes.interfaces.wire;
+
+/**
+ * The properties specific to the wire type "serial".
+ */
+public interface IWireTypeSerial {
+
+ /**
+ * The data container.
+ */
+ public static String PROPERTY_CONTAINER_NAME = "serial"; //$NON-NLS-1$
+
+ /**
+ * The serial device name.
+ */
+ public static final String PROPERTY_SERIAL_DEVICE = "device"; //$NON-NLS-1$
+
+ /**
+ * The baud rate.
+ */
+ public static final String PROPERTY_SERIAL_BAUD_RATE = "baudrate"; //$NON-NLS-1$
+
+ /**
+ * The data bits
+ */
+ public static final String PROPERTY_SERIAL_DATA_BITS = "databits"; //$NON-NLS-1$
+
+ /**
+ * The parity
+ */
+ public static final String PROPERTY_SERIAL_PARITY = "parity"; //$NON-NLS-1$
+
+ /**
+ * The stop bits
+ */
+ public static final String PROPERTY_SERIAL_STOP_BITS = "stopbits"; //$NON-NLS-1$
+
+ /**
+ * The flow control
+ */
+ public static final String PROPERTY_SERIAL_FLOW_CONTROL = "flowcontrol"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/.options b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/.options
new file mode 100644
index 000000000..27e96b8e9
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/.options
@@ -0,0 +1,2 @@
+org.eclipse.tcf.te.ui.controls/debugmode = 0
+org.eclipse.tcf.te.ui.controls/trace/serialLinePanel = false
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/META-INF/MANIFEST.MF
index 0754a5b05..2664bcf71 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.ui.forms;bundle-version="3.5.100",
org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
+ org.eclipse.tcf.te.core;bundle-version="1.0.0",
org.eclipse.tcf.te.ui;bundle-version="1.0.0",
org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
@@ -17,9 +18,16 @@ Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.tcf.te.ui.controls,
org.eclipse.tcf.te.ui.controls.activator;x-internal:=true,
+ org.eclipse.tcf.te.ui.controls.common,
org.eclipse.tcf.te.ui.controls.file,
org.eclipse.tcf.te.ui.controls.interfaces,
+ org.eclipse.tcf.te.ui.controls.interfaces.help,
+ org.eclipse.tcf.te.ui.controls.interfaces.tracing,
org.eclipse.tcf.te.ui.controls.net,
org.eclipse.tcf.te.ui.controls.nls,
org.eclipse.tcf.te.ui.controls.panels,
- org.eclipse.tcf.te.ui.controls.validator
+ org.eclipse.tcf.te.ui.controls.validator,
+ org.eclipse.tcf.te.ui.controls.wire,
+ org.eclipse.tcf.te.ui.controls.wire.network,
+ org.eclipse.tcf.te.ui.controls.wire.serial
+Import-Package: gnu.io;resolution:=optional
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/activator/UIPlugin.java
index 337e09912..ef303834d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/activator/UIPlugin.java
@@ -9,6 +9,11 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.controls.activator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
+import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -18,6 +23,8 @@ import org.osgi.framework.BundleContext;
public class UIPlugin extends AbstractUIPlugin {
// The shared instance
private static UIPlugin plugin;
+ // The trace handler instance
+ private static TraceHandler traceHandler;
/**
* The constructor
@@ -44,6 +51,18 @@ public class UIPlugin extends AbstractUIPlugin {
return null;
}
+ /**
+ * Returns the bundles trace handler.
+ *
+ * @return The bundles trace handler.
+ */
+ public static TraceHandler getTraceHandler() {
+ if (traceHandler == null) {
+ traceHandler = new TraceHandler(getUniqueIdentifier());
+ }
+ return traceHandler;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@@ -59,6 +78,58 @@ public class UIPlugin extends AbstractUIPlugin {
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
+ traceHandler = null;
super.stop(context);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
+ */
+ @Override
+ protected void initializeImageRegistry(ImageRegistry registry) {
+ }
+
+ /**
+ * Loads the image registered under the specified key from the image
+ * registry and returns the <code>Image</code> object instance.
+ *
+ * @param key The key the image is registered with.
+ * @return The <code>Image</code> object instance or <code>null</code>.
+ */
+ public static Image getImage(String key) {
+ return getDefault().getImageRegistry().get(key);
+ }
+
+ /**
+ * Loads the image registered under the specified key from the image
+ * registry and returns the <code>ImageDescriptor</code> object instance.
+ *
+ * @param key The key the image is registered with.
+ * @return The <code>ImageDescriptor</code> object instance or <code>null</code>.
+ */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ return getDefault().getImageRegistry().getDescriptor(key);
+ }
+
+ /**
+ * Loads the image given by the specified image descriptor from the image
+ * registry. If the image has been loaded ones before already, the cached
+ * <code>Image</code> object instance is returned. Otherwise, the <code>
+ * Image</code> object instance will be created and cached before returned.
+ *
+ * @param descriptor The image descriptor.
+ * @return The corresponding <code>Image</code> object instance or <code>null</code>.
+ */
+ public static Image getSharedImage(AbstractImageDescriptor descriptor) {
+ ImageRegistry registry = getDefault().getImageRegistry();
+
+ String imageKey = descriptor.getDecriptorKey();
+ Image image = registry.get(imageKey);
+ if (image == null) {
+ registry.put(imageKey, descriptor);
+ image = registry.get(imageKey);
+ }
+
+ return image;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/common/NameControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/common/NameControl.java
new file mode 100644
index 000000000..de9b742ec
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/common/NameControl.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.common;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.controls.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.validator.RegexValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+
+/**
+ * Name control implementation.
+ */
+public class NameControl extends BaseEditBrowseTextControl {
+
+ /**
+ * Constructor.
+ *
+ * @param parentPage The parent dialog page this control is embedded in.
+ * Might be <code>null</code> if the control is not associated with a page.
+ */
+ public NameControl(IDialogPage parentPage) {
+ super(parentPage);
+ setIsGroup(false);
+ setHideBrowseButton(true);
+ setHasHistory(false);
+ setEditFieldLabel(Messages.NameControl_label);
+ setAdjustBackgroundColor(parentPage != null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doCreateEditFieldValidator()
+ */
+ @Override
+ protected Validator doCreateEditFieldValidator() {
+ return new RegexValidator(Validator.ATTR_MANDATORY, ".*"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#configureEditFieldValidator(org.eclipse.tcf.te.ui.controls.validator.Validator)
+ */
+ @Override
+ protected void configureEditFieldValidator(Validator validator) {
+ if (validator instanceof RegexValidator) {
+ validator.setMessageText(RegexValidator.INFO_MISSING_VALUE, Messages.NameControl_info_missingValue);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/help/IContextHelpIds.java
new file mode 100644
index 000000000..c5a9bcb4f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/help/IContextHelpIds.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.interfaces.help;
+
+import org.eclipse.tcf.te.ui.controls.activator.UIPlugin;
+
+/**
+ * Context help id definitions.
+ */
+public interface IContextHelpIds {
+
+ /**
+ * UI plug-in common context help id prefix.
+ */
+ public final static String PREFIX = UIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
+
+ /**
+ * Serial line configuration custom port or address dialog.
+ */
+ public final static String SERIAL_PORT_ADDRESS_DIALOG = PREFIX + "SerialPortAddressDialog"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/tracing/ITraceIds.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/tracing/ITraceIds.java
new file mode 100644
index 000000000..32a372a0c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/interfaces/tracing/ITraceIds.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.interfaces.tracing;
+
+/**
+ * Trace slot identifiers.
+ */
+public interface ITraceIds {
+
+ /**
+ * If activated, trace information about serial device discovery is printed out.
+ */
+ public static final String TRACE_SERIAL_LINE_PANEL = "trace/serialLinePanel"; //$NON-NLS-1$
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.java
index 634743748..d27318ca2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.java
@@ -72,6 +72,9 @@ public class Messages extends NLS {
public static String BaseEditBrowseTextControl_button_label;
public static String BaseEditBrowseTextControl_validationJob_name;
+ public static String NameControl_label;
+ public static String NameControl_info_missingValue;
+
public static String DirectorySelectionControl_title;
public static String DirectorySelectionControl_group_label;
public static String DirectorySelectionControl_editfield_label;
@@ -93,6 +96,42 @@ public class Messages extends NLS {
public static String RemoteHostPortControl_label;
+ public static String WireTypeControl_label;
+ public static String WireTypeControl_networkType_label;
+ public static String WireTypeControl_serialType_label;
+
+ public static String NetworkCablePanel_section;
+ public static String NetworkCablePanel_addressControl_label;
+
+ public static String SerialLinePanel_section;
+ public static String SerialLinePanel_hostTTYDevice_label;
+ public static String SerialLinePanel_hostTTYSpeed_label;
+ public static String SerialLinePanel_hostTTYDatabits_label;
+ public static String SerialLinePanel_hostTTYParity_label;
+ public static String SerialLinePanel_hostTTYStopbits_label;
+ public static String SerialLinePanel_hostTTYFlowControl_label;
+ public static String SerialLinePanel_customSerialDevice_title;
+ public static String SerialLinePanel_customSerialDevice_message;
+ public static String SerialLinePanel_customSerialBaudRate_title;
+ public static String SerialLinePanel_customSerialBaudRate_message;
+ public static String SerialLinePanel_error_invalidCharactes;
+ public static String SerialLinePanel_error_invalidCharactesBaudRate;
+ public static String SerialLinePanel_error_emptyHostTTYDevice;
+ public static String SerialLinePanel_error_emptyHostTTYSpeedRate;
+ public static String SerialLinePanel_error_emptyHostTTYDatabits;
+ public static String SerialLinePanel_error_emptyHostTTYParity;
+ public static String SerialLinePanel_error_emptyHostTTYStopbits;
+ public static String SerialLinePanel_error_emptyHostTTYFlowControl;
+ public static String SerialLinePanel_info_editableTTYDeviceSelected;
+ public static String SerialLinePanel_info_editableTTYBaudRateSelected;
+ public static String SerialLinePanel_warning_FailedToLoadSerialPorts;
+ public static String SerialLinePanel_task_queryAvailableSerialDevices;
+
+ public static String SerialPortAddressDialog_port;
+ public static String SerialPortAddressDialog_Information_MissingPort;
+ public static String SerialPortAddressDialog_Error_InvalidPort;
+ public static String SerialPortAddressDialog_Error_InvalidPortRange;
+
public static String NameOrIPValidator_Information_MissingNameOrIP;
public static String NameOrIPValidator_Information_MissingName;
public static String NameOrIPValidator_Information_MissingIP;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.properties
index ff4d2580a..a44540104 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/nls/Messages.properties
@@ -15,6 +15,9 @@ FileSelectionControl_title_save=Save File
FileSelectionControl_group_label=Select file
FileSelectionControl_editfield_label=File:
+NameControl_label=Name:
+NameControl_info_missingValue=Please enter a name.
+
RemoteHostAddressControl_label=Target name or address:
RemoteHostAddressControl_button_label=Check...
RemoteHostAddressControl_information_checkNameAddressUserInformation=The target name can be validated by pressing the check button.
@@ -27,6 +30,42 @@ RemoteHostAddressControl_error_targetNameNotResolveable=Cannot resolve the targe
RemoteHostPortControl_label=Port:
+WireTypeControl_label=Wire Type:
+WireTypeControl_networkType_label=Network Cable
+WireTypeControl_serialType_label=Serial Line
+
+NetworkCablePanel_section=Specify the target agent's address and port:
+NetworkCablePanel_addressControl_label=Address:
+
+SerialLinePanel_section=Specify the serial communication parameters:
+SerialLinePanel_hostTTYDevice_label=Host serial device:
+SerialLinePanel_hostTTYSpeed_label=Serial device speed (bit/s):
+SerialLinePanel_hostTTYDatabits_label=Data Bits:
+SerialLinePanel_hostTTYParity_label=Parity:
+SerialLinePanel_hostTTYStopbits_label=Stop Bits:
+SerialLinePanel_hostTTYFlowControl_label=Flow Control:
+SerialLinePanel_customSerialDevice_title=Choose Custom Serial Device
+SerialLinePanel_customSerialDevice_message=Please enter name of the custom serial device:
+SerialLinePanel_customSerialBaudRate_title=Choose Custom Serial Baud Rate
+SerialLinePanel_customSerialBaudRate_message=Please enter the custom serial baud rate:
+SerialLinePanel_error_invalidCharactes=The device name you've entered contains invalid characters.
+SerialLinePanel_error_invalidCharactesBaudRate=The baud rate you've entered contains invalid characters.
+SerialLinePanel_error_emptyHostTTYDevice=Please select a valid host serial device.
+SerialLinePanel_error_emptyHostTTYSpeedRate=Please select a valid serial device speed.
+SerialLinePanel_error_emptyHostTTYDatabits=Please select a valid number of data bits.
+SerialLinePanel_error_emptyHostTTYParity=Please select a valid parity.
+SerialLinePanel_error_emptyHostTTYStopbits=Please select a valid number of stop bits.
+SerialLinePanel_error_emptyHostTTYFlowControl=Please select a valid flow control.
+SerialLinePanel_info_editableTTYDeviceSelected=Please re-select ''Other...'' again to activate the custom serial device input dialog.
+SerialLinePanel_info_editableTTYBaudRateSelected=Please re-select ''Other...'' again to activate the custom serial baud rate input dialog.
+SerialLinePanel_warning_FailedToLoadSerialPorts=Failed to enumerate the systems serial ports.
+SerialLinePanel_task_queryAvailableSerialDevices=Query available serial devices...
+
+SerialPortAddressDialog_port=Port:
+SerialPortAddressDialog_Information_MissingPort=Please enter a valid target port number.
+SerialPortAddressDialog_Error_InvalidPort=Target port number must be a valid number in the range of 0 to 65535.
+SerialPortAddressDialog_Error_InvalidPortRange=Target port number must be in the range of 0 to 65535.
+
NameOrIPValidator_Information_MissingNameOrIP=Please enter a hostname or IP address.
NameOrIPValidator_Information_MissingName=Please enter a hostname.
NameOrIPValidator_Information_MissingIP=Please enter an IP address.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypeControl.java
new file mode 100644
index 000000000..bf1e0ba04
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypeControl.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.core.nodes.interfaces.wire.IWireTypeNetwork;
+import org.eclipse.tcf.te.core.nodes.interfaces.wire.IWireTypeSerial;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.controls.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+
+/**
+ * Wire type control implementation.
+ */
+public class WireTypeControl extends BaseEditBrowseTextControl {
+
+ public final static String[] WIRE_TYPES = new String[] {
+ IWireTypeNetwork.PROPERTY_CONTAINER_NAME,
+ IWireTypeSerial.PROPERTY_CONTAINER_NAME
+ };
+
+ /**
+ * Constructor.
+ *
+ * @param parentPage The parent dialog page this control is embedded in.
+ * Might be <code>null</code> if the control is not associated with a page.
+ */
+ public WireTypeControl(IDialogPage parentPage) {
+ super(parentPage);
+ setIsGroup(false);
+ setReadOnly(true);
+ setHideBrowseButton(true);
+ setEditFieldLabel(Messages.WireTypeControl_label);
+ setAdjustBackgroundColor(parentPage != null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#setupPanel(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void setupPanel(Composite parent) {
+ super.setupPanel(parent);
+
+ List<String> wireTypeLabels = new ArrayList<String>();
+ for (String wireType : WIRE_TYPES) {
+ String label = getWireTypeLabel(wireType);
+ if (label != null) wireTypeLabels.add(label);
+ }
+
+ setEditFieldControlHistory(wireTypeLabels.toArray(new String[wireTypeLabels.size()]));
+ SWTControlUtil.select(getEditFieldControl(), 0);
+ }
+
+ /**
+ * Returns the label of the given wire type.
+ *
+ * @param wireType The wire type. Must not be <code>null</code>.
+ * @return The corresponding label or <code>null</code> if the wire type is unknown.
+ */
+ protected String getWireTypeLabel(String wireType) {
+ Assert.isNotNull(wireType);
+
+ if (IWireTypeNetwork.PROPERTY_CONTAINER_NAME.equals(wireType)) return Messages.WireTypeControl_networkType_label;
+ if (IWireTypeSerial.PROPERTY_CONTAINER_NAME.equals(wireType)) return Messages.WireTypeControl_serialType_label;
+
+ return null;
+ }
+
+ /**
+ * Returns the currently selected wire type.
+ *
+ * @return The currently selected wire type.
+ */
+ public String getSelectedWireType() {
+ String type = getEditFieldControlText();
+
+ if (Messages.WireTypeControl_networkType_label.equals(type)) type = IWireTypeNetwork.PROPERTY_CONTAINER_NAME;
+ else if (Messages.WireTypeControl_serialType_label.equals(type)) type = IWireTypeSerial.PROPERTY_CONTAINER_NAME;
+
+ return type;
+ }
+
+ /**
+ * Sets the selected wire type to the specified one.
+ *
+ * @param wireType The wire type. Must not be <code>null</code>.
+ */
+ public void setSelectedWireType(String wireType) {
+ Assert.isNotNull(wireType);
+
+ // Get the wire type label for given wire type
+ String label = getWireTypeLabel(wireType);
+ int index = SWTControlUtil.indexOf(getEditFieldControl(), label);
+ if (index != -1) SWTControlUtil.select(getEditFieldControl(), index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ */
+ @Override
+ public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
+ // The widget is not user editable and the history is used
+ // for presenting the available wire types. Neither save
+ // or restore the history actively.
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ */
+ @Override
+ public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
+ // The widget is not user editable and the history is used
+ // for presenting the available wire types. Neither save
+ // or restore the history actively.
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypePanelControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypePanelControl.java
new file mode 100644
index 000000000..f80f38dd3
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/WireTypePanelControl.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.tcf.te.ui.controls.BaseWizardConfigurationPanelControl;
+
+/**
+ * Custom wire type wizard panel control.
+ */
+public class WireTypePanelControl extends BaseWizardConfigurationPanelControl {
+
+ /**
+ * Constructor.
+ *
+ * @param parentPage The parent dialog page this control is embedded in.
+ * Might be <code>null</code> if the control is not associated with a page.
+ */
+ public WireTypePanelControl(IDialogPage parentPage) {
+ super(parentPage);
+ }
+
+} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkAddressControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkAddressControl.java
new file mode 100644
index 000000000..7f280c4d7
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkAddressControl.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire.network;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl;
+import org.eclipse.tcf.te.ui.controls.nls.Messages;
+import org.eclipse.tcf.te.ui.wizards.interfaces.IValidatableWizardPage;
+
+/**
+ * Network cable panel remote host address control implementation.
+ */
+public class NetworkAddressControl extends RemoteHostAddressControl {
+ // Reference to the parent network cable panel
+ private final NetworkCablePanel networkPanel;
+
+ /**
+ * Constructor.
+ *
+ * @param networkPanel The parent network cable. Must not be <code>null</code>.
+ */
+ public NetworkAddressControl(NetworkCablePanel networkPanel) {
+ super(null);
+
+ Assert.isNotNull(networkPanel);
+ this.networkPanel = networkPanel;
+
+ setEditFieldLabel(Messages.NetworkCablePanel_addressControl_label);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatableWizardPage()
+ */
+ @Override
+ public IValidatableWizardPage getValidatableWizardPage() {
+ return networkPanel.getParentControl().getValidatableWizardPage();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ super.modifyText(e);
+ if (networkPanel.getParentControl() instanceof ModifyListener) {
+ ((ModifyListener)networkPanel.getParentControl()).modifyText(e);
+ }
+ }
+} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkCablePanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkCablePanel.java
new file mode 100644
index 000000000..246e89e27
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkCablePanel.java
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire.network;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.core.nodes.interfaces.wire.IWireTypeNetwork;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Network cable wire type wizard configuration panel.
+ */
+public class NetworkCablePanel extends AbstractWizardConfigurationPanel implements ISharedDataWizardPage {
+ private NetworkAddressControl addressControl = null;
+ private NetworkPortControl portControl = null;
+
+ /**
+ * Constructor.
+ *
+ * @param parentPageControl The parent control. Must not be <code>null</code>!
+ */
+ public NetworkCablePanel(BaseDialogPageControl parentPageControl) {
+ super(parentPageControl);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (addressControl != null) { addressControl.dispose(); addressControl = null; }
+ if (portControl != null) { portControl.dispose(); portControl = null; }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ public void setupPanel(Composite parent, FormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ boolean adjustBackgroundColor = getParentControl().getParentPage() != null;
+
+ Composite panel = toolkit.createComposite(parent);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (adjustBackgroundColor) panel.setBackground(parent.getBackground());
+
+ setControl(panel);
+
+ // Create the wire type section
+ Section section = toolkit.createSection(panel, ExpandableComposite.TITLE_BAR);
+ Assert.isNotNull(section);
+ section.setText(Messages.NetworkCablePanel_section);
+ section.setLayout(new GridLayout());
+ section.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ if (adjustBackgroundColor) section.setBackground(panel.getBackground());
+
+ Composite client = toolkit.createComposite(section);
+ Assert.isNotNull(client);
+ client.setLayout(new GridLayout());
+ client.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (adjustBackgroundColor) client.setBackground(section.getBackground());
+ section.setClient(client);
+
+ addressControl = doCreateAddressControl(this);
+ addressControl.setupPanel(client);
+
+ portControl = doCreatePortControl(this);
+ portControl.setParentControlIsInnerPanel(true);
+ portControl.setupPanel(addressControl.getInnerPanelComposite());
+ }
+
+ /**
+ * Creates the address control instance.
+ *
+ * @param parentPanel The parent network cable panel. Must not be <code>null</code>.
+ * @return The address control instance.
+ */
+ protected NetworkAddressControl doCreateAddressControl(NetworkCablePanel parentPanel) {
+ Assert.isNotNull(parentPanel);
+ return new NetworkAddressControl(parentPanel);
+ }
+
+ /**
+ * Creates the port control instance.
+ *
+ * @param parentPanel The parent network cable panel. Must not be <code>null</code>.
+ * @return The port control instance.
+ */
+ protected NetworkPortControl doCreatePortControl(NetworkCablePanel parentPanel) {
+ Assert.isNotNull(parentPanel);
+ return new NetworkPortControl(parentPanel);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#setEnabled(boolean)
+ */
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ if (addressControl != null) {
+ if (keepLabelsAlwaysEnabled()) {
+ SWTControlUtil.setEnabled(addressControl.getEditFieldControl(), enabled);
+ SWTControlUtil.setEnabled(addressControl.getButtonControl(), enabled);
+ } else {
+ addressControl.setEnabled(enabled);
+ }
+ }
+ if (portControl != null) {
+ if (keepLabelsAlwaysEnabled()) {
+ SWTControlUtil.setEnabled(portControl.getEditFieldControl(), enabled);
+ SWTControlUtil.setEnabled(portControl.getButtonControl(), enabled);
+ } else {
+ portControl.setEnabled(enabled);
+ }
+ }
+ }
+
+ /**
+ * Returns if or if not the control labels shall be kept enabled even
+ * if the state of the control is set to disabled.
+ *
+ * @return <code>True</code> to keep control labels enabled, <code>false</code> otherwise.
+ */
+ protected boolean keepLabelsAlwaysEnabled() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ boolean valid = super.isValid();
+ if (!valid) return false;
+
+ valid = addressControl.isValid();
+ setMessage(addressControl.getMessage(), addressControl.getMessageType());
+
+ valid &= portControl.isValid();
+ if (portControl.getMessageType() > getMessageType()) {
+ setMessage(portControl.getMessage(), portControl.getMessageType());
+ }
+
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#dataChanged(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer, org.eclipse.swt.events.TypedEvent)
+ */
+ @Override
+ public boolean dataChanged(IPropertiesContainer data, TypedEvent e) {
+ Assert.isNotNull(data);
+
+ boolean isDirty = false;
+
+ Map<String, Object> container = (Map<String, Object>)data.getProperty(IWireTypeNetwork.PROPERTY_CONTAINER_NAME);
+ if (container == null) container = new HashMap<String, Object>();
+
+ if (addressControl != null) {
+ String address = addressControl.getEditFieldControlText();
+ if (address != null) isDirty |= !address.equals(container.get(IWireTypeNetwork.PROPERTY_NETWORK_ADDRESS) != null ? container.get(IWireTypeNetwork.PROPERTY_NETWORK_ADDRESS) : ""); //$NON-NLS-1$
+ }
+
+ if (portControl != null) {
+ String port = portControl.getEditFieldControlText();
+ if (port != null) isDirty |= !port.equals(container.get(IWireTypeNetwork.PROPERTY_NETWORK_PORT) != null ? container.get(IWireTypeNetwork.PROPERTY_NETWORK_PORT) : ""); //$NON-NLS-1$
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#setupData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void setupData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ Map<String, Object> container = (Map<String, Object>)data.getProperty(IWireTypeNetwork.PROPERTY_CONTAINER_NAME);
+ if (container == null) container = new HashMap<String, Object>();
+
+ if (addressControl != null) {
+ addressControl.setEditFieldControlText((String)container.get(IWireTypeNetwork.PROPERTY_NETWORK_ADDRESS));
+ }
+
+ if (portControl != null) {
+ portControl.setEditFieldControlText((String)container.get(IWireTypeNetwork.PROPERTY_NETWORK_PORT));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#extractData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void extractData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ Map<String, Object> container = (Map<String, Object>)data.getProperty(IWireTypeNetwork.PROPERTY_CONTAINER_NAME);
+ if (container == null) container = new HashMap<String, Object>();
+
+ if (addressControl != null) {
+ container.put(IWireTypeNetwork.PROPERTY_NETWORK_ADDRESS, addressControl.getEditFieldControlText());
+ }
+
+ if (portControl != null) {
+ container.put(IWireTypeNetwork.PROPERTY_NETWORK_PORT, portControl.getEditFieldControlText());
+ }
+
+ data.setProperty(IWireTypeNetwork.PROPERTY_CONTAINER_NAME, !container.isEmpty() ? container : null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#initializeData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void initializeData(IPropertiesContainer data) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#removeData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void removeData(IPropertiesContainer data) {
+ if (data == null) return;
+ data.setProperty(IWireTypeNetwork.PROPERTY_CONTAINER_NAME, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ */
+ @Override
+ public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
+ super.doSaveWidgetValues(settings, idPrefix);
+ if (addressControl != null) addressControl.doSaveWidgetValues(settings, idPrefix);
+ if (portControl != null) portControl.doSaveWidgetValues(settings, idPrefix);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ */
+ @Override
+ public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
+ super.doRestoreWidgetValues(settings, idPrefix);
+ if (addressControl != null) addressControl.doRestoreWidgetValues(settings, idPrefix);
+ if (portControl != null) portControl.doRestoreWidgetValues(settings, idPrefix);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkPortControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkPortControl.java
new file mode 100644
index 000000000..1075911e6
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/network/NetworkPortControl.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire.network;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.tcf.te.ui.controls.net.RemoteHostPortControl;
+import org.eclipse.tcf.te.ui.wizards.interfaces.IValidatableWizardPage;
+
+/**
+ * Local remote host port control implementation.
+ */
+class NetworkPortControl extends RemoteHostPortControl {
+ // Reference to the parent network cable panel
+ private final NetworkCablePanel networkPanel;
+
+ /**
+ * Constructor.
+ *
+ * @param networkPanel The parent network cable. Must not be <code>null</code>.
+ */
+ public NetworkPortControl(NetworkCablePanel networkPanel) {
+ super(null);
+
+ Assert.isNotNull(networkPanel);
+ this.networkPanel = networkPanel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatableWizardPage()
+ */
+ @Override
+ public IValidatableWizardPage getValidatableWizardPage() {
+ return networkPanel.getParentControl().getValidatableWizardPage();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ super.modifyText(e);
+ if (networkPanel.getParentControl() instanceof ModifyListener) {
+ ((ModifyListener)networkPanel.getParentControl()).modifyText(e);
+ }
+ }
+} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialLinePanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialLinePanel.java
new file mode 100644
index 000000000..35dcc8bff
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialLinePanel.java
@@ -0,0 +1,930 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire.serial;
+
+import gnu.io.CommPortIdentifier;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.tcf.te.core.nodes.interfaces.wire.IWireTypeSerial;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.controls.interfaces.tracing.ITraceIds;
+import org.eclipse.tcf.te.ui.controls.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.controls.validator.NumberValidator;
+import org.eclipse.tcf.te.ui.controls.validator.RegexValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.tcf.te.ui.wizards.interfaces.IValidatableWizardPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Serial line wire type wizard configuration panel.
+ */
+public class SerialLinePanel extends AbstractWizardConfigurationPanel implements ISharedDataWizardPage {
+ public static final String fcDefaultTTYSpeed = "9600"; //$NON-NLS-1$
+ public static final String fcDefaultTTYDeviceWin32 = "COM2"; //$NON-NLS-1$
+ public static final String fcDefaultTTYDeviceSolaris = "/dev/cua/b"; //$NON-NLS-1$
+ public static final String fcDefaultTTYDeviceLinux = "/dev/ttyS1"; //$NON-NLS-1$
+ public static final String fcDefaultTTYDatabits = "8"; //$NON-NLS-1$
+ public static final String fcDefaultTTYParity = "None"; //$NON-NLS-1$
+ public static final String fcDefaultTTYStopbits = "1"; //$NON-NLS-1$
+ public static final String fcDefaultTTYFlowControl = "None"; //$NON-NLS-1$
+ public static final String fcEditableTTYOther = "Other..."; //$NON-NLS-1$
+
+ public static final String[] fcTTYSpeedRates = { "600", //$NON-NLS-1$
+ "1200", //$NON-NLS-1$
+ "2400", //$NON-NLS-1$
+ "4800", //$NON-NLS-1$
+ "9600", //$NON-NLS-1$
+ "14400", //$NON-NLS-1$
+ "19200", //$NON-NLS-1$
+ "38400", //$NON-NLS-1$
+ "57600", //$NON-NLS-1$
+ "115200" //$NON-NLS-1$
+ };
+
+ public static final String[] fcTTYDatabits = {
+ "8", "7" //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ public static final String[] fcTTYParity = {
+ "None", "Odd", "Even" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+
+ public static final String[] fcTTYStopbits = {
+ "1", "2" //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ public static final String[] fcTTYFlowControl = {
+ "None", "Hardware", "Software" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+
+ private final boolean editable;
+ private final boolean layoutInRows;
+ private final boolean showAdvancedSerialOptions;
+
+ Label hostTTYDeviceLabel;
+ Combo hostTTYDeviceCombo;
+ Label hostTTYSpeedLabel;
+ Combo hostTTYSpeedCombo;
+ Label hostTTYBitsLabel;
+ Combo hostTTYBitsCombo;
+ Label hostTTYParityLabel;
+ Combo hostTTYParityCombo;
+ Label hostTTYStopbitsLabel;
+ Combo hostTTYStopbitsCombo;
+ Label hostTTYFlowControlLabel;
+ Combo hostTTYFlowControlCombo;
+
+ // Keep the fInputValidator protected!
+ protected IInputValidator inputValidatorBaud;
+
+ int lastSelected = -1;
+ int lastSelectedBaud = -1;
+
+ /**
+ * Constructor.
+ *
+ * @param parentPageControl The parent control this backend configuration panel is embedded in. Must not be <code>null</code>!
+ * @param layoutInRows Specify <code>true</code> if the configuration panel controls should be layout one per row, <code>false</code> otherwise.
+ * @param editable Specify <code>true</code> if the user should be allowed to edit the serial device name, <code>false</code> otherwise.
+ */
+ public SerialLinePanel(BaseDialogPageControl parentPageControl, boolean layoutInRows, boolean editable) {
+ this(parentPageControl, layoutInRows, editable, false);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentPageControl The parent control this backend configuration panel is embedded in. Must not be <code>null</code>!
+ * @param layoutInRows Specify <code>true</code> if the configuration panel controls should be layout one per row, <code>false</code> otherwise.
+ * @param editable Specify <code>true</code> if the user should be allowed to edit the serial device name and serial baud rate, <code>false</code> otherwise.
+ * @param showAdvancedOptions If <code>true</code>, advanced serial options are available to the user.
+ */
+ public SerialLinePanel(BaseDialogPageControl parentPageControl, boolean layoutInRows, boolean editable, boolean showAdvancedOptions) {
+ super(parentPageControl);
+ this.layoutInRows = layoutInRows;
+ this.editable = editable;
+ this.showAdvancedSerialOptions = showAdvancedOptions;
+ }
+
+ protected class CustomSerialBaudRateInputValidator implements IInputValidator {
+ private final Validator fValidator;
+
+ /**
+ * Constructor.
+ *
+ */
+ public CustomSerialBaudRateInputValidator() {
+ fValidator = new NumberValidator();
+ fValidator.setMessageText(RegexValidator.ERROR_INVALID_VALUE, Messages.SerialLinePanel_error_invalidCharactesBaudRate);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String)
+ */
+ @Override
+ public String isValid(String newText) {
+ if (newText != null && newText.trim().length() > 0) {
+ if (!fValidator.isValid(newText)) {
+ return fValidator.getMessage();
+ }
+ } else if (newText != null) {
+ // Empty string is an error without message (see interface)!
+ return ""; //$NON-NLS-1$
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Returns the input validator to be used for checking the custom serial
+ * baud rate for basic plausibility.
+ */
+ protected IInputValidator getCustomSerialBaudRateInputValidator() {
+ if (inputValidatorBaud == null) {
+ inputValidatorBaud = new CustomSerialBaudRateInputValidator();
+ }
+ return inputValidatorBaud;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ public void setupPanel(Composite parent, FormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ boolean adjustBackgroundColor = getParentControl().getParentPage() != null;
+
+ Composite panel = toolkit.createComposite(parent);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (adjustBackgroundColor) panel.setBackground(parent.getBackground());
+
+ setControl(panel);
+
+ // Create the wire type section
+ // Create the wire type section
+ Section section = toolkit.createSection(panel, ExpandableComposite.TITLE_BAR);
+ Assert.isNotNull(section);
+ section.setText(Messages.SerialLinePanel_section);
+ section.setLayout(new GridLayout());
+ section.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ if (adjustBackgroundColor) section.setBackground(panel.getBackground());
+
+ final Composite client = toolkit.createComposite(section);
+ Assert.isNotNull(client);
+ client.setLayout(new GridLayout(layoutInRows ? 2 : 4, false));
+ client.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (adjustBackgroundColor) client.setBackground(section.getBackground());
+ section.setClient(client);
+
+ // Host TTY settings
+ hostTTYDeviceLabel = new Label(client, SWT.NONE);
+ hostTTYDeviceLabel.setText(Messages.SerialLinePanel_hostTTYDevice_label);
+
+ hostTTYDeviceCombo = new Combo(client, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ hostTTYDeviceCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostTTYDeviceCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // if the user selected the special editable device, show a dialog asking for the device name
+ if (fcEditableTTYOther.equals(SWTControlUtil.getText(hostTTYDeviceCombo))) {
+ List<String> tty = new ArrayList<String>();
+ List<String> tcp = new ArrayList<String>();
+ String selected = SWTControlUtil.getItem(hostTTYDeviceCombo, lastSelected);
+ for (String device : SWTControlUtil.getItems(hostTTYDeviceCombo)) {
+ if (!device.equalsIgnoreCase(fcEditableTTYOther)) {
+ if (device.toUpperCase().startsWith("TCP:")) { //$NON-NLS-1$
+ tcp.add(device);
+ }
+ else {
+ tty.add(device);
+ }
+ }
+ }
+ SerialPortAddressDialog dialog = new SerialPortAddressDialog(client.getShell(), selected, tty, tcp);
+ if (dialog.open() == Window.OK) {
+ // retrieve the custom serial device name and set it to the combobox drop
+ String device = dialog.getData();
+ if (device != null && device.trim().length() > 0) {
+ SWTControlUtil.add(hostTTYDeviceCombo, device.trim());
+ SWTControlUtil.setText(hostTTYDeviceCombo, device.trim());
+ } else if (lastSelected != -1) {
+ SWTControlUtil.setText(hostTTYDeviceCombo, SWTControlUtil.getItem(hostTTYDeviceCombo, lastSelected));
+ }
+ } else if (lastSelected != -1){
+ SWTControlUtil.setText(hostTTYDeviceCombo, SWTControlUtil.getItem(hostTTYDeviceCombo, lastSelected));
+ }
+ }
+ lastSelected = SWTControlUtil.getSelectionIndex(hostTTYDeviceCombo);
+
+ IValidatableWizardPage validatable = SerialLinePanel.this.getParentControl().getValidatableWizardPage();
+ if (validatable != null) validatable.validatePage();
+ }
+ });
+
+ hostTTYSpeedLabel = new Label(client, SWT.NONE);
+ hostTTYSpeedLabel.setText(Messages.SerialLinePanel_hostTTYSpeed_label);
+
+ hostTTYSpeedCombo = new Combo(client, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ hostTTYSpeedCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostTTYSpeedCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // if the user selected the special editable baud rate, show a dialog asking for the baud rate
+ if (fcEditableTTYOther.equals(SWTControlUtil.getText(hostTTYSpeedCombo))) {
+ InputDialog dialog = new InputDialog(getControl().getShell(),
+ Messages.SerialLinePanel_customSerialBaudRate_title,
+ Messages.SerialLinePanel_customSerialBaudRate_message,
+ "", //$NON-NLS-1$
+ getCustomSerialBaudRateInputValidator());
+ if (dialog.open() == Window.OK) {
+ // retrieve the custom serial device name and set it to the combobox drop
+ String device = dialog.getValue();
+ if (device != null && device.trim().length() > 0) {
+ int index = SWTControlUtil.indexOf(hostTTYSpeedCombo, fcEditableTTYOther);
+ if (index != -1 && index == SWTControlUtil.getItemCount(hostTTYSpeedCombo) - 1) {
+ SWTControlUtil.add(hostTTYSpeedCombo, device.trim());
+ } else if (index != -1) {
+ SWTControlUtil.setItem(hostTTYSpeedCombo, index + 1, device.trim());
+ }
+ SWTControlUtil.setText(hostTTYSpeedCombo, device.trim());
+ } else if (lastSelectedBaud != -1) {
+ SWTControlUtil.setText(hostTTYSpeedCombo, SWTControlUtil.getItem(hostTTYSpeedCombo, lastSelectedBaud));
+ }
+ } else if (lastSelectedBaud != -1){
+ SWTControlUtil.setText(hostTTYSpeedCombo, SWTControlUtil.getItem(hostTTYSpeedCombo, lastSelectedBaud));
+ }
+ }
+ lastSelectedBaud = SWTControlUtil.getSelectionIndex(hostTTYSpeedCombo);
+
+ IValidatableWizardPage validatable = SerialLinePanel.this.getParentControl().getValidatableWizardPage();
+ if (validatable != null) validatable.validatePage();
+ }
+ });
+
+ // Query the list of available serial port interfaces.
+ UIPlugin.getTraceHandler().trace("SerialLinePanel: Start quering the available comm ports.", ITraceIds.TRACE_SERIAL_LINE_PANEL, this); //$NON-NLS-1$
+
+ // Query the serial devices now. If we are in the wizard, we can show a progress
+ // bar in the bottom of the wizard. Otherwise, show at least a busy indicator.
+ if (getParentControl().getRunnableContext() instanceof WizardDialog) {
+ IRunnableContext context = getParentControl().getRunnableContext();
+
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(Messages.SerialLinePanel_task_queryAvailableSerialDevices, IProgressMonitor.UNKNOWN);
+ queryAvailableSerialDevices();
+ monitor.done();
+ }
+ };
+ try {
+ context.run(true, false, runnable);
+ } catch (InvocationTargetException e) {
+ /* ignored on purpose. The runnable is directly declared here. */
+ } catch (InterruptedException e) {
+ /* ignored on purpose. The runnable is not cancelable */
+ }
+ } else {
+ BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
+ @Override
+ public void run() {
+ queryAvailableSerialDevices();
+ }
+ });
+ }
+
+ // add a special device which is being the editable one if requested at the end of the list
+ if (editable) {
+ SWTControlUtil.add(hostTTYDeviceCombo, fcEditableTTYOther);
+ }
+
+ if (SWTControlUtil.indexOf(hostTTYDeviceCombo, getDefaultHostTTYDevice()) != -1) {
+ SWTControlUtil.setText(hostTTYDeviceCombo, getDefaultHostTTYDevice());
+ } else {
+ if ("".equals(SWTControlUtil.getText(hostTTYDeviceCombo)) && SWTControlUtil.getItemCount(hostTTYDeviceCombo) > 0) { //$NON-NLS-1$
+ // USI: For SWT-GTK we need the special empty entry as well. Otherwise we will have problems
+ // getting the selection changed event!
+ if (SWTControlUtil.getItemCount(hostTTYDeviceCombo) == 1
+ && fcEditableTTYOther.equals(SWTControlUtil.getItem(hostTTYDeviceCombo, 0))) {
+ SWTControlUtil.add(hostTTYDeviceCombo, "", 0, true); //$NON-NLS-1$
+ }
+ SWTControlUtil.setText(hostTTYDeviceCombo, SWTControlUtil.getItem(hostTTYDeviceCombo, 0));
+ }
+ }
+
+ if (SWTControlUtil.getItemCount(hostTTYDeviceCombo) > 0) {
+ SWTControlUtil.setEnabled(hostTTYDeviceCombo, true);
+ } else {
+ SWTControlUtil.setEnabled(hostTTYDeviceCombo, false);
+ }
+ lastSelected = SWTControlUtil.getSelectionIndex(hostTTYDeviceCombo);
+
+ for (String fcTTYSpeedRate : fcTTYSpeedRates) {
+ SWTControlUtil.add(hostTTYSpeedCombo, fcTTYSpeedRate);
+ }
+ if (editable) {
+ SWTControlUtil.add(hostTTYSpeedCombo, fcEditableTTYOther);
+ }
+
+ SWTControlUtil.setText(hostTTYSpeedCombo, fcDefaultTTYSpeed);
+ lastSelectedBaud = SWTControlUtil.getSelectionIndex(hostTTYSpeedCombo);
+
+ // add the advanced serial options if configured
+ if (showAdvancedSerialOptions) {
+ Composite bitsPanel = layoutInRows ? getControl() : new Composite(getControl(), SWT.NONE);
+ if (!layoutInRows) {
+ layout = new GridLayout();
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ layout.numColumns = 3;
+ bitsPanel.setLayout(layout);
+ GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
+ layoutData.horizontalSpan = 4;
+ bitsPanel.setLayoutData(layoutData);
+ }
+
+ Composite panel2 = layoutInRows ? getControl() : new Composite(bitsPanel, SWT.NONE);
+ if (!layoutInRows) {
+ layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ hostTTYBitsLabel = new Label(panel2, SWT.NONE);
+ hostTTYBitsLabel.setText(Messages.SerialLinePanel_hostTTYDatabits_label);
+ hostTTYBitsCombo = new Combo(panel2, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ hostTTYBitsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostTTYBitsCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IValidatableWizardPage validatable = SerialLinePanel.this.getParentControl().getValidatableWizardPage();
+ if (validatable != null) validatable.validatePage();
+ }
+ });
+
+ for (String fcTTYDatabit : fcTTYDatabits) {
+ SWTControlUtil.add(hostTTYBitsCombo, fcTTYDatabit);
+ }
+ SWTControlUtil.setText(hostTTYBitsCombo, fcDefaultTTYDatabits);
+
+ panel = layoutInRows ? getControl() : new Composite(bitsPanel, SWT.NONE);
+ if (!layoutInRows) {
+ layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ hostTTYParityLabel = new Label(panel2, SWT.NONE);
+ hostTTYParityLabel.setText(Messages.SerialLinePanel_hostTTYParity_label);
+ hostTTYParityCombo = new Combo(panel2, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ hostTTYParityCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostTTYParityCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IValidatableWizardPage validatable = SerialLinePanel.this.getParentControl().getValidatableWizardPage();
+ if (validatable != null) validatable.validatePage();
+ }
+ });
+
+ for (String element : fcTTYParity) {
+ SWTControlUtil.add(hostTTYParityCombo, element);
+ }
+ SWTControlUtil.setText(hostTTYParityCombo, fcDefaultTTYParity);
+
+ panel = layoutInRows ? getControl() : new Composite(bitsPanel, SWT.NONE);
+ if (!layoutInRows) {
+ layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ hostTTYStopbitsLabel = new Label(panel2, SWT.NONE);
+ hostTTYStopbitsLabel.setText(Messages.SerialLinePanel_hostTTYStopbits_label);
+ hostTTYStopbitsCombo = new Combo(panel2, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ hostTTYStopbitsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostTTYStopbitsCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IValidatableWizardPage validatable = SerialLinePanel.this.getParentControl().getValidatableWizardPage();
+ if (validatable != null) validatable.validatePage();
+ }
+ });
+
+ for (String fcTTYStopbit : fcTTYStopbits) {
+ SWTControlUtil.add(hostTTYStopbitsCombo, fcTTYStopbit);
+ }
+ SWTControlUtil.setText(hostTTYStopbitsCombo, fcDefaultTTYStopbits);
+
+ panel = layoutInRows ? getControl() : new Composite(bitsPanel, SWT.NONE);
+ if (!layoutInRows) {
+ layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ panel.setLayout(layout);
+ GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
+ layoutData.horizontalSpan = 3;
+ panel.setLayoutData(layoutData);
+ }
+
+ hostTTYFlowControlLabel = new Label(panel2, SWT.NONE);
+ hostTTYFlowControlLabel.setText(Messages.SerialLinePanel_hostTTYFlowControl_label);
+ hostTTYFlowControlCombo = new Combo(panel2, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ hostTTYFlowControlCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ hostTTYFlowControlCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IValidatableWizardPage validatable = SerialLinePanel.this.getParentControl().getValidatableWizardPage();
+ if (validatable != null) validatable.validatePage();
+ }
+ });
+
+ for (String element : fcTTYFlowControl) {
+ SWTControlUtil.add(hostTTYFlowControlCombo, element);
+ }
+ SWTControlUtil.setText(hostTTYFlowControlCombo, fcDefaultTTYFlowControl);
+ }
+ }
+
+ /**
+ * Query the list of serial devices via RXTX.
+ */
+ protected void queryAvailableSerialDevices() {
+ // java.lang.UnsatisfiedLinkError: ../plugins/gnu.io.rxtx.solaris.sparc_2.1.7.200702281917/os/solaris/sparc/librxtxSerial.so:
+ // Can't load Sparc 32-bit .so on a Sparc 32-bit platform
+ // May happen in CommPortIdentifier static constructor!
+ try {
+ Enumeration<CommPortIdentifier> ttyPortIds = CommPortIdentifier.getPortIdentifiers();
+ if (!ttyPortIds.hasMoreElements()) {
+ UIPlugin.getTraceHandler().trace("SerialLinePanel: NO comm ports available at all!", ITraceIds.TRACE_SERIAL_LINE_PANEL, this); //$NON-NLS-1$
+ }
+ final List<String> ports = new ArrayList<String>();
+ while (ttyPortIds.hasMoreElements()) {
+ CommPortIdentifier port = ttyPortIds.nextElement();
+ String type = "unknown"; //$NON-NLS-1$
+ if (port.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
+ type = "parallel"; //$NON-NLS-1$
+ }
+ if (port.getPortType() == CommPortIdentifier.PORT_SERIAL) {
+ type = "serial"; //$NON-NLS-1$
+ }
+ UIPlugin.getTraceHandler().trace("SerialLinePanel: Found comm port: name='" + port.getName() + "', type='" + type, ITraceIds.TRACE_SERIAL_LINE_PANEL, this); //$NON-NLS-1$ //$NON-NLS-2$
+ // only add serial ports
+ if (port.getPortType() == CommPortIdentifier.PORT_SERIAL) {
+ UIPlugin.getTraceHandler().trace("SerialLinePanel: Adding found serial comm port to combo!", ITraceIds.TRACE_SERIAL_LINE_PANEL, this); //$NON-NLS-1$
+ if (!ports.contains(port.getName())) {
+ ports.add(port.getName());
+ }
+ }
+ }
+ if (!ports.isEmpty()) {
+ Collections.sort(ports);
+ // This method may executed in a separate thread. We must spawn back
+ // into the UI thread to execute the adding of the ports to the control.
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ for (String port : ports) {
+ SWTControlUtil.add(hostTTYDeviceCombo, port);
+ }
+ }
+ });
+ }
+ } catch (UnsatisfiedLinkError e) {
+ IStatus status = new Status(IStatus.WARNING, UIPlugin.getUniqueIdentifier(),
+ Messages.SerialLinePanel_warning_FailedToLoadSerialPorts, e);
+ UIPlugin.getDefault().getLog().log(status);
+ } catch (NoClassDefFoundError e) {
+ // The NoClassDefFoundError happens the second time if the load of the library
+ // failed once! We do ignore this error completely!
+ }
+ }
+
+ /**
+ * Enables or disables the configuration panels controls.
+ *
+ * @param enabled Specify <code>true</code> to enable the controls, <code>false</code> otherwise.
+ */
+ @Override
+ public void setEnabled(boolean enabled) {
+ SWTControlUtil.setEnabled(hostTTYDeviceLabel, enabled);
+ SWTControlUtil.setEnabled(hostTTYDeviceCombo, enabled);
+ SWTControlUtil.setEnabled(hostTTYSpeedLabel, enabled);
+ SWTControlUtil.setEnabled(hostTTYSpeedCombo, enabled);
+ SWTControlUtil.setEnabled(hostTTYBitsLabel, enabled);
+ SWTControlUtil.setEnabled(hostTTYBitsCombo, enabled);
+ SWTControlUtil.setEnabled(hostTTYParityLabel, enabled);
+ SWTControlUtil.setEnabled(hostTTYParityCombo, enabled);
+ SWTControlUtil.setEnabled(hostTTYStopbitsLabel, enabled);
+ SWTControlUtil.setEnabled(hostTTYStopbitsCombo, enabled);
+ SWTControlUtil.setEnabled(hostTTYFlowControlLabel, enabled);
+ SWTControlUtil.setEnabled(hostTTYFlowControlCombo, enabled);
+ }
+
+ /**
+ * The name of the serial ports differ between the host platforms, so we have to
+ * detect the default host TTY device based on the host platform.
+ */
+ public String getDefaultHostTTYDevice() {
+ String osName = System.getProperty("os.name"); //$NON-NLS-1$
+ // Linux ?
+ if (osName.equalsIgnoreCase("Linux")) { //$NON-NLS-1$
+ return fcDefaultTTYDeviceLinux;
+ }
+ // Solaris ?
+ if (osName.equalsIgnoreCase("SunOS")) { //$NON-NLS-1$
+ return fcDefaultTTYDeviceSolaris;
+ }
+ // Windows ?
+ if (osName.toLowerCase().startsWith("windows")) { //$NON-NLS-1$
+ return fcDefaultTTYDeviceWin32;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the default value for the serial port default speed setting in bit/s
+ */
+ public String getDefaultHostTTYSpeed() {
+ return fcDefaultTTYSpeed;
+ }
+
+ /**
+ * Returns the default value for the serial port default data bits setting
+ */
+ public String getDefaultHostTTYDatabits() {
+ return fcDefaultTTYDatabits;
+ }
+
+ /**
+ * Returns the default value for the serial port default parity setting
+ */
+ public String getDefaultHostTTYParity() {
+ return fcDefaultTTYParity;
+ }
+
+ /**
+ * Returns the default value for the serial port default stop bits setting
+ */
+ public String getDefaultHostTTYStopbits() {
+ return fcDefaultTTYStopbits;
+ }
+
+ /**
+ * Returns the default value for the serial port default flow control setting
+ */
+ public String getDefaultHostTTYFlowControl() {
+ return fcDefaultTTYFlowControl;
+ }
+
+ /**
+ * Set the text to the combo if available as selectable option.
+ *
+ * @param combo The combo box control. Must not be <code>null</code>.
+ * @param value The value to set. Must not be <code>null</code>.
+ */
+ protected void doSetTextInCombo(Combo combo, String value) {
+ Assert.isNotNull(combo);
+ Assert.isNotNull(value);
+ if (SWTControlUtil.indexOf(combo, value) != 1) {
+ SWTControlUtil.setText(combo, value);
+ }
+ }
+
+ /**
+ * Select the given tty device if available.
+ *
+ * @param value The tty device to select. Must not be <code>null</code>.
+ */
+ public void setSelectedTTYDevice(String value) {
+ doSetTextInCombo(hostTTYDeviceCombo, value);
+ }
+
+ /**
+ * Select the given tty device if available. The method
+ * will do nothing if the specified index is invalid.
+ *
+ * @param index The index of the tty device to select.
+ */
+ public void setSelectedTTYDevice(int index) {
+ if (index >= 0 && index < SWTControlUtil.getItemCount(hostTTYDeviceCombo)) {
+ SWTControlUtil.setText(hostTTYDeviceCombo, SWTControlUtil.getItem(hostTTYDeviceCombo, index));
+ }
+ }
+
+ /**
+ * Select the given tty device speed if available.
+ *
+ * @param value The tty device speed to select. Must not be <code>null</code>.
+ */
+ public void setSelectedTTYSpeed(String value) {
+ doSetTextInCombo(hostTTYSpeedCombo, value);
+ }
+
+ /**
+ * Select the given tty device data bit configuration if available.
+ *
+ * @param value The tty device data bit configuration to select. Must not be <code>null</code>.
+ */
+ public void setSelectedTTYDatabits(String value) {
+ doSetTextInCombo(hostTTYBitsCombo, value);
+ }
+
+ /**
+ * Select the given tty device parity configuration if available.
+ *
+ * @param value The tty device parity configuration to select. Must not be <code>null</code>.
+ */
+ public void setSelectedTTYParity(String value) {
+ doSetTextInCombo(hostTTYParityCombo, value);
+ }
+
+ /**
+ * Select the given tty device stop bit configuration if available.
+ *
+ * @param value The tty device stop bit configuration to select. Must not be <code>null</code>.
+ */
+ public void setSelectedTTYStopbits(String value) {
+ doSetTextInCombo(hostTTYStopbitsCombo, value);
+ }
+
+ /**
+ * Select the given tty device flow control configuration if available.
+ *
+ * @param value The tty device flow control configuration to select. Must not be <code>null</code>.
+ */
+ public void setSelectedTTYFlowControl(String value) {
+ doSetTextInCombo(hostTTYFlowControlCombo, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ String selectedTTYDevice = SWTControlUtil.getText(hostTTYDeviceCombo);
+ if (selectedTTYDevice == null || selectedTTYDevice.trim().length() == 0) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYDevice, IMessageProvider.ERROR);
+ return false;
+ }
+
+ if (fcEditableTTYOther.equals(selectedTTYDevice)) {
+ setMessage(Messages.SerialLinePanel_info_editableTTYDeviceSelected, IMessageProvider.INFORMATION);
+ return false;
+ }
+
+ String selectedTTYSpeedRate = SWTControlUtil.getText(hostTTYSpeedCombo);
+ if (selectedTTYSpeedRate == null || selectedTTYSpeedRate.trim().length() == 0) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYSpeedRate, IMessageProvider.ERROR);
+ return false;
+ }
+
+ if (fcEditableTTYOther.equals(selectedTTYSpeedRate)) {
+ setMessage(Messages.SerialLinePanel_info_editableTTYBaudRateSelected, IMessageProvider.INFORMATION);
+ return false;
+ }
+
+ if (showAdvancedSerialOptions) {
+ String option = SWTControlUtil.getText(hostTTYBitsCombo);
+ if (option == null || option.trim().length() == 0) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYDatabits, IMessageProvider.ERROR);
+ return false;
+ }
+
+ option = SWTControlUtil.getText(hostTTYParityCombo);
+ if (option == null || option.trim().length() == 0) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYParity, IMessageProvider.ERROR);
+ return false;
+ }
+
+ option = SWTControlUtil.getText(hostTTYStopbitsCombo);
+ if (option == null || option.trim().length() == 0) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYStopbits, IMessageProvider.ERROR);
+ return false;
+ }
+
+ option = SWTControlUtil.getText(hostTTYFlowControlCombo);
+ if (option == null || option.trim().length() == 0) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYFlowControl, IMessageProvider.ERROR);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#dataChanged(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer, org.eclipse.swt.events.TypedEvent)
+ */
+ @Override
+ public boolean dataChanged(IPropertiesContainer data, TypedEvent e) {
+ Assert.isNotNull(data);
+
+ boolean isDirty = false;
+
+ Map<String, Object> container = (Map<String, Object>)data.getProperty(IWireTypeSerial.PROPERTY_CONTAINER_NAME);
+ if (container == null) container = new HashMap<String, Object>();
+
+ String value = SWTControlUtil.getText(hostTTYDeviceCombo);
+ if (value != null) isDirty |= !value.equals(container.get(IWireTypeSerial.PROPERTY_SERIAL_DEVICE) != null ? container.get(IWireTypeSerial.PROPERTY_SERIAL_DEVICE) : ""); //$NON-NLS-1$
+
+ value = SWTControlUtil.getText(hostTTYSpeedCombo);
+ if (value != null) isDirty |= !value.equals(container.get(IWireTypeSerial.PROPERTY_SERIAL_BAUD_RATE) != null ? container.get(IWireTypeSerial.PROPERTY_SERIAL_BAUD_RATE) : ""); //$NON-NLS-1$
+
+ if (showAdvancedSerialOptions) {
+ value = SWTControlUtil.getText(hostTTYBitsCombo);
+ if (value != null) isDirty |= !value.equals(container.get(IWireTypeSerial.PROPERTY_SERIAL_DATA_BITS) != null ? container.get(IWireTypeSerial.PROPERTY_SERIAL_DATA_BITS) : ""); //$NON-NLS-1$
+
+ value = SWTControlUtil.getText(hostTTYParityCombo);
+ if (value != null) isDirty |= !value.equals(container.get(IWireTypeSerial.PROPERTY_SERIAL_PARITY) != null ? container.get(IWireTypeSerial.PROPERTY_SERIAL_PARITY) : ""); //$NON-NLS-1$
+
+ value = SWTControlUtil.getText(hostTTYStopbitsCombo);
+ if (value != null) isDirty |= !value.equals(container.get(IWireTypeSerial.PROPERTY_SERIAL_STOP_BITS) != null ? container.get(IWireTypeSerial.PROPERTY_SERIAL_STOP_BITS) : ""); //$NON-NLS-1$
+
+ value = SWTControlUtil.getText(hostTTYFlowControlCombo);
+ if (value != null) isDirty |= !value.equals(container.get(IWireTypeSerial.PROPERTY_SERIAL_FLOW_CONTROL) != null ? container.get(IWireTypeSerial.PROPERTY_SERIAL_FLOW_CONTROL) : ""); //$NON-NLS-1$
+ }
+
+ return isDirty;
+ }
+
+ private final String fcSelectedTTYDeviceSlotId = "SerialLinePanel.selectedTTYDevice." + System.getProperty("os.name"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final String fcSelectedTTYSpeedRateSlotId = "SerialLinePanel.selectedTTYSpeedRate." + System.getProperty("os.name"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final String fcSelectedTTYDatabitsSlotId = "SerialLinePanel.selectedTTYDatabits." + System.getProperty("os.name"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final String fcSelectedTTYParitySlotId = "SerialLinePanel.selectedTTYParity." + System.getProperty("os.name"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final String fcSelectedTTYStopbitsSlotId = "SerialLinePanel.selectedTTYStopbits." + System.getProperty("os.name"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final String fcSelectedTTYFlowControlSlotId = "SerialLinePanel.selectedTTYFlowControl." + System.getProperty("os.name"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#doRestoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ */
+ @Override
+ public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
+ Assert.isNotNull(settings);
+
+ String selectedTTYDevice = settings.get(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYDeviceSlotId, idPrefix));
+ if (selectedTTYDevice != null && selectedTTYDevice.trim().length() > 0) {
+ if (SWTControlUtil.indexOf(hostTTYDeviceCombo, selectedTTYDevice) != -1) {
+ SWTControlUtil.setText(hostTTYDeviceCombo, selectedTTYDevice);
+ }
+ }
+
+ String selectedTTYSpeedRate = settings.get(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYSpeedRateSlotId, idPrefix));
+ if (selectedTTYSpeedRate != null && selectedTTYSpeedRate.trim().length() > 0) {
+ if (SWTControlUtil.indexOf(hostTTYSpeedCombo, selectedTTYSpeedRate) != -1) {
+ SWTControlUtil.setText(hostTTYSpeedCombo, selectedTTYSpeedRate);
+ }
+ }
+
+ if (showAdvancedSerialOptions) {
+ String option = settings.get(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYDatabitsSlotId, idPrefix));
+ if (option != null && option.trim().length() > 0 && SWTControlUtil.indexOf(hostTTYBitsCombo, option) != -1) {
+ SWTControlUtil.setText(hostTTYBitsCombo, option);
+ }
+
+ option = settings.get(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYParitySlotId, idPrefix));
+ if (option != null && option.trim().length() > 0 && SWTControlUtil.indexOf(hostTTYParityCombo, option) != -1) {
+ SWTControlUtil.setText(hostTTYParityCombo, option);
+ }
+
+ option = settings.get(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYStopbitsSlotId, idPrefix));
+ if (option != null && option.trim().length() > 0 && SWTControlUtil.indexOf(hostTTYStopbitsCombo, option) != -1) {
+ SWTControlUtil.setText(hostTTYStopbitsCombo, option);
+ }
+
+ option = settings.get(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYFlowControlSlotId, idPrefix));
+ if (option != null && option.trim().length() > 0 && SWTControlUtil.indexOf(hostTTYFlowControlCombo, option) != -1) {
+ SWTControlUtil.setText(hostTTYFlowControlCombo, option);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
+ */
+ @Override
+ public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
+ Assert.isNotNull(settings);
+
+ settings.put(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYDeviceSlotId, idPrefix), SWTControlUtil.getText(hostTTYDeviceCombo));
+ settings.put(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYSpeedRateSlotId, idPrefix), SWTControlUtil.getText(hostTTYSpeedCombo));
+
+ if (showAdvancedSerialOptions) {
+ settings.put(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYDatabitsSlotId, idPrefix), SWTControlUtil.getText(hostTTYBitsCombo));
+ settings.put(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYParitySlotId, idPrefix), SWTControlUtil.getText(hostTTYParityCombo));
+ settings.put(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYStopbitsSlotId, idPrefix), SWTControlUtil.getText(hostTTYStopbitsCombo));
+ settings.put(getParentControl().prefixDialogSettingsSlotId(fcSelectedTTYFlowControlSlotId, idPrefix), SWTControlUtil.getText(hostTTYFlowControlCombo));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#setupData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void setupData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ Map<String, Object> container = (Map<String, Object>)data.getProperty(IWireTypeSerial.PROPERTY_CONTAINER_NAME);
+ if (container == null) container = new HashMap<String, Object>();
+
+ SWTControlUtil.setText(hostTTYDeviceCombo, (String)container.get(IWireTypeSerial.PROPERTY_SERIAL_DEVICE));
+ SWTControlUtil.setText(hostTTYSpeedCombo, (String)container.get(IWireTypeSerial.PROPERTY_SERIAL_BAUD_RATE));
+
+ if (showAdvancedSerialOptions) {
+ SWTControlUtil.setText(hostTTYBitsCombo, (String)container.get(IWireTypeSerial.PROPERTY_SERIAL_DATA_BITS));
+ SWTControlUtil.setText(hostTTYParityCombo, (String)container.get(IWireTypeSerial.PROPERTY_SERIAL_PARITY));
+ SWTControlUtil.setText(hostTTYStopbitsCombo, (String)container.get(IWireTypeSerial.PROPERTY_SERIAL_STOP_BITS));
+ SWTControlUtil.setText(hostTTYFlowControlCombo, (String)container.get(IWireTypeSerial.PROPERTY_SERIAL_FLOW_CONTROL));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#extractData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void extractData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ Map<String, Object> container = (Map<String, Object>)data.getProperty(IWireTypeSerial.PROPERTY_CONTAINER_NAME);
+ if (container == null) container = new HashMap<String, Object>();
+
+ container.put(IWireTypeSerial.PROPERTY_SERIAL_DEVICE, SWTControlUtil.getText(hostTTYDeviceCombo));
+ container.put(IWireTypeSerial.PROPERTY_SERIAL_BAUD_RATE, SWTControlUtil.getText(hostTTYSpeedCombo));
+
+ container.put(IWireTypeSerial.PROPERTY_SERIAL_DATA_BITS, showAdvancedSerialOptions ? SWTControlUtil.getText(hostTTYBitsCombo) : null);
+ container.put(IWireTypeSerial.PROPERTY_SERIAL_PARITY, showAdvancedSerialOptions ? SWTControlUtil.getText(hostTTYParityCombo) : null);
+ container.put(IWireTypeSerial.PROPERTY_SERIAL_STOP_BITS, showAdvancedSerialOptions ? SWTControlUtil.getText(hostTTYStopbitsCombo) : null);
+ container.put(IWireTypeSerial.PROPERTY_SERIAL_FLOW_CONTROL, showAdvancedSerialOptions ? SWTControlUtil.getText(hostTTYFlowControlCombo) : null);
+
+ data.setProperty(IWireTypeSerial.PROPERTY_CONTAINER_NAME, !container.isEmpty() ? container : null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#initializeData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void initializeData(IPropertiesContainer data) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#removeData(org.eclipse.tcf.te.runtime.interfaces.nodes.IPropertiesContainer)
+ */
+ @Override
+ public void removeData(IPropertiesContainer data) {
+ if (data == null) return;
+ data.setProperty(IWireTypeSerial.PROPERTY_CONTAINER_NAME, null);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialPortAddressDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialPortAddressDialog.java
new file mode 100644
index 000000000..29ab2c5ca
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/wire/serial/SerialPortAddressDialog.java
@@ -0,0 +1,357 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.controls.wire.serial;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.controls.interfaces.help.IContextHelpIds;
+import org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl;
+import org.eclipse.tcf.te.ui.controls.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.validator.NameOrIPValidator;
+import org.eclipse.tcf.te.ui.controls.validator.NumberValidator;
+import org.eclipse.tcf.te.ui.controls.validator.PortNumberValidator;
+import org.eclipse.tcf.te.ui.controls.validator.PortNumberVerifyListener;
+import org.eclipse.tcf.te.ui.controls.validator.RegexValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
+
+/**
+ * Serial line port or address dialog.
+ */
+public class SerialPortAddressDialog extends CustomTitleAreaDialog {
+
+ BaseEditBrowseTextControl ttyControl;
+ RemoteHostAddressControl addressControl;
+ BaseEditBrowseTextControl portControl;
+
+ Validator ttyValidator;
+ Validator portValidator;
+
+ List<String> ttyHistory;
+ List<String> tcpHistory;
+
+ String data = null;
+
+ /**
+ * Constructor.
+ * @param parentShell
+ */
+ public SerialPortAddressDialog(Shell parentShell, String selected, List<String> ttyHistory, List<String> tcpHistory) {
+ super(parentShell, IContextHelpIds.SERIAL_PORT_ADDRESS_DIALOG);
+ this.ttyHistory = ttyHistory;
+ this.tcpHistory = tcpHistory;
+ this.data = selected;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#isResizable()
+ */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.dialogs.CustomTitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ setDialogTitle(Messages.SerialLinePanel_customSerialDevice_title);
+
+ //set margins of dialog and apply dialog font
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ Composite ttyComp = new Composite(container, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ ttyComp.setLayout(gl);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 250;
+ ttyComp.setLayoutData(gd);
+
+ ttyControl = new BaseEditBrowseTextControl(null);
+ ttyControl.setLabelIsButton(true);
+ parent.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ boolean enable = ttyHistory != null && ttyHistory.contains(data);
+ setTTYControlEnabled(enable);
+ setTCPControlEnabled(!enable);
+ onModify();
+ }
+ });
+ ttyControl.setIsGroup(false);
+ ttyControl.setEditFieldLabel(Messages.SerialLinePanel_hostTTYDevice_label);
+ ttyControl.setHideBrowseButton(true);
+ ttyControl.setupPanel(ttyComp);
+ ((Button)ttyControl.getLabelControl()).addSelectionListener(new SelectionListener(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean selected = ((Button)ttyControl.getLabelControl()).getSelection();
+ setTTYControlEnabled(selected);
+ setTCPControlEnabled(!selected);
+ onModify();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ ((Combo)ttyControl.getEditFieldControl()).addModifyListener(new ModifyListener(){
+ @Override
+ public void modifyText(ModifyEvent e) {
+ onModify();
+ }
+ });
+
+ Composite tcpComp = new Composite(container, SWT.NONE);
+ gl = new GridLayout(4, true);
+ tcpComp.setLayout(gl);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ tcpComp.setLayoutData(gd);
+
+ Composite tcpAddrComp = new Composite(tcpComp, SWT.NONE);
+ gl = new GridLayout();
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
+ tcpAddrComp.setLayout(gl);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ tcpAddrComp.setLayoutData(gd);
+
+ addressControl = new RemoteHostAddressControl(null) {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ super.modifyText(e);
+ onModify();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean selected = ((Button)addressControl.getLabelControl()).getSelection();
+ setTTYControlEnabled(!selected);
+ setTCPControlEnabled(selected);
+ onModify();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl#setCheckResultMessage(int, java.lang.String)
+ */
+ @Override
+ protected void setCheckResultMessage(int severity, String message) {
+ SerialPortAddressDialog.this.setMessage(message, severity);
+ }
+ };
+ addressControl.setLabelIsButton(true);
+ addressControl.setIsGroup(false);
+ addressControl.setEditFieldLabel(org.eclipse.tcf.te.ui.controls.nls.Messages.RemoteHostAddressControl_label);
+ addressControl.setButtonLabel(org.eclipse.tcf.te.ui.controls.nls.Messages.RemoteHostAddressControl_button_label);
+ addressControl.setupPanel(tcpAddrComp);
+
+ Composite tcpPortComp = new Composite(tcpComp, SWT.NONE);
+ gl = new GridLayout();
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
+ tcpPortComp.setLayout(gl);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ tcpPortComp.setLayoutData(gd);
+
+ portControl = new BaseEditBrowseTextControl(null);
+ portControl.setIsGroup(false);
+ portControl.setEditFieldLabel(Messages.SerialPortAddressDialog_port);
+ portControl.setHideBrowseButton(true);
+ portControl.setupPanel(tcpPortComp);
+ ((Combo)portControl.getEditFieldControl()).addVerifyListener(new PortNumberVerifyListener(PortNumberVerifyListener.ATTR_DECIMAL | PortNumberVerifyListener.ATTR_HEX));
+ ((Combo)portControl.getEditFieldControl()).addModifyListener(new ModifyListener(){
+ @Override
+ public void modifyText(ModifyEvent e) {
+ onModify();
+ }
+ });
+
+ // Trigger the runnable after having created all controls!
+ parent.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ boolean enable = tcpHistory != null && tcpHistory.contains(data);
+ setTTYControlEnabled(!enable);
+ setTCPControlEnabled(enable);
+ onModify();
+ }
+ });
+
+ ttyValidator = new Validator(Validator.ATTR_MANDATORY) {
+ private final Pattern fValidCharacters = System.getProperty("os.name","").toLowerCase().startsWith("windows") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ? Pattern.compile("[\\w]+") : Pattern.compile("[\\w/]+"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ @Override
+ public boolean isValid(String newText) {
+ setMessage(null);
+ setMessageType(INFORMATION);
+ if (newText != null && newText.trim().length() > 0) {
+ Matcher matcher = fValidCharacters.matcher(newText);
+ if (!matcher.matches()) {
+ setMessage(Messages.SerialLinePanel_error_invalidCharactes, ERROR);
+ }
+ }
+ else if (newText != null) {
+ setMessage(Messages.SerialLinePanel_error_emptyHostTTYDevice, INFORMATION);
+ }
+ return getMessageType() != ERROR;
+ }
+ };
+ ttyControl.setEditFieldValidator(ttyValidator);
+
+ portValidator = new PortNumberValidator(Validator.ATTR_MANDATORY | PortNumberValidator.ATTR_DECIMAL | PortNumberValidator.ATTR_HEX);
+ portValidator.setMessageText(RegexValidator.INFO_MISSING_VALUE,
+ Messages.SerialPortAddressDialog_Information_MissingPort);
+ portValidator.setMessageText(RegexValidator.ERROR_INVALID_VALUE,
+ Messages.SerialPortAddressDialog_Error_InvalidPort);
+ portValidator.setMessageText(NumberValidator.ERROR_INVALID_RANGE,
+ Messages.SerialPortAddressDialog_Error_InvalidPortRange);
+ portControl.setEditFieldValidator(portValidator);
+
+ applyDialogFont(container);
+
+ setupData();
+
+ return container;
+ }
+
+ private void setupData() {
+ setTTYControlEnabled(true);
+ setTCPControlEnabled(false);
+ if (ttyHistory != null && !ttyHistory.isEmpty()) {
+ for (String tty : ttyHistory) {
+ ttyControl.addToEditFieldControlHistory(tty.trim());
+ if (tty.equals(data)) {
+ ttyControl.setEditFieldControlText(tty.trim());
+ }
+ }
+ }
+ if (tcpHistory != null && !tcpHistory.isEmpty()) {
+ for (String tcp : tcpHistory) {
+ String[] data = tcp.split(":"); //$NON-NLS-1$
+ if (data.length > 1) {
+ addressControl.addToEditFieldControlHistory(data[1]);
+ }
+ if (data.length > 2) {
+ portControl.addToEditFieldControlHistory(data[2]);
+ }
+ if (tcp.equals(this.data)) {
+ setTTYControlEnabled(false);
+ setTCPControlEnabled(true);
+ if (data.length > 1) {
+ addressControl.setEditFieldControlText(data[1]);
+ }
+ if (data.length > 2) {
+ portControl.setEditFieldControlText(data[2]);
+ }
+ }
+ }
+ }
+ onModify();
+ }
+
+ void setTTYControlEnabled(boolean enable) {
+ ttyControl.setLabelControlSelection(enable);
+ ttyControl.getEditFieldControl().setEnabled(enable);
+ }
+
+ void setTCPControlEnabled(boolean enable) {
+ addressControl.setLabelControlSelection(enable);
+ addressControl.getEditFieldControl().setEnabled(enable);
+ addressControl.getButtonControl().setEnabled(enable);
+ portControl.setEnabled(enable);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control control = super.createButtonBar(parent);
+ setButtonEnabled(OK, false);
+ return control;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.dialogs.CustomTitleAreaDialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ if (((Button)ttyControl.getLabelControl()).getSelection()) {
+ data = ttyControl.getEditFieldControlText();
+ }
+ else {
+ data = "tcp:" + addressControl.getEditFieldControlText() + ":" + portControl.getEditFieldControlText(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ super.okPressed();
+ }
+
+ void onModify() {
+ setMessage(null);
+
+ boolean ttySelected = ((Button)ttyControl.getLabelControl()).getSelection();
+
+ boolean isTTYValid = ttyControl.isValid();
+ if (ttySelected && ttyControl.getMessageType() > getMessageType()) {
+ setMessage(ttyControl.getMessage(), ttyControl.getMessageType());
+ }
+
+ boolean isTCPValid = addressControl.isValid();
+ if (!ttySelected && addressControl.getMessageType() > getMessageType()) {
+ setMessage(addressControl.getMessage(), addressControl.getMessageType());
+ }
+
+ isTCPValid &= portControl.isValid();
+ if (!ttySelected && portControl.getMessageType() > getMessageType()) {
+ setMessage(portControl.getMessage(), portControl.getMessageType());
+ }
+
+ if (getMessage() == null) {
+ setDefaultMessage(Messages.SerialLinePanel_customSerialDevice_message, IMessageProvider.INFORMATION);
+ }
+
+ addressControl.getButtonControl().setEnabled(!ttySelected && addressControl.isValid() &&
+ (addressControl.getEditFieldValidator() instanceof NameOrIPValidator) &&
+ ((NameOrIPValidator)addressControl.getEditFieldValidator()).isName());
+ setButtonEnabled(OK, ttySelected ? isTTYValid : isTCPValid);
+ }
+
+ /**
+ * Return the new name after OK was pressed.
+ * Unless OK was pressed, the old name is returned.
+ */
+ public String getData() {
+ return data;
+ }
+}

Back to the top