Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-03-01 07:03:46 +0000
committerTobias Schwarz2013-03-01 07:03:46 +0000
commitead8cb523c1a6fd41628277b82dc7cad9ca76df2 (patch)
tree43ed6ed9fa8b5ec84b6d0c8323d957410c9765ed
parentd02e6a61f5bb4f10c16ea55a784858499bd51e48 (diff)
downloadorg.eclipse.tcf-ead8cb523c1a6fd41628277b82dc7cad9ca76df2.tar.gz
org.eclipse.tcf-ead8cb523c1a6fd41628277b82dc7cad9ca76df2.tar.xz
org.eclipse.tcf-ead8cb523c1a6fd41628277b82dc7cad9ca76df2.zip
Target Explorer: fix transport type selection
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java288
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java46
2 files changed, 189 insertions, 145 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java
index 3f9c9dde8..fee94cedc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java
@@ -1,144 +1,144 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.tcf.ui.controls;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-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.tcf.core.interfaces.ITransportTypes;
-import org.eclipse.tcf.te.tcf.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
-
-/**
- * Transport type control implementation.
- */
-public class TransportTypeControl extends BaseEditBrowseTextControl {
-
- private final static List<String> TRANSPORT_TYPES = Arrays.asList(new String[] {
- ITransportTypes.TRANSPORT_TYPE_TCP,
- ITransportTypes.TRANSPORT_TYPE_SSL,
- ITransportTypes.TRANSPORT_TYPE_PIPE,
- ITransportTypes.TRANSPORT_TYPE_CUSTOM
- });
-
- /**
- * 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 TransportTypeControl(IDialogPage parentPage) {
- super(parentPage);
- setIsGroup(false);
- setReadOnly(true);
- setHideBrowseButton(true);
- setEditFieldLabel(Messages.TransportTypeControl_label);
- }
-
- /**
- * Returns the list of transport types supported by this control.
- *
- * @return The list of supported transport types.
- */
- public String[] getTransportTypes() {
- return TRANSPORT_TYPES.toArray(new String[TRANSPORT_TYPES.size()]);
- }
-
- /* (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> transportTypeLabels = new ArrayList<String>();
- for (String transportType : TRANSPORT_TYPES) {
- String label = getTransportTypeLabel(transportType);
- if (label != null) transportTypeLabels.add(label);
- }
-
- setEditFieldControlHistory(transportTypeLabels.toArray(new String[transportTypeLabels.size()]));
- SWTControlUtil.select(getEditFieldControl(), 0);
- SWTControlUtil.setEnabled(getEditFieldControl(), transportTypeLabels.size() > 1);
- }
-
- /**
- * Returns the label of the given transport type.
- *
- * @param transportType The transport type. Must not be <code>null</code>.
- * @return The corresponding label or <code>null</code> if the transport type is unknown.
- */
- protected String getTransportTypeLabel(String transportType) {
- Assert.isNotNull(transportType);
-
- if (ITransportTypes.TRANSPORT_TYPE_TCP.equals(transportType)) return Messages.TransportTypeControl_tcpType_label;
- else if (ITransportTypes.TRANSPORT_TYPE_SSL.equals(transportType)) return Messages.TransportTypeControl_sslType_label;
- else if (ITransportTypes.TRANSPORT_TYPE_PIPE.equals(transportType)) return Messages.TransportTypeControl_pipeType_label;
- else if (ITransportTypes.TRANSPORT_TYPE_CUSTOM.equals(transportType)) return Messages.TransportTypeControl_customType_label;
-
- return null;
- }
-
- /**
- * Returns the currently selected transport type.
- *
- * @return The currently selected transport type.
- */
- public String getSelectedTransportType() {
- String type = getEditFieldControlText();
-
- if (Messages.TransportTypeControl_tcpType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_TCP;
- else if (Messages.TransportTypeControl_sslType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_SSL;
- else if (Messages.TransportTypeControl_pipeType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_PIPE;
- else if (Messages.TransportTypeControl_customType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_CUSTOM;
-
- return type;
- }
-
- /**
- * Sets the selected transport type to the specified one.
- *
- * @param transportType The transport type. Must not be <code>null</code>.
- */
- public void setSelectedTransportType(String transportType) {
- Assert.isNotNull(transportType);
-
- // Get the transport type label for given transport type
- String label = getTransportTypeLabel(transportType);
- 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 transport 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 transport types. Neither save
- // or restore the history actively.
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.tcf.ui.controls;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+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.tcf.core.interfaces.ITransportTypes;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+
+/**
+ * Transport type control implementation.
+ */
+public class TransportTypeControl extends BaseEditBrowseTextControl {
+
+ private final static List<String> TRANSPORT_TYPES = Arrays.asList(new String[] {
+ ITransportTypes.TRANSPORT_TYPE_TCP,
+ ITransportTypes.TRANSPORT_TYPE_SSL,
+ ITransportTypes.TRANSPORT_TYPE_PIPE,
+ ITransportTypes.TRANSPORT_TYPE_CUSTOM
+ });
+
+ /**
+ * 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 TransportTypeControl(IDialogPage parentPage) {
+ super(parentPage);
+ setIsGroup(false);
+ setReadOnly(true);
+ setHideBrowseButton(true);
+ setEditFieldLabel(Messages.TransportTypeControl_label);
+ }
+
+ /**
+ * Returns the list of transport types supported by this control.
+ *
+ * @return The list of supported transport types.
+ */
+ public String[] getTransportTypes() {
+ return TRANSPORT_TYPES.toArray(new String[TRANSPORT_TYPES.size()]);
+ }
+
+ /* (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> transportTypeLabels = new ArrayList<String>();
+ for (String transportType : getTransportTypes()) {
+ String label = getTransportTypeLabel(transportType);
+ if (label != null) transportTypeLabels.add(label);
+ }
+
+ setEditFieldControlHistory(transportTypeLabels.toArray(new String[transportTypeLabels.size()]));
+ SWTControlUtil.select(getEditFieldControl(), 0);
+ SWTControlUtil.setEnabled(getEditFieldControl(), transportTypeLabels.size() > 1);
+ }
+
+ /**
+ * Returns the label of the given transport type.
+ *
+ * @param transportType The transport type. Must not be <code>null</code>.
+ * @return The corresponding label or <code>null</code> if the transport type is unknown.
+ */
+ protected String getTransportTypeLabel(String transportType) {
+ Assert.isNotNull(transportType);
+
+ if (ITransportTypes.TRANSPORT_TYPE_TCP.equals(transportType)) return Messages.TransportTypeControl_tcpType_label;
+ else if (ITransportTypes.TRANSPORT_TYPE_SSL.equals(transportType)) return Messages.TransportTypeControl_sslType_label;
+ else if (ITransportTypes.TRANSPORT_TYPE_PIPE.equals(transportType)) return Messages.TransportTypeControl_pipeType_label;
+ else if (ITransportTypes.TRANSPORT_TYPE_CUSTOM.equals(transportType)) return Messages.TransportTypeControl_customType_label;
+
+ return null;
+ }
+
+ /**
+ * Returns the currently selected transport type.
+ *
+ * @return The currently selected transport type.
+ */
+ public String getSelectedTransportType() {
+ String type = getEditFieldControlText();
+
+ if (Messages.TransportTypeControl_tcpType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_TCP;
+ else if (Messages.TransportTypeControl_sslType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_SSL;
+ else if (Messages.TransportTypeControl_pipeType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_PIPE;
+ else if (Messages.TransportTypeControl_customType_label.equals(type)) type = ITransportTypes.TRANSPORT_TYPE_CUSTOM;
+
+ return type;
+ }
+
+ /**
+ * Sets the selected transport type to the specified one.
+ *
+ * @param transportType The transport type. Must not be <code>null</code>.
+ */
+ public void setSelectedTransportType(String transportType) {
+ Assert.isNotNull(transportType);
+
+ // Get the transport type label for given transport type
+ String label = getTransportTypeLabel(transportType);
+ 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 transport 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 transport types. Neither save
+ // or restore the history actively.
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
index 0638b6135..84ce33755 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
@@ -18,6 +18,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
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;
@@ -134,7 +135,18 @@ public class TransportSection extends AbstractSection {
section.setClient(client);
// Create the transport type control
- transportTypeControl = new TransportSectionTypeControl(this);
+ transportTypeControl = new TransportSectionTypeControl(this) {
+ @Override
+ public String[] getTransportTypes() {
+ List<String> types = new ArrayList<String>();
+ for (String type : super.getTransportTypes()) {
+ if (isTransportTypeSupported(type)) {
+ types.add(type);
+ }
+ }
+ return types.toArray(new String[types.size()]);
+ }
+ };
transportTypeControl.setFormToolkit(toolkit);
transportTypeControl.setAdjustBackgroundColor(true);
transportTypeControl.setupPanel(client);
@@ -151,6 +163,10 @@ public class TransportSection extends AbstractSection {
protected boolean isAdjustBackgroundColor() {
return true;
}
+ @Override
+ protected boolean hasHistory() {
+ return true;
+ }
};
transportTypePanelControl.addConfigurationPanel(ITransportTypes.TRANSPORT_TYPE_TCP, tcpTransportPanel);
}
@@ -602,4 +618,32 @@ public class TransportSection extends AbstractSection {
}
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#saveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void saveWidgetValues(IDialogSettings settings) {
+ super.saveWidgetValues(settings);
+
+ if (settings != null) {
+ if (transportTypePanelControl != null) {
+ transportTypePanelControl.saveWidgetValues(settings, TransportSection.class.getSimpleName());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#restoreWidgetValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void restoreWidgetValues(IDialogSettings settings) {
+ super.restoreWidgetValues(settings);
+
+ if (settings != null) {
+ if (transportTypePanelControl != null) {
+ transportTypePanelControl.restoreWidgetValues(settings, TransportSection.class.getSimpleName());
+ }
+ }
+ }
}

Back to the top