Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-03-30 10:37:38 +0000
committerUwe Stieber2012-03-30 10:37:38 +0000
commit584d406667038d8c2b9595f291f354b1c4aa4416 (patch)
tree3941823891752d3f0092bae69aa1fff8e170ef44 /target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui
parentfa6f33666c29c335cfc6a6f6e957a9727529c46d (diff)
downloadorg.eclipse.tcf-584d406667038d8c2b9595f291f354b1c4aa4416.tar.gz
org.eclipse.tcf-584d406667038d8c2b9595f291f354b1c4aa4416.tar.xz
org.eclipse.tcf-584d406667038d8c2b9595f291f354b1c4aa4416.zip
Target Explorer: REWORK persistence, ADD file transfer and referenced projects to remote app launch
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java39
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java297
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java620
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java67
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjectsSection.java491
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjetcsTab.java67
9 files changed, 1643 insertions, 11 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java
index dca541478..8ec2522ef 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java
@@ -35,4 +35,43 @@ public class Messages extends NLS {
public static String ProcessImageSelectorControl_label;
public static String ProcessImageSelectorControl_error_missingProcessImage;
+ public static String FileTransferTab_name;
+
+ public static String FileTransferSection_title;
+ public static String FileTransferSection_description;
+ public static String FileTransferSection_host_column;
+ public static String FileTransferSection_target_column;
+ public static String FileTransferSection_options_column;
+ public static String FileTransferSection_add_button;
+ public static String FileTransferSection_edit_button;
+ public static String FileTransferSection_delete_button;
+ public static String FileTransferSection_up_button;
+ public static String FileTransferSection_down_button;
+ public static String FileTransferSection_toHost_text;
+ public static String FileTransferSection_toTarget_text;
+ public static String FileTransferSection_toHost_tooltip;
+ public static String FileTransferSection_toTarget_tooltip;
+
+ public static String ReferencedProjectsTab_name;
+
+ public static String ReferencedProjectsSection_title;
+ public static String ReferencedProjectsSection_description;
+ public static String ReferencedProjectsSection_project_column;
+ public static String ReferencedProjectsSection_add_button;
+ public static String ReferencedProjectsSection_delete_button;
+ public static String ReferencedProjectsSection_up_button;
+ public static String ReferencedProjectsSection_down_button;
+ public static String ReferencedProjectsSection_addDialog_message;
+
+ public static String AddEditFileTransferDialog_add_dialogTitle;
+ public static String AddEditFileTransferDialog_edit_dialogTitle;
+ public static String AddEditFileTransferDialog_add_title;
+ public static String AddEditFileTransferDialog_edit_title;
+ public static String AddEditFileTransferDialog_add_message;
+ public static String AddEditFileTransferDialog_edit_message;
+ public static String AddEditFileTransferDialog_target_label;
+ public static String AddEditFileTransferDialog_host_label;
+ public static String AddEditFileTransferDialog_options_label;
+ public static String AddEditFileTransferDialog_toHost_checkbox;
+ public static String AddEditFileTransferDialog_toTarget_checkbox;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties
index 1cf47ceb5..500e106cf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties
@@ -8,3 +8,44 @@ LaunchConfigurationMainTabSection_processArguments_label = Arguments:
ProcessImageSelectorControl_label = Process Image:
ProcessImageSelectorControl_error_missingProcessImage = Please select or enter a process image.
+
+FileTransferTab_name = File Transfers
+
+FileTransferSection_title = File Transfers
+FileTransferSection_description = File Transfers
+FileTransferSection_host_column = Host
+FileTransferSection_target_column = Target
+FileTransferSection_options_column = Options
+FileTransferSection_add_button = Add
+FileTransferSection_edit_button = Edit
+FileTransferSection_delete_button = Delete
+FileTransferSection_up_button = Up
+FileTransferSection_down_button = Down
+FileTransferSection_toHost_tooltip = Transfer from Target to Host
+FileTransferSection_toTarget_tooltip = Transfer from Host to Target
+FileTransferSection_toHost_text = <<
+FileTransferSection_toTarget_text = >>
+
+ReferencedProjectsTab_name = Referenced Projects
+
+ReferencedProjectsSection_title = Referenced Projects
+ReferencedProjectsSection_description = Referenced Projects
+ReferencedProjectsSection_project_column = Project
+ReferencedProjectsSection_add_button = Add
+ReferencedProjectsSection_delete_button = Delete
+ReferencedProjectsSection_up_button = Up
+ReferencedProjectsSection_down_button = Down
+ReferencedProjectsSection_addDialog_message = Select projects that should be built before launch.
+
+AddEditFileTransferDialog_add_dialogTitle = Add
+AddEditFileTransferDialog_edit_dialogTitle = Edit
+AddEditFileTransferDialog_add_title = Add new file transfer
+AddEditFileTransferDialog_edit_title = Edit existing file transfer
+AddEditFileTransferDialog_add_message = Please enter the host and traget file/directory.
+AddEditFileTransferDialog_edit_message = Change the host or target file/directory or the direction.
+AddEditFileTransferDialog_target_label = Target:
+AddEditFileTransferDialog_host_label = Host:
+AddEditFileTransferDialog_options_label = Options:
+AddEditFileTransferDialog_toHost_checkbox = Transfer from Target to Host
+AddEditFileTransferDialog_toTarget_checkbox = Transfer from Host to Target
+ \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java
index 31e1f01f0..ff4132bbc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java
@@ -18,13 +18,13 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.launch.core.persistence.ContextSelectorPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.tcf.filesystem.dialogs.FSOpenFileDialog;
import org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILinuxAppLaunchAttributes;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
@@ -132,12 +132,12 @@ public class LaunchConfigurationMainTabSection extends AbstractSection implement
Assert.isNotNull(configuration);
if (processImage != null) {
- String image = DefaultPersistenceDelegate.getAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_IMAGE, ""); //$NON-NLS-1$
+ String image = DefaultPersistenceDelegate.getAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, ""); //$NON-NLS-1$
processImage.setEditFieldControlText(image);
}
if (processArguments != null) {
- String arguments = DefaultPersistenceDelegate.getAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, ""); //$NON-NLS-1$
+ String arguments = DefaultPersistenceDelegate.getAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, ""); //$NON-NLS-1$
processArguments.setEditFieldControlText(arguments);
}
}
@@ -153,31 +153,31 @@ public class LaunchConfigurationMainTabSection extends AbstractSection implement
String image = processImage.getEditFieldControlText();
if (image != null && image.trim().length() > 0) {
- DefaultPersistenceDelegate.setAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_IMAGE, image);
+ DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, image);
} else {
- DefaultPersistenceDelegate.setAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
+ DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
}
} else {
- DefaultPersistenceDelegate.setAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
+ DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
}
if (processArguments != null) {
String arguments = processArguments.getEditFieldControlText();
if (arguments != null && arguments.trim().length() > 0) {
- DefaultPersistenceDelegate.setAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, arguments);
+ DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, arguments);
} else {
- DefaultPersistenceDelegate.setAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
+ DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
}
} else {
- DefaultPersistenceDelegate.setAttribute(configuration, ILinuxAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
+ DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
}
}
@Override
public boolean isValid(ILaunchConfiguration configuration) {
firstSelection = null;
- IModelNode[] contexts = ContextSelectorPersistenceDelegate.getLaunchContexts(configuration);
+ IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(configuration);
if (contexts != null && contexts.length > 0) {
firstSelection = contexts[0];
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java
index a68d7a6c8..36dd89ff0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java
@@ -14,6 +14,8 @@ import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer.FileTransferTab;
+import org.eclipse.tcf.te.tcf.launch.ui.remote.app.projects.ReferencedProjetcsTab;
/**
* Remote application launch configuration tab group implementation.
@@ -32,7 +34,15 @@ public class LaunchConfigurationTabGroup extends org.eclipse.tcf.te.launch.ui.ta
Assert.isNotNull(tabs);
ILaunchConfigurationTab tab = new LaunchConfigurationMainTab();
+ tabs.add(tab);
+ }
+ @Override
+ public void createAdditionalTabs(ILaunchConfigurationDialog dialog, List<ILaunchConfigurationTab> tabs, String mode) {
+
+ ILaunchConfigurationTab tab = new FileTransferTab();
+ tabs.add(tab);
+ tab = new ReferencedProjetcsTab();
tabs.add(tab);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java
new file mode 100644
index 000000000..9c9930e20
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * Copyright (c) 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.launch.ui.remote.app.filetransfer;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.launch.core.interfaces.IFileTransferItem;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransferItem;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransferItemValidator;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.tcf.filesystem.dialogs.FSFolderSelectionDialog;
+import org.eclipse.tcf.te.tcf.filesystem.dialogs.FSOpenFileDialog;
+import org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+
+/**
+ * AddEditFileTransferDialog
+ * @author tobias.schwarz@windriver.com
+ */
+public class AddEditFileTransferDialog extends CustomTitleAreaDialog {
+
+ final private IFileTransferItem item;
+ final IModelNode launchContext;
+
+ private BaseEditBrowseTextControl host;
+ private BaseEditBrowseTextControl target;
+ private BaseEditBrowseTextControl options;
+
+ private Button toTarget;
+ private Button toHost;
+
+ private boolean modeNew = true;
+
+
+ /**
+ * Constructor.
+ *
+ * @param item The file transfer item to edit or <code>null</code> to create a new one.
+ * @param shell The shell.
+ * @param contextHelpId The context help id.
+ */
+ public AddEditFileTransferDialog(Shell shell, String contextHelpId, IFileTransferItem item, IModelNode launchContexts) {
+ super(shell, contextHelpId);
+
+ Assert.isNotNull(item);
+
+ this.item = item;
+ this.launchContext = launchContexts;
+ this.modeNew = item.isEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ // Set dialog title and default message
+ setDialogTitle(modeNew ? Messages.AddEditFileTransferDialog_add_dialogTitle : Messages.AddEditFileTransferDialog_edit_dialogTitle);
+ setTitle(modeNew ? Messages.AddEditFileTransferDialog_add_title : Messages.AddEditFileTransferDialog_edit_title);
+ setDefaultMessage(modeNew ? Messages.AddEditFileTransferDialog_add_message : Messages.AddEditFileTransferDialog_edit_message, IMessageProvider.INFORMATION);
+
+ // Get the parent container composite
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ // Create the inner panel
+ Composite panel = new Composite(container, SWT.NULL);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ @SuppressWarnings("unused")
+ Label spacer = new Label(panel, SWT.NONE);
+
+ toTarget = new Button(panel, SWT.RADIO);
+ toTarget.setText(Messages.AddEditFileTransferDialog_toTarget_checkbox);
+ toTarget.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ validate();
+ }
+ });
+
+ spacer = new Label(panel, SWT.NONE);
+
+ toHost = new Button(panel, SWT.RADIO);
+ toHost.setText(Messages.AddEditFileTransferDialog_toHost_checkbox);
+ toHost.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ validate();
+ }
+ });
+
+ // Create the section sub controls
+ host = new BaseEditBrowseTextControl(null) {
+ @Override
+ protected void onButtonControlSelected() {
+ @SuppressWarnings("synthetic-access")
+ int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
+ if (direction == IFileTransferItem.HOST_TO_TARGET) {
+ FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
+ fileDialog.setFilterPath(getEditFieldControlText());
+ fileDialog.setFileName(getEditFieldControlText());
+ String file = fileDialog.open();
+ if (file != null) {
+ setEditFieldControlText(file);
+ }
+ }
+ else {
+ DirectoryDialog directoryDialog = new DirectoryDialog(getShell(), SWT.OPEN);
+ directoryDialog.setFilterPath(getEditFieldControlText());
+ String directory = directoryDialog.open();
+ if (directory != null) {
+ setEditFieldControlText(directory);
+ }
+ }
+ }
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+ host.setEditFieldLabel(Messages.AddEditFileTransferDialog_host_label);
+ host.setIsGroup(false);
+ host.setHideBrowseButton(false);
+ host.setAdjustBackgroundColor(true);
+ host.setParentControlIsInnerPanel(true);
+ host.setupPanel(panel);
+ host.doCreateControlDecoration(host.getEditFieldControl());
+
+ // Create the section sub controls
+ target = new BaseEditBrowseTextControl(null) {
+ @Override
+ protected void onButtonControlSelected() {
+ @SuppressWarnings("synthetic-access")
+ int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
+ ElementTreeSelectionDialog dialog = direction == IFileTransferItem.HOST_TO_TARGET ? new FSFolderSelectionDialog(getShell()) : new FSOpenFileDialog(getShell());
+ dialog.setInput(getEditFieldControlText());
+ dialog.setInput(launchContext);
+ if (dialog.open() == Window.OK) {
+ Object candidate = dialog.getFirstResult();
+ if (candidate instanceof FSTreeNode) {
+ String absPath = ((FSTreeNode) candidate).getLocation();
+ if (absPath != null) {
+ setEditFieldControlText(absPath);
+ }
+ }
+ }
+ }
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+ target.setEditFieldLabel(Messages.AddEditFileTransferDialog_target_label);
+ target.setIsGroup(false);
+ target.setHideBrowseButton(false);
+ target.setAdjustBackgroundColor(true);
+ target.setParentControlIsInnerPanel(true);
+ target.setupPanel(panel);
+ target.doCreateControlDecoration(target.getEditFieldControl());
+
+ spacer = new Label(panel, SWT.NONE);
+ spacer = new Label(panel, SWT.NONE);
+
+ options = new BaseEditBrowseTextControl(null) {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+ options.setEditFieldLabel(Messages.AddEditFileTransferDialog_options_label);
+ options.setIsGroup(false);
+ options.setHideBrowseButton(true);
+ options.setHasHistory(false);
+ options.setAdjustBackgroundColor(true);
+ options.setParentControlIsInnerPanel(true);
+ options.setupPanel(panel);
+ options.doCreateControlDecoration(target.getEditFieldControl());
+
+ applyDialogFont(container);
+
+ return container;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+
+ restoreWidgetValues();
+ validate();
+
+ return control;
+ }
+
+ protected void validate() {
+ IFileTransferItem wc = new FileTransferItem();
+ saveWidgetValues(wc);
+ Map<String,String> invalid = FileTransferItemValidator.validate(wc);
+ boolean valid = true;
+
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
+ host.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_HOST), IMessageProvider.ERROR);
+ if (valid) {
+ setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_HOST));
+ }
+ valid = false;
+ }
+ else {
+ host.updateControlDecoration(null, IMessageProvider.NONE);
+ }
+
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
+ target.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_TARGET), IMessageProvider.ERROR);
+ if (valid) {
+ setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_TARGET));
+ }
+ valid = false;
+ }
+ else {
+ target.updateControlDecoration(null, IMessageProvider.NONE);
+ }
+
+ if (valid) {
+ setErrorMessage(null);
+ }
+
+ getButton(IDialogConstants.OK_ID).setEnabled(valid);
+ }
+
+ private void saveWidgetValues(IFileTransferItem wc) {
+ wc.setProperty(IFileTransferItem.PROPERTY_HOST, new Path(host.getEditFieldControlText()).toPortableString());
+ wc.setProperty(IFileTransferItem.PROPERTY_TARGET, new Path(target.getEditFieldControlText()).toPortableString());
+ wc.setProperty(IFileTransferItem.PROPERTY_OPTIONS, options.getEditFieldControlText());
+
+ int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
+ wc.setProperty(IFileTransferItem.PROPERTY_DIRECTION, direction);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#restoreWidgetValues()
+ */
+ @Override
+ protected void restoreWidgetValues() {
+ String hostPath = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
+ host.setEditFieldControlText(hostPath != null ? new Path(hostPath).toOSString() : ""); //$NON-NLS-1$
+
+ String targetPath = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
+ target.setEditFieldControlText(targetPath != null ? new Path(targetPath).toPortableString() : ""); //$NON-NLS-1$
+ target.getButtonControl().setEnabled(launchContext != null);
+
+ String optionsString = item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
+ options.setEditFieldControlText(optionsString != null ? optionsString : ""); //$NON-NLS-1$
+
+ int direction = item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION);
+ toTarget.setSelection(direction != IFileTransferItem.TARGET_TO_HOST);
+ toHost.setSelection(direction == IFileTransferItem.TARGET_TO_HOST);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#saveWidgetValues()
+ */
+ @Override
+ protected void saveWidgetValues() {
+ saveWidgetValues(item);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java
new file mode 100644
index 000000000..323c8bcd4
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java
@@ -0,0 +1,620 @@
+/*******************************************************************************
+ * Copyright (c) 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.launch.ui.remote.app.filetransfer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+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.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.tcf.te.launch.core.interfaces.IFileTransferItem;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransferItem;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransferItemValidator;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection;
+import org.eclipse.tcf.te.ui.swt.listener.AbstractDecorationCellPaintListener;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * FileTransferSection
+ * @author tobias.schwarz@windriver.com
+ */
+public class FileTransferSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
+
+ private ControlDecoration controlDecoration;
+ private IModelNode launchContext = null;
+
+ protected static final String PROPERTY_VALIDATION_RESULT = "validation_result.transient"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ * @param form
+ * @param parent
+ */
+ public FileTransferSection(IManagedForm form, Composite parent) {
+ super(form, parent, SWT.NONE, new String[]{
+ Messages.FileTransferSection_add_button,
+ Messages.FileTransferSection_edit_button,
+ Messages.FileTransferSection_delete_button,
+ null,
+ Messages.FileTransferSection_up_button,
+ Messages.FileTransferSection_down_button});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ IFileTransferItem[] items = FileTransfersPersistenceDelegate.getFileTransfers(configuration);
+ getTablePart().getViewer().setInput(items);
+ if (items != null && items.length > 0) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(items[0]), true);
+ }
+ launchContext = LaunchContextsPersistenceDelegate.getFirstLaunchContext(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy wc) {
+ FileTransfersPersistenceDelegate.setFileTransfers(wc, (IFileTransferItem[])getTablePart().getViewer().getInput());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public boolean isValid(ILaunchConfiguration configuration) {
+ return validateInputList();
+ }
+
+ private boolean validateInputList() {
+ List<IFileTransferItem> list = getInputList();
+ boolean valid = true;
+ for (IFileTransferItem item : list) {
+ Map<String,String> invalid = item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED) ? FileTransferItemValidator.validate(item) : null;
+ item.setProperty(PROPERTY_VALIDATION_RESULT, invalid);
+ if (valid && invalid != null) {
+ valid = false;
+ setMessage(invalid.get(invalid.keySet().toArray()[0]), IMessageProvider.ERROR);
+ }
+ }
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createClient(Section section, FormToolkit toolkit) {
+ Assert.isNotNull(section);
+ Assert.isNotNull(toolkit);
+
+ section.setText(Messages.FileTransferSection_title);
+ section.setDescription(Messages.FileTransferSection_description);
+
+ section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, true));
+
+ Composite client = createClientContainer(section, 2, toolkit);
+ client.setBackground(section.getBackground());
+
+ section.setClient(client);
+
+ createPartControl((Composite)section.getClient(), SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION, 2, toolkit);
+ }
+
+ @Override
+ protected TableViewer createTableViewer(Composite parent, int style) {
+ return new CheckboxTableViewer(new Table(parent, style | SWT.CHECK));
+ }
+
+ @Override
+ protected void configureTableViewer(TableViewer viewer) {
+ super.configureTableViewer(viewer);
+
+ ColumnViewerToolTipSupport.enableFor(viewer);
+
+ final Table table = viewer.getTable();
+
+ ((CheckboxTableViewer)viewer).setCheckStateProvider(new ICheckStateProvider() {
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+ @Override
+ public boolean isChecked(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED);
+ }
+ return false;
+ }
+ });
+ ((CheckboxTableViewer)viewer).addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getElement() instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)event.getElement();
+ item.setProperty(IFileTransferItem.PROPERTY_ENABLED, event.getChecked());
+ getManagedForm().dirtyStateChanged();
+ }
+ }
+ });
+
+ TableViewerColumn tvEnableCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colEnable = tvEnableCol.getColumn();
+ colEnable.setResizable(false);
+ tvEnableCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return null;
+ }
+ });
+
+ TableViewerColumn tvHostCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colHost = tvHostCol.getColumn();
+ colHost.setText(Messages.FileTransferSection_host_column);
+ colHost.setResizable(true);
+ tvHostCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
+ return invalid.get(IFileTransferItem.PROPERTY_HOST);
+ }
+ String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
+ return host != null ? new Path(host).toOSString() : host;
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
+ return host != null ? new Path(host).toOSString() : host;
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableViewerColumn tvDirCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colDir = tvDirCol.getColumn();
+ colDir.setResizable(false);
+ colDir.setAlignment(SWT.CENTER);
+ tvDirCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
+ case IFileTransferItem.HOST_TO_TARGET:
+ return Messages.FileTransferSection_toTarget_tooltip;
+ case IFileTransferItem.TARGET_TO_HOST:
+ return Messages.FileTransferSection_toHost_tooltip;
+ }
+ }
+ return super.getToolTipText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
+ case IFileTransferItem.HOST_TO_TARGET:
+ return Messages.FileTransferSection_toTarget_text;
+ case IFileTransferItem.TARGET_TO_HOST:
+ return Messages.FileTransferSection_toHost_text;
+ }
+ }
+ return super.getText(element);
+ }
+ });
+ tvDirCol.setEditingSupport(new EditingSupport(tvDirCol.getViewer()) {
+ @Override
+ protected void setValue(Object element, Object value) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ item.setProperty(IFileTransferItem.PROPERTY_DIRECTION,
+ Boolean.parseBoolean(value.toString()) ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST);
+ getManagedForm().dirtyStateChanged();
+ getViewer().refresh();
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return new Boolean(item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION) != IFileTransferItem.TARGET_TO_HOST);
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return new CheckboxCellEditor();
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+ });
+
+ TableViewerColumn tvTargetCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colTarget = tvTargetCol.getColumn();
+ colTarget.setText(Messages.FileTransferSection_target_column);
+ colTarget.setResizable(true);
+ tvTargetCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
+ return invalid.get(IFileTransferItem.PROPERTY_TARGET);
+ }
+ String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
+ return target != null ? new Path(target).toPortableString() : target;
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
+ return target != null ? new Path(target).toPortableString() : target;
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableViewerColumn tvOptionCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colOption = tvOptionCol.getColumn();
+ colOption.setText(Messages.FileTransferSection_options_column);
+ colOption.setResizable(true);
+ tvOptionCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableLayout tableLayout = new TableLayout();
+ tableLayout.addColumnData(new ColumnPixelData(30, true));
+ tableLayout.addColumnData(new ColumnPixelData(200, true));
+ tableLayout.addColumnData(new ColumnPixelData(30, true));
+ tableLayout.addColumnData(new ColumnPixelData(200, true));
+ tableLayout.addColumnData(new ColumnPixelData(100, true));
+ table.setLayout(tableLayout);
+ GridData data = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING);
+ table.setLayoutData(data);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ table.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int width = table.getSize().x - 4 - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth() - colTarget.getWidth();
+ colOption.setWidth(Math.max(width, 100));
+ }
+ });
+ colHost.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int colWidth = colHost.getWidth();
+ if (colWidth < 100) {
+ event.doit = false;
+ colHost.setWidth(100);
+ colWidth = 100;
+ }
+ int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colDir.getWidth() - colTarget.getWidth();
+ colOption.setWidth(Math.max(width, 100));
+ }
+ });
+ colTarget.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int colWidth = colTarget.getWidth();
+ if (colWidth < 100) {
+ event.doit = false;
+ colTarget.setWidth(100);
+ colWidth = 100;
+ }
+ int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth();
+ colOption.setWidth(Math.max(width, 100));
+ }
+ });
+
+ @SuppressWarnings("unused")
+ AbstractDecorationCellPaintListener cpl = new AbstractDecorationCellPaintListener(table, 1, 3) {
+ @Override
+ protected int getDecorationState(Object data, int columnIndex) {
+ if (data instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)data;
+ if (item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED)) {
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null) {
+ switch (columnIndex) {
+ case 1:
+ if (invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
+ return STATE_ERROR;
+ }
+ break;
+ case 3:
+ if (invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
+ return STATE_ERROR;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return STATE_NONE;
+ }
+ };
+
+ viewer.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public void dispose() {
+ }
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ viewer.refresh();
+ }
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return inputElement instanceof Object[] ? (Object[])inputElement : new Object[0];
+ }
+ });
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ initializeButtonsEnablement();
+ }
+ });
+
+ doCreateControlDecoration(table);
+ configureControlDecoration(getControlDecoration());
+ }
+
+ /**
+ * Creates a new instance of a {@link ControlDecoration} object associated with
+ * the given control. The method is called after the control has been created.
+ *
+ * @param control The control. Must not be <code>null</code>.
+ * @return The control decoration object instance.
+ */
+ public ControlDecoration doCreateControlDecoration(Control control) {
+ Assert.isNotNull(control);
+ controlDecoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT);
+ return controlDecoration;
+ }
+
+ /**
+ * Returns the control decoration.
+ *
+ * @return The control decoration instance or <code>null</code> if not yet created.
+ */
+ public final ControlDecoration getControlDecoration() {
+ return controlDecoration;
+ }
+
+ /**
+ * Configure the given control decoration.
+ *
+ * @param decoration The control decoration. Must not be <code>null</code>.
+ */
+ protected void configureControlDecoration(ControlDecoration decoration) {
+ Assert.isNotNull(decoration);
+ decoration.setShowOnlyOnFocus(false);
+ }
+
+ /**
+ * Updates the control decoration to represent the given message and message type.
+ * If the message is <code>null</code> or the message type is IMessageProvider.NONE,
+ * no decoration will be shown.
+ *
+ * @param message The message.
+ * @param messageType The message type.
+ */
+ public void updateControlDecoration(String message, int messageType) {
+ if (getControlDecoration() != null) {
+ // The description is the same as the message
+ getControlDecoration().setDescriptionText(message);
+
+ // The icon depends on the message type
+ FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
+
+ // Determine the id of the decoration to show
+ String decorationId = FieldDecorationRegistry.DEC_INFORMATION;
+ if (messageType == IMessageProvider.ERROR) {
+ decorationId = FieldDecorationRegistry.DEC_ERROR;
+ } else if (messageType == IMessageProvider.WARNING) {
+ decorationId = FieldDecorationRegistry.DEC_WARNING;
+ }
+
+ // Get the field decoration
+ FieldDecoration fieldDeco = registry.getFieldDecoration(decorationId);
+ if (fieldDeco != null) {
+ getControlDecoration().setImage(fieldDeco.getImage());
+ }
+
+ if (message == null || messageType == IMessageProvider.NONE) {
+ getControlDecoration().hide();
+ }
+ else {
+ getControlDecoration().show();
+ }
+ }
+ }
+
+ private List<IFileTransferItem> getInputList() {
+ return new ArrayList<IFileTransferItem>(Arrays.asList((IFileTransferItem[])getTablePart().getViewer().getInput()));
+ }
+
+ private void setInputList(List<IFileTransferItem> list) {
+ getTablePart().getViewer().setInput(list.toArray(new IFileTransferItem[list.size()]));
+ }
+
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ onButtonEditClick();
+ }
+
+ @Override
+ protected void onButtonSelected(Button button) {
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ List<IFileTransferItem> list = getInputList();
+
+ switch (((Integer)button.getData()).intValue()) {
+ case 0: // Add
+ onButtonAddClick();
+ break;
+ case 1: // Edit
+ onButtonEditClick();
+ break;
+ case 2: // Delete
+ list.remove(selIndex);
+ setInputList(list);
+ if (!list.isEmpty()) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(
+ new StructuredSelection(list.get(selIndex < list.size() ? selIndex : list.size()-1)), true);
+ }
+ break;
+ case 4: // Up
+ list.add(selIndex-1, list.remove(selIndex));
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex-1)), true);
+ break;
+ case 5: // Down
+ list.add(selIndex+1, list.remove(selIndex));
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex+1)), true);
+ break;
+ }
+ validateInputList();
+ getManagedForm().dirtyStateChanged();
+ }
+
+ private void onButtonAddClick() {
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ List<IFileTransferItem> list = getInputList();
+ IFileTransferItem item = new FileTransferItem();
+ AddEditFileTransferDialog dialog = new AddEditFileTransferDialog(getSection().getShell(), null, item, launchContext);
+ if (dialog.open() == Window.OK) {
+ item.setProperty(IFileTransferItem.PROPERTY_ENABLED, true);
+ list.add(selIndex != -1 ? selIndex : 0, item);
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(item), true);
+ }
+ }
+
+ private void onButtonEditClick() {
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+
+ if (selIndex >= 0) {
+ List<IFileTransferItem> list = getInputList();
+ IFileTransferItem item = list.get(selIndex);
+
+ AddEditFileTransferDialog dialog = new AddEditFileTransferDialog(getSection().getShell(), null, item, launchContext);
+ if (dialog.open() == Window.OK) {
+ list.set(selIndex, item);
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(item), true);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection#initializeButtonsEnablement()
+ */
+ @Override
+ protected void initializeButtonsEnablement() {
+ ISelection selection = ((TableViewer)getTablePart().getViewer()).getSelection();
+ boolean singleSelection = selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1;
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ int count = ((TableViewer)getTablePart().getViewer()).getTable().getItemCount();
+
+ getTablePart().getButton(0).setEnabled(getTablePart().isEnabled());
+ getTablePart().getButton(1).setEnabled(getTablePart().isEnabled() && singleSelection);
+ getTablePart().getButton(2).setEnabled(getTablePart().isEnabled() && singleSelection);
+ getTablePart().getButton(4).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex > 0);
+ getTablePart().getButton(5).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex < count-1);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java
new file mode 100644
index 000000000..44dcd4c76
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 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.launch.ui.remote.app.filetransfer;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab;
+import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+/**
+ * File transfer launch configuration tab implementation.
+ */
+public class FileTransferTab extends AbstractFormsLaunchConfigurationTab {
+ // References to the tab sub sections
+ private FileTransferSection section;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (section != null) { section.dispose(); section = null; }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#doCreateFormContent(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
+ */
+ @Override
+ protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ // Setup the main panel (using the table wrap layout)
+ Composite panel = toolkit.getFormToolkit().createComposite(parent);
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.makeColumnsEqualWidth = true;
+ layout.numColumns = 1;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ panel.setBackground(parent.getBackground());
+
+ section = new FileTransferSection(getManagedForm(), panel);
+ section.getSection().setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
+ getManagedForm().addPart(section);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ @Override
+ public String getName() {
+ return Messages.FileTransferTab_name;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjectsSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjectsSection.java
new file mode 100644
index 000000000..ee4d91323
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjectsSection.java
@@ -0,0 +1,491 @@
+/*******************************************************************************
+ * Copyright (c) 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.launch.ui.remote.app.projects;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+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.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectItem;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectItemValidator;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
+import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection;
+import org.eclipse.tcf.te.ui.swt.listener.AbstractDecorationCellPaintListener;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * ReferencedProjectsSection
+ * @author tobias.schwarz@windriver.com
+ */
+public class ReferencedProjectsSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
+
+ private ControlDecoration controlDecoration;
+
+ protected static final String PROPERTY_VALIDATION_RESULT = "validation_result.transient"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ * @param form
+ * @param parent
+ */
+ public ReferencedProjectsSection(IManagedForm form, Composite parent) {
+ super(form, parent, SWT.NONE, new String[]{
+ Messages.ReferencedProjectsSection_add_button,
+ Messages.ReferencedProjectsSection_delete_button,
+ null,
+ Messages.ReferencedProjectsSection_up_button,
+ Messages.ReferencedProjectsSection_down_button});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ IReferencedProjectItem[] items = ReferencedProjectsPersistenceDelegate.getReferencedProjects(configuration);
+ getTablePart().getViewer().setInput(items);
+ if (items != null && items.length > 0) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(items[0]), true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy wc) {
+ ReferencedProjectsPersistenceDelegate.setReferencedProjects(wc, (IReferencedProjectItem[])getTablePart().getViewer().getInput());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public boolean isValid(ILaunchConfiguration configuration) {
+ return validateInputList();
+ }
+
+ private boolean validateInputList() {
+ List<IReferencedProjectItem> list = getInputList();
+ boolean valid = true;
+ for (IReferencedProjectItem item : list) {
+ Map<String,String> invalid = item.getBooleanProperty(IReferencedProjectItem.PROPERTY_ENABLED) ? ReferencedProjectItemValidator.validate(item) : null;
+ item.setProperty(PROPERTY_VALIDATION_RESULT, invalid);
+ if (valid && invalid != null) {
+ valid = false;
+ setMessage(invalid.get(invalid.keySet().toArray()[0]), IMessageProvider.ERROR);
+ }
+ }
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createClient(Section section, FormToolkit toolkit) {
+ Assert.isNotNull(section);
+ Assert.isNotNull(toolkit);
+
+ section.setText(Messages.ReferencedProjectsSection_title);
+ section.setDescription(Messages.ReferencedProjectsSection_description);
+
+ section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, true));
+
+ Composite client = createClientContainer(section, 2, toolkit);
+ client.setBackground(section.getBackground());
+
+ section.setClient(client);
+
+ createPartControl((Composite)section.getClient(), SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION, 2, toolkit);
+ }
+
+ @Override
+ protected TableViewer createTableViewer(Composite parent, int style) {
+ return new CheckboxTableViewer(new Table(parent, style | SWT.CHECK));
+ }
+
+ @Override
+ protected void configureTableViewer(TableViewer viewer) {
+ super.configureTableViewer(viewer);
+
+ ColumnViewerToolTipSupport.enableFor(viewer);
+
+ final Table table = viewer.getTable();
+
+ ((CheckboxTableViewer)viewer).setCheckStateProvider(new ICheckStateProvider() {
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+ @Override
+ public boolean isChecked(Object element) {
+ if (element instanceof IReferencedProjectItem) {
+ IReferencedProjectItem item = (IReferencedProjectItem)element;
+ return item.getBooleanProperty(IReferencedProjectItem.PROPERTY_ENABLED);
+ }
+ return false;
+ }
+ });
+ ((CheckboxTableViewer)viewer).addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getElement() instanceof IReferencedProjectItem) {
+ IReferencedProjectItem item = (IReferencedProjectItem)event.getElement();
+ item.setProperty(IReferencedProjectItem.PROPERTY_ENABLED, event.getChecked());
+ getManagedForm().dirtyStateChanged();
+ }
+ }
+ });
+
+ TableViewerColumn tvEnableCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colEnable = tvEnableCol.getColumn();
+ colEnable.setResizable(false);
+ tvEnableCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return null;
+ }
+ });
+
+ TableViewerColumn tvProjectCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colProject = tvProjectCol.getColumn();
+ colProject.setText(Messages.ReferencedProjectsSection_project_column);
+ colProject.setResizable(true);
+ tvProjectCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IReferencedProjectItem) {
+ IReferencedProjectItem item = (IReferencedProjectItem)element;
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null && invalid.containsKey(IReferencedProjectItem.PROPERTY_PROJECT_NAME)) {
+ return invalid.get(IReferencedProjectItem.PROPERTY_PROJECT_NAME);
+ }
+ return item.getStringProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME);
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IReferencedProjectItem) {
+ IReferencedProjectItem item = (IReferencedProjectItem)element;
+ return item.getStringProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME);
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableLayout tableLayout = new TableLayout();
+ tableLayout.addColumnData(new ColumnPixelData(30, true));
+ tableLayout.addColumnData(new ColumnPixelData(200, true));
+ table.setLayout(tableLayout);
+ GridData data = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING);
+ table.setLayoutData(data);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ table.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int width = table.getSize().x - 4 - colEnable.getWidth();
+ colProject.setWidth(Math.max(width, 100));
+ }
+ });
+
+ @SuppressWarnings("unused")
+ AbstractDecorationCellPaintListener cpl = new AbstractDecorationCellPaintListener(table, 1) {
+ @Override
+ protected int getDecorationState(Object data, int columnIndex) {
+ if (data instanceof IReferencedProjectItem) {
+ IReferencedProjectItem item = (IReferencedProjectItem)data;
+ if (item.getBooleanProperty(IReferencedProjectItem.PROPERTY_ENABLED)) {
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null) {
+ switch (columnIndex) {
+ case 1:
+ if (invalid.containsKey(IReferencedProjectItem.PROPERTY_PROJECT_NAME)) {
+ return STATE_ERROR;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return STATE_NONE;
+ }
+ };
+
+ viewer.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public void dispose() {
+ }
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ viewer.refresh();
+ }
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return inputElement instanceof Object[] ? (Object[])inputElement : new Object[0];
+ }
+ });
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ initializeButtonsEnablement();
+ }
+ });
+
+ doCreateControlDecoration(table);
+ configureControlDecoration(getControlDecoration());
+ }
+
+ /**
+ * Creates a new instance of a {@link ControlDecoration} object associated with
+ * the given control. The method is called after the control has been created.
+ *
+ * @param control The control. Must not be <code>null</code>.
+ * @return The control decoration object instance.
+ */
+ public ControlDecoration doCreateControlDecoration(Control control) {
+ Assert.isNotNull(control);
+ controlDecoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT);
+ return controlDecoration;
+ }
+
+ /**
+ * Returns the control decoration.
+ *
+ * @return The control decoration instance or <code>null</code> if not yet created.
+ */
+ public final ControlDecoration getControlDecoration() {
+ return controlDecoration;
+ }
+
+ /**
+ * Configure the given control decoration.
+ *
+ * @param decoration The control decoration. Must not be <code>null</code>.
+ */
+ protected void configureControlDecoration(ControlDecoration decoration) {
+ Assert.isNotNull(decoration);
+ decoration.setShowOnlyOnFocus(false);
+ }
+
+ /**
+ * Updates the control decoration to represent the given message and message type.
+ * If the message is <code>null</code> or the message type is IMessageProvider.NONE,
+ * no decoration will be shown.
+ *
+ * @param message The message.
+ * @param messageType The message type.
+ */
+ public void updateControlDecoration(String message, int messageType) {
+ if (getControlDecoration() != null) {
+ // The description is the same as the message
+ getControlDecoration().setDescriptionText(message);
+
+ // The icon depends on the message type
+ FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
+
+ // Determine the id of the decoration to show
+ String decorationId = FieldDecorationRegistry.DEC_INFORMATION;
+ if (messageType == IMessageProvider.ERROR) {
+ decorationId = FieldDecorationRegistry.DEC_ERROR;
+ } else if (messageType == IMessageProvider.WARNING) {
+ decorationId = FieldDecorationRegistry.DEC_WARNING;
+ }
+
+ // Get the field decoration
+ FieldDecoration fieldDeco = registry.getFieldDecoration(decorationId);
+ if (fieldDeco != null) {
+ getControlDecoration().setImage(fieldDeco.getImage());
+ }
+
+ if (message == null || messageType == IMessageProvider.NONE) {
+ getControlDecoration().hide();
+ }
+ else {
+ getControlDecoration().show();
+ }
+ }
+ }
+
+ private List<IReferencedProjectItem> getInputList() {
+ return new ArrayList<IReferencedProjectItem>(Arrays.asList((IReferencedProjectItem[])getTablePart().getViewer().getInput()));
+ }
+
+ private void setInputList(List<IReferencedProjectItem> list) {
+ getTablePart().getViewer().setInput(list.toArray(new IReferencedProjectItem[list.size()]));
+ }
+
+ @Override
+ protected void onButtonSelected(Button button) {
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ List<IReferencedProjectItem> list = getInputList();
+
+ switch (((Integer)button.getData()).intValue()) {
+ case 0: // Add
+ onButtonAddClick();
+ break;
+ case 1: // Edit
+ list.remove(selIndex);
+ setInputList(list);
+ if (!list.isEmpty()) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(
+ new StructuredSelection(list.get(selIndex < list.size() ? selIndex : list.size()-1)), true);
+ }
+ break;
+ case 3: // Up
+ list.add(selIndex-1, list.remove(selIndex));
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex-1)), true);
+ break;
+ case 4: // Down
+ list.add(selIndex+1, list.remove(selIndex));
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex+1)), true);
+ break;
+ }
+ validateInputList();
+ getManagedForm().dirtyStateChanged();
+ }
+
+ private boolean contains(List<IReferencedProjectItem> list, IProject project) {
+ for (IReferencedProjectItem item : list) {
+ if (item.isProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME, project.getName())) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ private void onButtonAddClick() {
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ List<IReferencedProjectItem> list = getInputList();
+
+ IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ List<String> unreferencedProjects = new ArrayList<String>();
+ for (IProject project : allProjects) {
+ if (project.isOpen() && !contains(list, project)) {
+ unreferencedProjects.add(project.getName());
+ }
+ }
+
+ ILabelProvider labelProvider = new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return (String)element;
+ }
+ };
+
+ IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ @Override
+ public void dispose() {
+ }
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return (Object[])inputElement;
+ }
+ };
+
+ ListSelectionDialog dialog = new ListSelectionDialog(getSection().getShell(),
+ unreferencedProjects.toArray(), contentProvider, labelProvider, Messages.ReferencedProjectsSection_addDialog_message);
+
+ if (dialog.open() == Window.OK) {
+ Object[] result = dialog.getResult();
+
+ if (result != null) {
+ IReferencedProjectItem first = null;
+ for (Object name : result) {
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject((String)name);
+ if (prj != null && prj.isOpen()) {
+ IReferencedProjectItem item = new ReferencedProjectItem();
+ item.setProperty(IReferencedProjectItem.PROPERTY_ENABLED, true);
+ item.setProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME, prj.getName());
+ list.add(selIndex != -1 ? selIndex++ : 0, item);
+ if (first == null) {
+ first = item;
+ }
+ }
+ }
+ setInputList(list);
+ if (first != null) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(first), true);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection#initializeButtonsEnablement()
+ */
+ @Override
+ protected void initializeButtonsEnablement() {
+ ISelection selection = ((TableViewer)getTablePart().getViewer()).getSelection();
+ boolean singleSelection = selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1;
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ int count = ((TableViewer)getTablePart().getViewer()).getTable().getItemCount();
+
+ getTablePart().getButton(0).setEnabled(getTablePart().isEnabled());
+ getTablePart().getButton(1).setEnabled(getTablePart().isEnabled() && singleSelection);
+ getTablePart().getButton(3).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex > 0);
+ getTablePart().getButton(4).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex < count-1);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjetcsTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjetcsTab.java
new file mode 100644
index 000000000..9c86abb7a
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/projects/ReferencedProjetcsTab.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 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.launch.ui.remote.app.projects;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab;
+import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+/**
+ * Referenced projetcs launch configuration tab implementation.
+ */
+public class ReferencedProjetcsTab extends AbstractFormsLaunchConfigurationTab {
+ // References to the tab sub sections
+ private ReferencedProjectsSection section;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (section != null) { section.dispose(); section = null; }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#doCreateFormContent(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
+ */
+ @Override
+ protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ // Setup the main panel (using the table wrap layout)
+ Composite panel = toolkit.getFormToolkit().createComposite(parent);
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.makeColumnsEqualWidth = true;
+ layout.numColumns = 1;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ panel.setBackground(parent.getBackground());
+
+ section = new ReferencedProjectsSection(getManagedForm(), panel);
+ section.getSection().setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
+ getManagedForm().addPart(section);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ @Override
+ public String getName() {
+ return Messages.ReferencedProjectsTab_name;
+ }
+}

Back to the top