Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java110
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/CustomTransportPanel.java239
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerAttributesTablePart.java381
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerIdControl.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerNameControl.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PipeTransportPanel.java238
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TcpTransportPanel.java311
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypeControl.java135
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypePanelControl.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java424
10 files changed, 1943 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java
new file mode 100644
index 000000000..f07ad9f0c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.tcf.ui.model.Model;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.ui.wizards.pages.NewTargetWizardPage;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceService;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
+import org.eclipse.tcf.te.ui.views.ViewsUtil;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.wizards.AbstractWizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * New TCF target wizard implementation.
+ */
+public class NewTargetWizard extends AbstractWizard implements INewWizard {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // Set the window title
+ setWindowTitle(Messages.NewTargetWizard_windowTitle);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ // Create and add the wizard pages
+ addPage(new NewTargetWizardPage());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ IWizardPage page = getPage(NewTargetWizardPage.class.getName());
+ if (page instanceof NewTargetWizardPage) {
+ // Trigger the saving of the widget history
+ ((NewTargetWizardPage)page).saveWidgetValues();
+ // Get the peer attributes map from the page
+ final Map<String, String> peerAttributes = ((NewTargetWizardPage)page).getPeerAttributes();
+ if (peerAttributes != null) {
+ try {
+ // Save the new peer
+ IPersistenceService persistenceService = ServiceManager.getInstance().getService(IPersistenceService.class);
+ if (persistenceService == null) throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ persistenceService.write(peerAttributes);
+
+ // Get the locator model
+ final ILocatorModel model = Model.getModel();
+ if (model != null) {
+ // Trigger a refresh of the model to read in the newly created static peer
+ final ILocatorModelRefreshService service = model.getService(ILocatorModelRefreshService.class);
+ if (service != null) {
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ // Refresh the model now (must be executed within the TCF dispatch thread)
+ service.refresh();
+
+ // Get the peer model node from the model and select it in the tree
+ final IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peerAttributes.get(IPeer.ATTR_ID));
+ if (peerNode != null) {
+ ViewsUtil.setSelection(IUIConstants.ID_EXPLORER, new StructuredSelection(peerNode));
+ }
+ }
+ });
+ }
+ }
+ } catch (IOException e) {
+ ((NewTargetWizardPage)page).setMessage(NLS.bind(Messages.NewTargetWizard_error_savePeer, e.getLocalizedMessage()), IMessageProvider.ERROR);
+ getContainer().updateMessage();
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/CustomTransportPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/CustomTransportPanel.java
new file mode 100644
index 000000000..d6d351073
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/CustomTransportPanel.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.protocol.IPeer;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.controls.validator.RegexValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.tcf.te.ui.wizards.interfaces.IValidatableWizardPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * Custom transport type panel implementation.
+ */
+public class CustomTransportPanel extends AbstractWizardConfigurationPanel implements ISharedDataWizardPage {
+
+ private CustomTransportNameControl customTransportNameControl;
+
+ /**
+ * Local custom transport name control implementation.
+ */
+ protected class CustomTransportNameControl 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 CustomTransportNameControl(IDialogPage parentPage) {
+ super(parentPage);
+ setIsGroup(false);
+ setHasHistory(false);
+ setHideBrowseButton(true);
+ setEditFieldLabel(Messages.CustomTransportNameControl_label);
+ }
+
+ /* (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.CustomTransportNameControl_information_missingValue);
+ validator.setMessageText(RegexValidator.ERROR_INVALID_VALUE, Messages.CustomTransportNameControl_error_invalidValue);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatableWizardPage()
+ */
+ @Override
+ public IValidatableWizardPage getValidatableWizardPage() {
+ return CustomTransportPanel.this.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 (CustomTransportPanel.this.getParentControl() instanceof ModifyListener) {
+ ((ModifyListener)CustomTransportPanel.this.getParentControl()).modifyText(e);
+ }
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentPageControl The parent control. Must not be <code>null</code>!
+ */
+ public CustomTransportPanel(BaseDialogPageControl parentControl) {
+ super(parentControl);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (customTransportNameControl != null) { customTransportNameControl.dispose(); customTransportNameControl = 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);
+
+ customTransportNameControl = doCreateCustomTransportNameControl(getParentControl().getParentPage());
+ customTransportNameControl.setupPanel(panel);
+ }
+
+ /**
+ * Creates the pipe name control instance.
+ *
+ * @param parentPage The parent dialog page or <code>null</code>.
+ * @return The pipe name control instance.
+ */
+ protected CustomTransportNameControl doCreateCustomTransportNameControl(IDialogPage parentPage) {
+ return new CustomTransportNameControl(parentPage);
+ }
+
+ /* (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 = customTransportNameControl.isValid();
+ setMessage(customTransportNameControl.getMessage(), customTransportNameControl.getMessageType());
+
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#dataChanged(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.swt.events.TypedEvent)
+ */
+ @Override
+ public boolean dataChanged(IPropertiesContainer data, TypedEvent e) {
+ Assert.isNotNull(data);
+
+ boolean isDirty = false;
+
+ if (customTransportNameControl != null) {
+ String CustomTransportName = customTransportNameControl.getEditFieldControlText();
+ if (CustomTransportName != null) isDirty |= !CustomTransportName.equals(data.getStringProperty(IPeer.ATTR_TRANSPORT_NAME));
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#setupData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void setupData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ if (customTransportNameControl != null) {
+ customTransportNameControl.setEditFieldControlText(data.getStringProperty(IPeer.ATTR_TRANSPORT_NAME));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void extractData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ if (customTransportNameControl != null) {
+ data.setProperty(IPeer.ATTR_TRANSPORT_NAME, customTransportNameControl.getEditFieldControlText());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#initializeData(org.eclipse.tcf.te.runtime.interfaces.properties.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.properties.IPropertiesContainer)
+ */
+ @Override
+ public void removeData(IPropertiesContainer data) {
+ if (data == null) return;
+ data.setProperty(IPeer.ATTR_TRANSPORT_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 (customTransportNameControl != null) customTransportNameControl.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 (customTransportNameControl != null) customTransportNameControl.doRestoreWidgetValues(settings, idPrefix);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerAttributesTablePart.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerAttributesTablePart.java
new file mode 100644
index 000000000..57d48c952
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerAttributesTablePart.java
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.dialogs.NameValuePairDialog;
+import org.eclipse.tcf.te.ui.forms.parts.TablePart;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.services.IDisposable;
+
+/**
+ * Peer attributes table part implementation.
+ */
+public class PeerAttributesTablePart extends TablePart implements IDisposable {
+ // The list of table nodes
+ /* default */ final List<TableNode> nodes = new ArrayList<TableNode>();
+
+ // A list of names which are banned from using
+ private String[] bannedNames;
+
+ /**
+ * Peer attributes table table node implementation.
+ */
+ protected static class TableNode extends PlatformObject {
+ /**
+ * The node name.
+ */
+ public String name = ""; //$NON-NLS-1$
+
+ /**
+ * The node value.
+ */
+ public String value = ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Peer attributes table label provider implementation.
+ */
+ protected static class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ String text = null;
+ if (element instanceof TableNode) {
+ switch (columnIndex) {
+ case 0:
+ text = ((TableNode)element).name;
+ break;
+ case 1:
+ text = ((TableNode)element).value;
+ break;
+ }
+ }
+ return text != null ? text : ""; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ public PeerAttributesTablePart() {
+ super(new String[] {
+ Messages.PeerAttributesTablePart_button_new,
+ Messages.PeerAttributesTablePart_button_edit,
+ Messages.PeerAttributesTablePart_button_remove
+ });
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.services.IDisposable#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.TablePart#configureTableViewer(org.eclipse.jface.viewers.TableViewer)
+ */
+ @Override
+ protected void configureTableViewer(final TableViewer viewer) {
+ super.configureTableViewer(viewer);
+
+ if (viewer != null && viewer.getTable() != null && !viewer.getTable().isDisposed()) {
+ Table table = viewer.getTable();
+
+ // Create the table columns
+ new TableColumn(table, SWT.NONE).setText(Messages.PeerAttributesTablePart_column_name);
+ new TableColumn(table, SWT.NONE).setText(Messages.PeerAttributesTablePart_column_value);
+
+ // Create and configure the table layout
+ TableLayout tableLayout = new TableLayout();
+ tableLayout.addColumnData(new ColumnWeightData(40, true));
+ tableLayout.addColumnData(new ColumnWeightData(60, true));
+ table.setLayout(tableLayout);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ // Setup the cell editors
+ viewer.setColumnProperties(new String[] { Messages.PeerAttributesTablePart_column_name, Messages.PeerAttributesTablePart_column_value });
+
+ CellEditor[] cellEditors = new CellEditor[viewer.getColumnProperties().length];
+ cellEditors[0] = new TextCellEditor(table);
+ ((Text)cellEditors[0].getControl()).setTextLimit(250);
+ cellEditors[1] = new TextCellEditor(table);
+ ((Text)cellEditors[1].getControl()).setTextLimit(250);
+
+ viewer.setCellEditors(cellEditors);
+ viewer.setCellModifier(new ICellModifier() {
+ @Override
+ public boolean canModify(Object element, String property) {
+ return element instanceof TableNode;
+ }
+ @Override
+ public Object getValue(Object element, String property) {
+ String value = null;
+ if (element instanceof TableNode) {
+ if (Messages.PeerAttributesTablePart_column_name.equals(property)) {
+ value = ((TableNode)element).name;
+ }
+ else if (Messages.PeerAttributesTablePart_column_value.equals(property)) {
+ value = ((TableNode)element).value;
+ }
+ }
+ return value;
+ }
+ @Override
+ public void modify(Object element, String property, Object value) {
+ if (element instanceof TableItem) element = ((TableItem)element).getData();
+ if (element instanceof TableNode) {
+ if (Messages.PeerAttributesTablePart_column_name.equals(property)) {
+ ((TableNode)element).name = value != null ? value.toString() : ""; //$NON-NLS-1$
+ }
+ else if (Messages.PeerAttributesTablePart_column_value.equals(property)) {
+ ((TableNode)element).value = value != null ? value.toString() : ""; //$NON-NLS-1$
+ }
+ viewer.setInput(nodes);
+ }
+ }
+ });
+
+ // Create and set content and label provider
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setLabelProvider(new TableLabelProvider());
+
+ // Attach listeners
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateButtons();
+ }
+ });
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractPartWithButtons#createControl(org.eclipse.swt.widgets.Composite, int, int, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ public void createControl(Composite parent, int style, int span, FormToolkit toolkit) {
+ super.createControl(parent, style, span, toolkit);
+ nodes.clear();
+ getTableViewer().setInput(nodes);
+ updateButtons();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractPartWithButtons#onButtonSelected(org.eclipse.swt.widgets.Button)
+ */
+ @Override
+ protected void onButtonSelected(Button button) {
+ Assert.isNotNull(button);
+
+ if (Messages.PeerAttributesTablePart_button_new.equals(button.getText())) {
+ onNewPressed();
+ }
+ else if (Messages.PeerAttributesTablePart_button_edit.equals(button.getText())) {
+ onEditPressed();
+ }
+ else if (Messages.PeerAttributesTablePart_button_remove.equals(button.getText())) {
+ onRemovePressed();
+ }
+ }
+
+ /**
+ * Update the button enablements.
+ */
+ protected void updateButtons() {
+ int selectionCount = getTableViewer().getTable().getSelectionCount();
+
+ SWTControlUtil.setEnabled(getButton(Messages.PeerAttributesTablePart_button_edit), selectionCount == 1);
+ SWTControlUtil.setEnabled(getButton(Messages.PeerAttributesTablePart_button_remove), selectionCount == 1);
+ }
+
+ /**
+ * Called from {@link #onButtonSelected(Button)} if "New..." got pressed.
+ */
+ protected void onNewPressed() {
+ doEditTableNode(null);
+ }
+
+ /**
+ * Called from {@link #onButtonSelected(Button)} if "Edit..." got pressed.
+ */
+ protected void onEditPressed() {
+ // Get the selection from the table
+ ISelection selection = getTableViewer().getSelection();
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ doEditTableNode((TableNode)((IStructuredSelection)selection).getFirstElement());
+ }
+ }
+
+ /**
+ * Called from {@link #onButtonSelected(Button)} if "Remove..." got pressed.
+ */
+ protected void onRemovePressed() {
+ // Get the selection from the table
+ ISelection selection = getTableViewer().getSelection();
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ TableNode node = (TableNode)((IStructuredSelection)selection).getFirstElement();
+ int index = nodes.indexOf(node);
+ nodes.remove(node);
+ getTableViewer().setInput(nodes);
+ if (index < nodes.size()) getTableViewer().setSelection(new StructuredSelection(nodes.get(index)));
+ updateButtons();
+ }
+ }
+
+ /**
+ * Opens the name/pair dialog.
+ *
+ * @param node The node to edit or <code>null</code>.
+ */
+ protected void doEditTableNode(TableNode node) {
+ // If the node is null, the dialog will be opened as "Add" dialog
+ boolean addMode = node == null;
+
+ // Determine the initial values
+ String name = node != null ? node.name : ""; //$NON-NLS-1$
+ String value = node != null ? node.value : ""; //$NON-NLS-1$
+
+ // Determine the used names
+ Set<String> usedNames = new HashSet<String>(convertList2Map(nodes).keySet());
+
+ // Add banned names to the used names list
+ if (bannedNames != null) {
+ for (String bannedName : bannedNames) {
+ usedNames.add(bannedName);
+ }
+ }
+
+ // Remove the current name
+ usedNames.remove(name);
+
+ // Determine the dialog title, the title and the default message
+ String dialogTitle = addMode ? Messages.PeerAttributesTablePart_add_dialogTitle : Messages.PeerAttributesTablePart_edit_dialogTitle;
+ String title = addMode ? Messages.PeerAttributesTablePart_add_title : Messages.PeerAttributesTablePart_edit_title;
+ String message = addMode ? Messages.PeerAttributesTablePart_add_message : Messages.PeerAttributesTablePart_edit_message;
+
+ // Construct the name/value pair dialog
+ NameValuePairDialog dialog = new NameValuePairDialog(getViewer().getControl().getShell(),
+ dialogTitle, title, message,
+ new String[] { Messages.PeerAttributesTablePart_column_name, Messages.PeerAttributesTablePart_column_value },
+ new String[] { name, value },
+ usedNames
+ );
+
+ // Open the dialog
+ if (dialog.open() == Window.OK) {
+ // If the user pressed OK, copy the data to the given node
+ // or create a new node in add mode.
+ String[] pair = dialog.getNameValuePair();
+ if (addMode) {
+ node = new TableNode();
+ nodes.add(node);
+ }
+
+ Assert.isNotNull(node);
+ node.name = pair[0];
+ node.value = pair[1];
+
+ // Refresh the view
+ getTableViewer().setInput(nodes);
+ getTableViewer().setSelection(new StructuredSelection(node));
+ }
+ }
+
+ /**
+ * Convert the given list into a map.
+ *
+ * @param list The list of table node. Must not be <code>null</code>:
+ * @return The corresponding map.
+ */
+ private static Map<String, String> convertList2Map(List<TableNode> list) {
+ Assert.isNotNull(list);
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ for (TableNode node : list) {
+ map.put(node.name, node.value);
+ }
+ return map;
+ }
+
+ /**
+ * Returns the configured attributes.
+ *
+ * @return The configured attributes.
+ */
+ public Map<String, String> getAttributes() {
+ return convertList2Map(nodes);
+ }
+
+ /**
+ * Set a list of banned names.
+ *
+ * @param bannedNames The list of banned names or <code>null</code>.
+ */
+ public final void setBannedNames(String[] bannedNames) {
+ this.bannedNames = bannedNames;
+ }
+
+ /**
+ * Returns the list of banned names.
+ *
+ * @return The list of banned names or <code>null</code>.
+ */
+ public final String[] getBannedNames() {
+ return bannedNames;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerIdControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerIdControl.java
new file mode 100644
index 000000000..664d49a01
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerIdControl.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+
+/**
+ * Peer id control implementation.
+ */
+public class PeerIdControl 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 PeerIdControl(IDialogPage parentPage) {
+ super(parentPage);
+
+ setIsGroup(false);
+ setHasHistory(false);
+ setHideBrowseButton(true);
+ setReadOnly(true);
+ setEditFieldLabel(Messages.PeerIdControl_label);
+ setAdjustBackgroundColor(parentPage != null);
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerNameControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerNameControl.java
new file mode 100644
index 000000000..716d572cf
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PeerNameControl.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+
+/**
+ * Peer name control implementation.
+ */
+public class PeerNameControl 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 PeerNameControl(IDialogPage parentPage) {
+ super(parentPage);
+
+ setIsGroup(false);
+ setHasHistory(false);
+ setHideBrowseButton(true);
+ setEditFieldLabel(Messages.PeerNameControl_label);
+ setAdjustBackgroundColor(parentPage != null);
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PipeTransportPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PipeTransportPanel.java
new file mode 100644
index 000000000..cca36b37e
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/PipeTransportPanel.java
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.controls.validator.RegexValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.tcf.te.ui.wizards.interfaces.IValidatableWizardPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * Pipe transport type panel implementation.
+ */
+public class PipeTransportPanel extends AbstractWizardConfigurationPanel implements ISharedDataWizardPage {
+
+ private PipeNameControl pipeNameControl;
+
+ /**
+ * Local pipe name control implementation.
+ */
+ protected class PipeNameControl 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 PipeNameControl(IDialogPage parentPage) {
+ super(parentPage);
+ setIsGroup(false);
+ setHasHistory(false);
+ setHideBrowseButton(true);
+ setEditFieldLabel(Messages.PipeNameControl_label);
+ }
+
+ /* (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.PipeNameControl_information_missingValue);
+ validator.setMessageText(RegexValidator.ERROR_INVALID_VALUE, Messages.PipeNameControl_error_invalidValue);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatableWizardPage()
+ */
+ @Override
+ public IValidatableWizardPage getValidatableWizardPage() {
+ return PipeTransportPanel.this.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 (PipeTransportPanel.this.getParentControl() instanceof ModifyListener) {
+ ((ModifyListener)PipeTransportPanel.this.getParentControl()).modifyText(e);
+ }
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentPageControl The parent control. Must not be <code>null</code>!
+ */
+ public PipeTransportPanel(BaseDialogPageControl parentControl) {
+ super(parentControl);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (pipeNameControl != null) { pipeNameControl.dispose(); pipeNameControl = 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);
+
+ pipeNameControl = doCreatePipeNameControl(getParentControl().getParentPage());
+ pipeNameControl.setupPanel(panel);
+ }
+
+ /**
+ * Creates the pipe name control instance.
+ *
+ * @param parentPage The parent dialog page or <code>null</code>.
+ * @return The pipe name control instance.
+ */
+ protected PipeNameControl doCreatePipeNameControl(IDialogPage parentPage) {
+ return new PipeNameControl(parentPage);
+ }
+
+ /* (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 = pipeNameControl.isValid();
+ setMessage(pipeNameControl.getMessage(), pipeNameControl.getMessageType());
+
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#dataChanged(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.swt.events.TypedEvent)
+ */
+ @Override
+ public boolean dataChanged(IPropertiesContainer data, TypedEvent e) {
+ Assert.isNotNull(data);
+
+ boolean isDirty = false;
+
+ if (pipeNameControl != null) {
+ String pipeName = pipeNameControl.getEditFieldControlText();
+ if (pipeName != null) isDirty |= !pipeName.equals(data.getStringProperty("PipeName")); //$NON-NLS-1$
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#setupData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void setupData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ if (pipeNameControl != null) {
+ pipeNameControl.setEditFieldControlText(data.getStringProperty("PipeName")); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void extractData(IPropertiesContainer data) {
+ if (data == null) return;
+
+ if (pipeNameControl != null) {
+ data.setProperty("PipeName", pipeNameControl.getEditFieldControlText()); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#initializeData(org.eclipse.tcf.te.runtime.interfaces.properties.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.properties.IPropertiesContainer)
+ */
+ @Override
+ public void removeData(IPropertiesContainer data) {
+ if (data == null) return;
+ data.setProperty("PipeName", null); //$NON-NLS-1$
+ }
+
+ /* (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 (pipeNameControl != null) pipeNameControl.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 (pipeNameControl != null) pipeNameControl.doRestoreWidgetValues(settings, idPrefix);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TcpTransportPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TcpTransportPanel.java
new file mode 100644
index 000000000..98c0a89ba
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TcpTransportPanel.java
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.protocol.IPeer;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl;
+import org.eclipse.tcf.te.ui.controls.net.RemoteHostPortControl;
+import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.controls.validator.NameOrIPValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.tcf.te.ui.wizards.interfaces.IValidatableWizardPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * TCP transport type wizard configuration panel.
+ */
+public class TcpTransportPanel extends AbstractWizardConfigurationPanel implements ISharedDataWizardPage {
+
+ private RemoteHostAddressControl addressControl = null;
+ private RemoteHostPortControl portControl = null;
+
+ /**
+ * Local remote host address control implementation.
+ */
+ protected class MyRemoteHostAddressControl extends RemoteHostAddressControl {
+
+ /**
+ * Constructor.
+ *
+ * @param parentPage The parent dialog page this control is embedded in. Must not be <code>null</code>!
+ */
+ public MyRemoteHostAddressControl(IDialogPage parentPage) {
+ super(parentPage);
+ setEditFieldLabel(Messages.MyRemoteHostAddressControl_label);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl#configureEditFieldValidator(org.eclipse.tcf.te.ui.controls.validator.Validator)
+ */
+ @Override
+ protected void configureEditFieldValidator(Validator validator) {
+ if (validator instanceof NameOrIPValidator) {
+ validator.setMessageText(NameOrIPValidator.INFO_MISSING_NAME_OR_IP, Messages.MyRemoteHostAddressControl_information_missingTargetNameAddress);
+ validator.setMessageText(NameOrIPValidator.ERROR_INVALID_NAME_OR_IP, Messages.MyRemoteHostAddressControl_error_invalidTargetNameAddress);
+ validator.setMessageText(NameOrIPValidator.ERROR_INVALID_NAME, Messages.MyRemoteHostAddressControl_error_invalidTargetNameAddress);
+ validator.setMessageText(NameOrIPValidator.ERROR_INVALID_IP, Messages.MyRemoteHostAddressControl_error_invalidTargetIpAddress);
+ validator.setMessageText(NameOrIPValidator.INFO_CHECK_NAME, getUserInformationTextCheckNameAddress());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl#getUserInformationTextCheckNameAddress()
+ */
+ @Override
+ protected String getUserInformationTextCheckNameAddress() {
+ return Messages.MyRemoteHostAddressControl_information_checkNameAddressUserInformation;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatableWizardPage()
+ */
+ @Override
+ public IValidatableWizardPage getValidatableWizardPage() {
+ return TcpTransportPanel.this.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 (TcpTransportPanel.this.getParentControl() instanceof ModifyListener) {
+ ((ModifyListener)TcpTransportPanel.this.getParentControl()).modifyText(e);
+ }
+ }
+ }
+
+ /**
+ * Local remote host port control implementation.
+ */
+ protected class MyRemoteHostPortControl extends RemoteHostPortControl {
+
+ /**
+ * Constructor.
+ *
+ * @param parentPage The parent dialog page this control is embedded in. Must not be <code>null</code>!
+ */
+ public MyRemoteHostPortControl(IDialogPage parentPage) {
+ super(parentPage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatableWizardPage()
+ */
+ @Override
+ public IValidatableWizardPage getValidatableWizardPage() {
+ return TcpTransportPanel.this.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 (TcpTransportPanel.this.getParentControl() instanceof ModifyListener) {
+ ((ModifyListener)TcpTransportPanel.this.getParentControl()).modifyText(e);
+ }
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentPageControl The parent control. Must not be <code>null</code>!
+ */
+ public TcpTransportPanel(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);
+
+ addressControl = doCreateAddressControl(getParentControl().getParentPage());
+ addressControl.setupPanel(panel);
+
+ portControl = doCreatePortControl(getParentControl().getParentPage());
+ portControl.setParentControlIsInnerPanel(true);
+ portControl.setupPanel(addressControl.getInnerPanelComposite());
+ portControl.setEditFieldControlText("1534"); //$NON-NLS-1$
+ }
+
+ /**
+ * Creates the address control instance.
+ *
+ * @param parentPage The parent dialog page or <code>null</code>.
+ * @return The address control instance.
+ */
+ protected RemoteHostAddressControl doCreateAddressControl(IDialogPage parentPage) {
+ return new MyRemoteHostAddressControl(parentPage);
+ }
+
+ /**
+ * Creates the port control instance.
+ *
+ * @param parentPage The parent dialog page or <code>null</code>.
+ * @return The port control instance.
+ */
+ protected RemoteHostPortControl doCreatePortControl(IDialogPage parentPage) {
+ return new MyRemoteHostPortControl(parentPage);
+ }
+
+ /* (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;
+
+ if (addressControl != null) {
+ String address = addressControl.getEditFieldControlText();
+ if (address != null) isDirty |= !address.equals(data.getStringProperty(IPeer.ATTR_IP_HOST));
+ }
+
+ if (portControl != null) {
+ String port = portControl.getEditFieldControlText();
+ if (port != null) isDirty |= !port.equals(data.getStringProperty(IPeer.ATTR_IP_PORT));
+ }
+
+ 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;
+
+ if (addressControl != null) {
+ addressControl.setEditFieldControlText(data.getStringProperty(IPeer.ATTR_IP_HOST));
+ }
+
+ if (portControl != null) {
+ portControl.setEditFieldControlText(data.getStringProperty(IPeer.ATTR_IP_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;
+
+ if (addressControl != null) {
+ data.setProperty(IPeer.ATTR_IP_HOST, addressControl.getEditFieldControlText());
+ }
+
+ if (portControl != null) {
+ data.setProperty(IPeer.ATTR_IP_PORT, portControl.getEditFieldControlText());
+ }
+ }
+
+ /* (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(IPeer.ATTR_IP_HOST, null);
+ data.setProperty(IPeer.ATTR_IP_PORT, 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.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypeControl.java
new file mode 100644
index 000000000..fa7fe3422
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypeControl.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.controls;
+
+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.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.core.interfaces.ITransportTypes;
+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 {
+
+ public final static String[] TRANSPORT_TYPES = 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);
+ 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> 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.
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypePanelControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypePanelControl.java
new file mode 100644
index 000000000..67ade653b
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/controls/TransportTypePanelControl.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.tcf.ui.wizards.controls;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.tcf.te.ui.controls.BaseWizardConfigurationPanelControl;
+
+/**
+ * Transport type wizard panel control.
+ */
+public class TransportTypePanelControl 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 TransportTypePanelControl(IDialogPage parentPage) {
+ super(parentPage);
+ }
+
+} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java
new file mode 100644
index 000000000..4725f41ce
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * 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.tcf.ui.wizards.pages;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.tcf.ui.internal.help.IContextHelpIds;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.CustomTransportPanel;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.PeerAttributesTablePart;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.PeerIdControl;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.PeerNameControl;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.PipeTransportPanel;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.TcpTransportPanel;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.TransportTypeControl;
+import org.eclipse.tcf.te.tcf.ui.wizards.controls.TransportTypePanelControl;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.tcf.core.interfaces.ITransportTypes;
+import org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
+import org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatableWizardPage;
+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;
+
+/**
+ * Wizard page implementation querying all information needed
+ * to create the different TCF peer types.
+ */
+public class NewTargetWizardPage extends AbstractValidatableWizardPage {
+ private PeerIdControl peerIdControl;
+ private PeerNameControl peerNameControl;
+ TransportTypeControl transportTypeControl;
+ TransportTypePanelControl transportTypePanelControl;
+ private PeerAttributesTablePart tablePart;
+
+ private FormToolkit toolkit = null;
+
+ /**
+ * Local transport type control implementation.
+ */
+ private class MyTransportTypeControl extends TransportTypeControl {
+
+ /**
+ * 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 MyTransportTypeControl(IDialogPage parentPage) {
+ super(parentPage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (transportTypePanelControl != null) {
+ transportTypePanelControl.showConfigurationPanel(getSelectedTransportType());
+ validatePage();
+ }
+ }
+ }
+
+ /**
+ * Local transport type panel control implementation.
+ */
+ private class MyTransportTypePanelControl extends TransportTypePanelControl {
+
+ /**
+ * 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 MyTransportTypePanelControl(IDialogPage parentPage) {
+ super(parentPage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseControl#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ boolean valid = super.isValid();
+ if (!valid) return false;
+
+ // Get the currently selected transport type
+ if (transportTypeControl != null) {
+ String transportType = transportTypeControl.getSelectedTransportType();
+ if (transportType != null) {
+ // get the panel for the transport type and validate the panel
+ IWizardConfigurationPanel panel = getConfigurationPanel(transportType);
+
+ if (panel != null) {
+ valid = panel.isValid();
+ setMessage(panel.getMessage(), panel.getMessageType());
+ }
+ }
+ }
+
+ return valid;
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ public NewTargetWizardPage() {
+ this(NewTargetWizardPage.class.getName());
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param pageName The page name. Must not be <code>null</code>.
+ */
+ public NewTargetWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (peerIdControl != null) { peerIdControl.dispose(); peerIdControl = null; }
+ if (peerNameControl != null) { peerNameControl.dispose(); peerNameControl = null; }
+ if (transportTypeControl != null) { transportTypeControl.dispose(); transportTypeControl = null; }
+ if (transportTypePanelControl != null) { transportTypePanelControl.dispose(); transportTypePanelControl = null; }
+ if (tablePart != null) { tablePart.dispose(); tablePart = null; }
+
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ // Setup title and description
+ setTitle(Messages.NewTargetWizardPage_title);
+ setDescription(Messages.NewTargetWizardPage_description);
+
+ // Create the forms toolkit
+ toolkit = new FormToolkit(parent.getDisplay());
+
+ // Create the main panel
+ Composite mainPanel = toolkit.createComposite(parent);
+ mainPanel.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
+ mainPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ mainPanel.setBackground(parent.getBackground());
+
+ setControl(mainPanel);
+
+ // Setup the help
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(mainPanel, IContextHelpIds.NEW_TARGET_WIZARD_PAGE);
+
+ // Do not validate the page while creating the controls
+ boolean changed = setValidationInProgress(true);
+ // Create the main panel sub controls
+ createMainPanelControls(mainPanel, toolkit);
+ // Reset the validation in progress state
+ if (changed) setValidationInProgress(false);
+
+ // Adjust the font
+ Dialog.applyDialogFont(mainPanel);
+
+ // Validate the page for the first time
+ validatePage();
+ }
+
+ /**
+ * Creates the main panel sub controls.
+ *
+ * @param parent The parent main panel composite. Must not be <code>null</code>.
+ * @param toolkit The form toolkit. Must not be <code>null</code>.
+ */
+ protected void createMainPanelControls(Composite parent, FormToolkit toolkit) {
+ Assert.isNotNull(parent);
+
+ // Create the client composite
+ Composite client = toolkit.createComposite(parent);
+ client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ client.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ client.setBackground(parent.getBackground());
+
+ // Add the controls
+ peerIdControl = new PeerIdControl(this);
+ peerIdControl.setFormToolkit(toolkit);
+ peerIdControl.setParentControlIsInnerPanel(true);
+ peerIdControl.setupPanel(client);
+ peerIdControl.getEditFieldControl().setEnabled(false);
+ peerIdControl.setEditFieldControlText(UUID.randomUUID().toString());
+
+ peerNameControl = new PeerNameControl(this);
+ peerNameControl.setFormToolkit(toolkit);
+ peerNameControl.setParentControlIsInnerPanel(true);
+ peerNameControl.setupPanel(client);
+ peerNameControl.getEditFieldControl().setFocus();
+
+ createEmptySpace(client, 5, 2, toolkit);
+
+ // Create and configure the transport type section
+ Section transportTypeSection = toolkit.createSection(client, ExpandableComposite.TITLE_BAR);
+ transportTypeSection.setText(Messages.NewTargetWizardPage_section_transportType);
+ transportTypeSection.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ transportTypeSection.setLayoutData(layoutData);
+ transportTypeSection.setBackground(client.getBackground());
+
+ Composite transportTypeClient = toolkit.createComposite(transportTypeSection);
+ transportTypeClient.setLayout(new GridLayout());
+ transportTypeClient.setBackground(transportTypeSection.getBackground());
+ transportTypeSection.setClient(transportTypeClient);
+
+ // Create the transport type control
+ transportTypeControl = new MyTransportTypeControl(this);
+ transportTypeControl.setFormToolkit(toolkit);
+ transportTypeControl.setupPanel(transportTypeClient);
+
+ // The transport type specific controls are placed into a stack
+ transportTypePanelControl = new MyTransportTypePanelControl(this);
+
+ // Create and add the panels
+ TcpTransportPanel tcpTransportPanel = new TcpTransportPanel(transportTypePanelControl);
+ transportTypePanelControl.addConfigurationPanel(ITransportTypes.TRANSPORT_TYPE_TCP, tcpTransportPanel);
+ transportTypePanelControl.addConfigurationPanel(ITransportTypes.TRANSPORT_TYPE_SSL, tcpTransportPanel);
+ transportTypePanelControl.addConfigurationPanel(ITransportTypes.TRANSPORT_TYPE_PIPE, new PipeTransportPanel(transportTypePanelControl));
+ transportTypePanelControl.addConfigurationPanel(ITransportTypes.TRANSPORT_TYPE_CUSTOM, new CustomTransportPanel(transportTypePanelControl));
+
+ // Setup the panel control
+ transportTypePanelControl.setupPanel(transportTypeClient, TransportTypeControl.TRANSPORT_TYPES, toolkit);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ layoutData.horizontalSpan = 2;
+ transportTypePanelControl.getPanel().setLayoutData(layoutData);
+ toolkit.adapt(transportTypePanelControl.getPanel());
+
+ transportTypePanelControl.showConfigurationPanel(transportTypeControl.getSelectedTransportType());
+
+ // Create the advanced peer properties table
+ createPeerAttributesTableControl(client, toolkit);
+
+ // restore the widget values from the history
+ restoreWidgetValues();
+ }
+
+ /**
+ * Creates the peer attributes table controls.
+ *
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @param toolkit The form toolkit. Must not be <code>null</code>.
+ */
+ protected void createPeerAttributesTableControl(Composite parent, FormToolkit toolkit) {
+ Assert.isNotNull(parent);
+
+ createEmptySpace(parent, 5, 2, toolkit);
+
+ // Create and configure the advanced attributes section
+ Section attributesSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
+ attributesSection.setText(Messages.NewTargetWizardPage_section_attributes);
+ attributesSection.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ attributesSection.setLayoutData(layoutData);
+ attributesSection.setBackground(parent.getBackground());
+
+ Composite client = toolkit.createComposite(attributesSection);
+ client.setLayout(new GridLayout(2, false));
+ client.setBackground(attributesSection.getBackground());
+ attributesSection.setClient(client);
+
+ tablePart = new PeerAttributesTablePart();
+ tablePart.setMinSize(SWTControlUtil.convertWidthInCharsToPixels(client, 20), SWTControlUtil.convertHeightInCharsToPixels(client, 6));
+ tablePart.setBannedNames(new String[] { IPeer.ATTR_ID, IPeer.ATTR_AGENT_ID, IPeer.ATTR_SERVICE_MANGER_ID, IPeer.ATTR_NAME, IPeer.ATTR_TRANSPORT_NAME, IPeer.ATTR_IP_HOST, IPeer.ATTR_IP_PORT, "PipeName" }); //$NON-NLS-1$
+ tablePart.createControl(client, SWT.SINGLE | SWT.FULL_SELECTION, 2, toolkit);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.wizards.pages.AbstractValidatableWizardPage#validatePage()
+ */
+ @Override
+ public void validatePage() {
+ super.validatePage();
+ if (!isPageComplete()) return;
+
+ if (isValidationInProgress()) return;
+ setValidationInProgress(true);
+
+ boolean valid = true;
+
+ if (peerIdControl != null) {
+ valid &= peerIdControl.isValid();
+ setMessage(peerIdControl.getMessage(), peerIdControl.getMessageType());
+ }
+
+ if (peerNameControl != null) {
+ valid &= peerNameControl.isValid();
+ if (peerNameControl.getMessageType() > getMessageType()) {
+ setMessage(peerNameControl.getMessage(), peerNameControl.getMessageType());
+ }
+ }
+
+ if (transportTypeControl != null) {
+ valid &= transportTypeControl.isValid();
+ if (transportTypeControl.getMessageType() > getMessageType()) {
+ setMessage(transportTypeControl.getMessage(), transportTypeControl.getMessageType());
+ }
+ }
+
+ if (transportTypePanelControl != null) {
+ valid &= transportTypePanelControl.isValid();
+ if (transportTypePanelControl.getMessageType() > getMessageType()) {
+ setMessage(transportTypePanelControl.getMessage(), transportTypePanelControl.getMessageType());
+ }
+ }
+
+ setPageComplete(valid);
+ setValidationInProgress(false);
+ }
+
+ /**
+ * Updates the given attributes map with the current control content.
+ *
+ * @param peerAttributes The peer attributes map to update. Must not be <code>null</code>.
+ */
+ protected void updatePeerAttributes(Map<String, String> peerAttributes) {
+ Assert.isNotNull(peerAttributes);
+
+ peerAttributes.put(IPeer.ATTR_ID, peerIdControl.getEditFieldControlText());
+
+ String value = peerNameControl.getEditFieldControlText();
+ if (value != null && !"".equals(value)) peerAttributes.put(IPeer.ATTR_NAME, value); //$NON-NLS-1$
+
+ value = transportTypeControl.getSelectedTransportType();
+ if (value != null && !"".equals(value) && !ITransportTypes.TRANSPORT_TYPE_CUSTOM.equals(value)) { //$NON-NLS-1$
+ peerAttributes.put(IPeer.ATTR_TRANSPORT_NAME, value);
+ }
+
+ IWizardConfigurationPanel panel = transportTypePanelControl.getConfigurationPanel(value);
+ if (panel instanceof ISharedDataWizardPage) {
+ IPropertiesContainer data = new PropertiesContainer();
+ ((ISharedDataWizardPage)panel).extractData(data);
+
+ // Copy all string properties to the peer attributes map
+ for (String key : data.getProperties().keySet()) {
+ value = data.getStringProperty(key);
+ if (value != null && !"".equals(value)) peerAttributes.put(key, value); //$NON-NLS-1$
+ }
+ }
+
+ Map<String, String> additionalAttributes = tablePart.getAttributes();
+ if (additionalAttributes != null && !additionalAttributes.isEmpty()) {
+ peerAttributes.putAll(additionalAttributes);
+ }
+ }
+
+ /**
+ * Returns the peer attributes.
+ *
+ * @return The peer attributes or <code>null</code> if canceled.
+ */
+ public final Map<String, String> getPeerAttributes() {
+ // Create a new peer attributes map
+ Map<String, String> peerAttributes = new HashMap<String, String>();
+ // Update with the current control content
+ updatePeerAttributes(peerAttributes);
+
+ return peerAttributes;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractWizardPage#saveWidgetValues()
+ */
+ @Override
+ public void saveWidgetValues() {
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ if (peerIdControl != null) peerIdControl.saveWidgetValues(settings, null);
+ if (peerNameControl != null) peerNameControl.saveWidgetValues(settings, null);
+ if (transportTypeControl != null) transportTypeControl.saveWidgetValues(settings, null);
+ if (transportTypePanelControl != null) transportTypePanelControl.saveWidgetValues(settings, null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractWizardPage#restoreWidgetValues()
+ */
+ @Override
+ public void restoreWidgetValues() {
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ if (peerIdControl != null) peerIdControl.restoreWidgetValues(settings, null);
+ if (peerNameControl != null) peerNameControl.restoreWidgetValues(settings, null);
+ if (transportTypeControl != null) transportTypeControl.restoreWidgetValues(settings, null);
+ if (transportTypePanelControl != null) transportTypePanelControl.restoreWidgetValues(settings, null);
+ }
+ }
+}

Back to the top