Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-09-18 07:37:12 +0000
committerUwe Stieber2012-09-18 07:37:12 +0000
commit8eec89f974d6f751e72f0d2183de788f78fa8147 (patch)
treee865132ee3cd0abf0a426d32e48b56de7e7716f6 /target_explorer
parent41d89ccf0526314bc369c7c8d50bee77b14c7601 (diff)
downloadorg.eclipse.tcf-8eec89f974d6f751e72f0d2183de788f78fa8147.tar.gz
org.eclipse.tcf-8eec89f974d6f751e72f0d2183de788f78fa8147.tar.xz
org.eclipse.tcf-8eec89f974d6f751e72f0d2183de788f78fa8147.zip
Target Explorer: Fix section layout handling
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java1115
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java941
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationAdvancedTabSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/CustomFormToolkit.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractFormTextSection.java341
11 files changed, 1237 insertions, 1204 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java
index c064a9a36..86841e5fb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java
@@ -1,556 +1,559 @@
-/*******************************************************************************
- * 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.launch.ui.tabs.filetransfers;
-
-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.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-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.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.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.launch.ui.nls.Messages;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
-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;
-
-/**
- * AbstractFileTransferSection
- */
-public abstract class AbstractFileTransferSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
-
- protected ControlDecoration controlDecoration;
- protected IModelNode launchContext = null;
-
- protected static final String PROPERTY_VALIDATION_RESULT = "validation_result.transient"; //$NON-NLS-1$
-
- /**
- * Constructor.
- * @param form
- * @param parent
- */
- public AbstractFileTransferSection(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();
- }
-
- protected abstract boolean validateInputList();
-
- /* (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);
-
- // Mark the control update as completed now
- setIsUpdating(false);
- }
-
- @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();
-
- if (viewer instanceof CheckboxTableViewer) {
- ((CheckboxTableViewer)viewer).setCheckStateProvider(new FileTransferCheckStateProvider());
- ((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.TARGET_TO_HOST:
- return Messages.FileTransferSection_toHost_tooltip;
- default:
- return Messages.FileTransferSection_toTarget_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.TARGET_TO_HOST:
- return Messages.FileTransferSection_toHost_text;
- default:
- return Messages.FileTransferSection_toTarget_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 Boolean.valueOf(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 FileTransferContentProvider());
- 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();
- }
- }
- }
-
- protected List<IFileTransferItem> getInputList() {
- return new ArrayList<IFileTransferItem>(Arrays.asList((IFileTransferItem[])getTablePart().getViewer().getInput()));
- }
-
- protected 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();
- }
-
- protected abstract void onButtonAddClick();
-
- protected abstract void onButtonEditClick();
-
- /* (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);
- }
-}
+/*******************************************************************************
+ * 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.launch.ui.tabs.filetransfers;
+
+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.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+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.swt.SWT;
+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.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.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.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
+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;
+
+/**
+ * AbstractFileTransferSection
+ */
+public abstract class AbstractFileTransferSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
+
+ protected ControlDecoration controlDecoration;
+ protected IModelNode launchContext = null;
+
+ protected static final String PROPERTY_VALIDATION_RESULT = "validation_result.transient"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ * @param form
+ * @param parent
+ */
+ public AbstractFileTransferSection(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();
+ }
+
+ protected abstract boolean validateInputList();
+
+ /* (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);
+
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ 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);
+
+ // Mark the control update as completed now
+ setIsUpdating(false);
+ }
+
+ @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();
+
+ if (viewer instanceof CheckboxTableViewer) {
+ ((CheckboxTableViewer)viewer).setCheckStateProvider(new FileTransferCheckStateProvider());
+ ((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.TARGET_TO_HOST:
+ return Messages.FileTransferSection_toHost_tooltip;
+ default:
+ return Messages.FileTransferSection_toTarget_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.TARGET_TO_HOST:
+ return Messages.FileTransferSection_toHost_text;
+ default:
+ return Messages.FileTransferSection_toTarget_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 Boolean.valueOf(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 FileTransferContentProvider());
+ 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();
+ }
+ }
+ }
+
+ protected List<IFileTransferItem> getInputList() {
+ return new ArrayList<IFileTransferItem>(Arrays.asList((IFileTransferItem[])getTablePart().getViewer().getInput()));
+ }
+
+ protected 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();
+ }
+
+ protected abstract void onButtonAddClick();
+
+ protected abstract void onButtonEditClick();
+
+ /* (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.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java
index 538263f26..c2c75cd83 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
import org.eclipse.tcf.te.launch.ui.activator.UIPlugin;
@@ -87,7 +88,9 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp
// Configure the section
section.setText(Messages.ContextSelectorSection_title);
- section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 1, toolkit);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java
index 96f793da6..7365ddd90 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java
@@ -1,469 +1,472 @@
-/*******************************************************************************
- * 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.launch.ui.tabs.refprojects;
-
-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.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.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;
-
-/**
- * RefProjectsSection
- */
-public class RefProjectsSection 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 RefProjectsSection(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);
-
- // Mark the control update as completed now
- setIsUpdating(false);
- }
-
- @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();
-
- if (viewer instanceof CheckboxTableViewer) {
- ((CheckboxTableViewer)viewer).setCheckStateProvider(new RefProjectsCheckStateProvider());
- ((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_name_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 RefProjectsContentProvider());
- 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 true;
- }
- }
- 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);
- }
-}
+/*******************************************************************************
+ * 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.launch.ui.tabs.refprojects;
+
+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.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.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.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.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;
+
+/**
+ * RefProjectsSection
+ */
+public class RefProjectsSection 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 RefProjectsSection(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);
+
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ 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);
+
+ // Mark the control update as completed now
+ setIsUpdating(false);
+ }
+
+ @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();
+
+ if (viewer instanceof CheckboxTableViewer) {
+ ((CheckboxTableViewer)viewer).setCheckStateProvider(new RefProjectsCheckStateProvider());
+ ((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_name_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 RefProjectsContentProvider());
+ 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 true;
+ }
+ }
+ 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/LaunchConfigurationAdvancedTabSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationAdvancedTabSection.java
index 4e08f673f..2144cb9bb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationAdvancedTabSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationAdvancedTabSection.java
@@ -64,7 +64,9 @@ public class LaunchConfigurationAdvancedTabSection extends AbstractSection imple
// Configure the section
section.setText(Messages.LaunchConfigurationAdvancedTabSection_title);
- section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 1, toolkit);
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 c4d65d176..e4e8fd12b 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
@@ -17,6 +17,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
@@ -64,7 +65,9 @@ public class LaunchConfigurationMainTabSection extends AbstractSection implement
// Configure the section
section.setText(Messages.LaunchConfigurationMainTabSection_title);
- section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 3, toolkit);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java
index 06d8dd71f..ebf7c9c37 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
@@ -120,7 +121,9 @@ public class AttributesSection extends AbstractSection {
section.setText(Messages.AttributesSection_title);
section.setDescription(Messages.AttributesSection_description);
- section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 2, toolkit);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java
index f37a45e4c..909b6f24e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java
@@ -115,7 +115,9 @@ public class GeneralInformationSection extends AbstractSection {
section.setText(Messages.GeneralInformationSection_title);
section.setDescription(Messages.GeneralInformationSection_description);
- section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 2, toolkit);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java
index c89562a9b..18395e78f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java
@@ -70,7 +70,9 @@ public class ServicesSection extends AbstractSection {
section.setText(Messages.ServicesSection_title);
section.setDescription(Messages.ServicesSection_description);
- section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 1, toolkit);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
index b0805f22f..dfd3fdb23 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
@@ -112,7 +113,9 @@ public class TransportSection extends AbstractSection {
section.setText(Messages.TransportSection_title);
section.setDescription(Messages.TransportSection_description);
- section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
// Create the section client
Composite client = createClientContainer(section, 2, toolkit);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/CustomFormToolkit.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/CustomFormToolkit.java
index fb021b69f..c741fac05 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/CustomFormToolkit.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/CustomFormToolkit.java
@@ -250,7 +250,9 @@ public class CustomFormToolkit extends PlatformObject {
}
section.setLayout(new GridLayout());
- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (scrolledForm.getBody().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ }
// Create an associate an expansion listener to the expandable form
section.addExpansionListener(new IExpansionListener() {
@@ -335,7 +337,9 @@ public class CustomFormToolkit extends PlatformObject {
// Configure the layout
section.setLayout(new GridLayout());
- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (scrolledForm.getBody().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ }
// Create the client area the caller can use as parent for the control
Composite client = getFormToolkit().createComposite(section);
@@ -380,7 +384,9 @@ public class CustomFormToolkit extends PlatformObject {
// Configure the layout
section.setLayout(new GridLayout());
- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (parent.getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ }
// Create the client area the caller can use as parent for the control
Composite client = getFormToolkit().createComposite(section);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractFormTextSection.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractFormTextSection.java
index ead102c38..7ba6cf715 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractFormTextSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractFormTextSection.java
@@ -1,169 +1,172 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.forms.parts;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-
-/**
- * Abstract form text section implementation.
- */
-public abstract class AbstractFormTextSection extends AbstractSection implements IHyperlinkListener {
-
- /**
- * Constructor.
- *
- * @param form The parent managed form. Must not be <code>null</code>.
- * @param parent The parent composite. Must not be <code>null</code>.
- * @param style The section style.
- */
- public AbstractFormTextSection(IManagedForm form, Composite parent, int style) {
- this(form, parent, style, true);
- }
-
- /**
- * Constructor.
- *
- * @param form The parent managed form. Must not be <code>null</code>.
- * @param parent The parent composite. Must not be <code>null</code>.
- * @param style The section style.
- * @param titleBar If <code>true</code>, the title bar style bit is added to <code>style</code>.
- */
- public AbstractFormTextSection(IManagedForm form, Composite parent, int style, boolean titleBar) {
- super(form, parent, style, titleBar);
- getSection().setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
- }
-
- /* (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);
-
- // Configure the section
- section.setText(getSectionTitle());
-
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Create the section client
- Composite client = toolkit.createComposite(section, SWT.NONE);
- Assert.isNotNull(client);
- client.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1));
- client.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
-
- FormText text = createFormText(client, toolkit);
- configureFormText(text);
-
- section.setClient(client);
-
- // Mark the control update as completed now
- setIsUpdating(false);
- }
-
- /**
- * Returns the section title.
- *
- * @return The section title.
- */
- protected abstract String getSectionTitle();
-
- /**
- * Returns the form text content.
- *
- * @return The form text content.
- */
- protected abstract String getFormTextContent();
-
- /**
- * Creates a form text control in the given parent composite with the given
- * content and form toolkit.
- *
- * @param parent The parent composite. Must not be <code>null</code>.
- * @param toolkit The toolkit. Must not be <code>null</code>.
- *
- * @return The form text control.
- */
- protected final FormText createFormText(Composite parent, FormToolkit toolkit) {
- Assert.isNotNull(parent);
- Assert.isNotNull(toolkit);
-
- // Create the form text control
- return toolkit.createFormText(parent, true);
- }
-
- /**
- * Configure the form text.
- * <p>
- * The default implementation is setting the form text content
- * and adding ourself as hyper link listener. The form text
- * content is queried through {@link #getFormTextContent()}.
- *
- * @param text The form text. Must not be <code>null</code>.
- */
- protected void configureFormText(FormText text) {
- Assert.isNotNull(text);
-
- // Set the content. If it fails, set the failure message
- try {
- text.setText(getFormTextContent(), true, false);
- } catch (SWTException e) {
- text.setText(e.getMessage(), false, false);
- }
-
- // Add ourself as hyper link listener
- text.addHyperlinkListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent)
- */
- @Override
- public void linkEntered(HyperlinkEvent e) {
- Object container = getManagedForm().getContainer();
- if (container instanceof IEditorPart) {
- IStatusLineManager manager = ((IEditorPart)container).getEditorSite().getActionBars().getStatusLineManager();
- manager.setMessage(e.getLabel());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent)
- */
- @Override
- public void linkExited(HyperlinkEvent e) {
- Object container = getManagedForm().getContainer();
- if (container instanceof IEditorPart) {
- IStatusLineManager manager = ((IEditorPart)container).getEditorSite().getActionBars().getStatusLineManager();
- manager.setMessage(null);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
- */
- @Override
- public void linkActivated(HyperlinkEvent e) {
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.forms.parts;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormText;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+
+/**
+ * Abstract form text section implementation.
+ */
+public abstract class AbstractFormTextSection extends AbstractSection implements IHyperlinkListener {
+
+ /**
+ * Constructor.
+ *
+ * @param form The parent managed form. Must not be <code>null</code>.
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @param style The section style.
+ */
+ public AbstractFormTextSection(IManagedForm form, Composite parent, int style) {
+ this(form, parent, style, true);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param form The parent managed form. Must not be <code>null</code>.
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @param style The section style.
+ * @param titleBar If <code>true</code>, the title bar style bit is added to <code>style</code>.
+ */
+ public AbstractFormTextSection(IManagedForm form, Composite parent, int style, boolean titleBar) {
+ super(form, parent, style, titleBar);
+ getSection().setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
+ }
+
+ /* (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);
+
+ // Configure the section
+ section.setText(getSectionTitle());
+
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ }
+
+ // Create the section client
+ Composite client = toolkit.createComposite(section, SWT.NONE);
+ Assert.isNotNull(client);
+ client.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1));
+ client.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+
+ FormText text = createFormText(client, toolkit);
+ configureFormText(text);
+
+ section.setClient(client);
+
+ // Mark the control update as completed now
+ setIsUpdating(false);
+ }
+
+ /**
+ * Returns the section title.
+ *
+ * @return The section title.
+ */
+ protected abstract String getSectionTitle();
+
+ /**
+ * Returns the form text content.
+ *
+ * @return The form text content.
+ */
+ protected abstract String getFormTextContent();
+
+ /**
+ * Creates a form text control in the given parent composite with the given
+ * content and form toolkit.
+ *
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @param toolkit The toolkit. Must not be <code>null</code>.
+ *
+ * @return The form text control.
+ */
+ protected final FormText createFormText(Composite parent, FormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ // Create the form text control
+ return toolkit.createFormText(parent, true);
+ }
+
+ /**
+ * Configure the form text.
+ * <p>
+ * The default implementation is setting the form text content
+ * and adding ourself as hyper link listener. The form text
+ * content is queried through {@link #getFormTextContent()}.
+ *
+ * @param text The form text. Must not be <code>null</code>.
+ */
+ protected void configureFormText(FormText text) {
+ Assert.isNotNull(text);
+
+ // Set the content. If it fails, set the failure message
+ try {
+ text.setText(getFormTextContent(), true, false);
+ } catch (SWTException e) {
+ text.setText(e.getMessage(), false, false);
+ }
+
+ // Add ourself as hyper link listener
+ text.addHyperlinkListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ @Override
+ public void linkEntered(HyperlinkEvent e) {
+ Object container = getManagedForm().getContainer();
+ if (container instanceof IEditorPart) {
+ IStatusLineManager manager = ((IEditorPart)container).getEditorSite().getActionBars().getStatusLineManager();
+ manager.setMessage(e.getLabel());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ @Override
+ public void linkExited(HyperlinkEvent e) {
+ Object container = getManagedForm().getContainer();
+ if (container instanceof IEditorPart) {
+ IStatusLineManager manager = ((IEditorPart)container).getEditorSite().getActionBars().getStatusLineManager();
+ manager.setMessage(null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ }
+}

Back to the top