diff options
author | Tobias Schwarz | 2014-09-26 06:33:29 +0000 |
---|---|---|
committer | Tobias Schwarz | 2014-09-26 06:36:10 +0000 |
commit | 03f197f4c84e04abda2f87944263c28f1b0c5eae (patch) | |
tree | bcb479194ac9f897abddada75d0ae8844d3529b7 /target_explorer | |
parent | 2a9756bbec339ce386c58a7ec24ac9aba5684ece (diff) | |
download | org.eclipse.tcf-03f197f4c84e04abda2f87944263c28f1b0c5eae.tar.gz org.eclipse.tcf-03f197f4c84e04abda2f87944263c28f1b0c5eae.tar.xz org.eclipse.tcf-03f197f4c84e04abda2f87944263c28f1b0c5eae.zip |
Target Explorer: rework selection dialogs
Diffstat (limited to 'target_explorer')
5 files changed, 97 insertions, 57 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java index 938c829e7..61c145338 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java @@ -26,7 +26,10 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; 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; @@ -98,23 +101,45 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog setTitle(getTitle()); setDefaultMessage(getDefaultMessage(), IMessageProvider.NONE); - // Create the table viewer - viewer = new TableViewer(parent, (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); + Composite comp = new Composite(parent, SWT.NONE); + GridLayout gl = new GridLayout(2, false); + gl.marginWidth = 0; + gl.marginHeight = 0; + comp.setLayout(gl); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + comp.setLayoutData(gd); + + createTableAreaContent(comp); + createButtonAreaContent(comp); + } + + protected int getTableViewerStyle() { + return (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL; + } + + protected TableViewer createTableAreaContent(Composite parent) { + // Create the tree viewer + viewer = new TableViewer(parent, getTableViewerStyle()); // Configure the table - Table table = viewer.getTable(); + final Table table = viewer.getTable(); + TableLayout tl = new TableLayout(); + tl.addColumnData(new ColumnWeightData(100)); + table.setLayout(tl); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + table.setLayoutData(gd); - @SuppressWarnings("unused") - TableColumn column = new TableColumn(table, SWT.LEFT); + final TableColumn column = new TableColumn(table, SWT.LEFT); ColumnViewerToolTipSupport.enableFor(viewer); - TableLayout tableLayout = new TableLayout(); - tableLayout.addColumnData(new ColumnWeightData(100)); - table.setLayout(tableLayout); - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - table.setLayoutData(layoutData); + table.addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent e) { + column.setWidth(Math.max(200, table.getBounds().width - table.getBorderWidth()*2)); + } + }); viewer.setContentProvider(getContentProvider()); viewer.setLabelProvider(getLabelProvider()); @@ -126,9 +151,7 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { - if (!viewer.getSelection().isEmpty()) { - okPressed(); - } + onDoubleClick(); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @@ -139,8 +162,19 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog }); viewer.refresh(); + updateSelection(getSelection()); + + return viewer; } + protected void onDoubleClick() { + if (!viewer.getSelection().isEmpty()) { + okPressed(); + } + } + + protected abstract void updateSelection(ISelection selection); + protected IContentProvider getContentProvider() { return new ArrayContentProvider(); } @@ -161,7 +195,9 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog }); } - protected abstract Object[] getInput(); + protected abstract Object getInput(); + + protected abstract void createButtonAreaContent(Composite parent); /* (non-Javadoc) * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractTreeSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractTreeSelectionDialog.java index cd44a82c3..485c5ae0f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractTreeSelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractTreeSelectionDialog.java @@ -37,6 +37,7 @@ import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil; import org.eclipse.tcf.te.tcf.ui.navigator.ViewerSorter; import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; +import org.eclipse.tcf.te.ui.trees.TreeArrayContentProvider; import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; /** @@ -110,12 +111,16 @@ public abstract class AbstractTreeSelectionDialog extends CustomTitleAreaDialog createButtonAreaContent(comp); } + protected int getTreeViewerStyle() { + return (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER; + } + protected TreeViewer createTreeAreaContent(Composite parent) { // Create the tree viewer - viewer = new TreeViewer(parent, (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); + viewer = new TreeViewer(parent, getTreeViewerStyle()); // Configure the tree - Tree tree = viewer.getTree(); + final Tree tree = viewer.getTree(); @SuppressWarnings("unused") TreeColumn column = new TreeColumn(tree, SWT.LEFT); @@ -141,9 +146,7 @@ public abstract class AbstractTreeSelectionDialog extends CustomTitleAreaDialog viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { - if (!viewer.getSelection().isEmpty()) { - okPressed(); - } + onDoubleClick(); } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @@ -159,11 +162,19 @@ public abstract class AbstractTreeSelectionDialog extends CustomTitleAreaDialog return viewer; } + protected void onDoubleClick() { + if (!viewer.getSelection().isEmpty()) { + okPressed(); + } + } + protected abstract void updateSelection(ISelection selection); protected abstract void createButtonAreaContent(Composite parent); - protected abstract IContentProvider getContentProvider(); + protected IContentProvider getContentProvider() { + return new TreeArrayContentProvider(); + } protected IBaseLabelProvider getLabelProvider() { DelegatingLabelProvider labelProvider = new DelegatingLabelProvider(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java index c224ad75a..e4f7fdaa5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java @@ -372,4 +372,18 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { return Messages.ActionHistorySelectionDialog_message; } + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#updateSelection(org.eclipse.jface.viewers.ISelection) + */ + @Override + protected void updateSelection(ISelection selection) { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#createButtonAreaContent(org.eclipse.swt.widgets.Composite) + */ + @Override + protected void createButtonAreaContent(Composite parent) { + } + } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java index e75b8879e..5abf99974 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java @@ -15,6 +15,8 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener; @@ -150,4 +152,18 @@ public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog implem @Override public void modelDisposed(IPeerModel model) { } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#updateSelection(org.eclipse.jface.viewers.ISelection) + */ + @Override + protected void updateSelection(ISelection selection) { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#createButtonAreaContent(org.eclipse.swt.widgets.Composite) + */ + @Override + protected void createButtonAreaContent(Composite parent) { + } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/TargetPathValidator.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/TargetPathValidator.java deleted file mode 100644 index f95861895..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/TargetPathValidator.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -package org.eclipse.tcf.te.ui.controls.validator; - -import org.eclipse.tcf.te.ui.controls.nls.Messages; - -/** - * TargetPathValidator - */ -public class TargetPathValidator extends RegexValidator { - - public static final int ATTR_MULTIPLE = 4; - - protected static final String TARGET_PATH_SEGMENT_REGEX = "[^;?* /\\\\]+"; //$NON-NLS-1$ - protected static final String TARGET_PATH_REGEX = "(/?(" + TARGET_PATH_SEGMENT_REGEX + "))(/(" + TARGET_PATH_SEGMENT_REGEX + "))*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - protected static final String TARGET_PATH_MULTIPLE_REGEX = TARGET_PATH_REGEX + "/?([ ]*;[ ]*" + TARGET_PATH_REGEX + "/?)*"; //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * Constructor. - * @param attributes - * @param regex - */ - public TargetPathValidator(int attributes) { - super(attributes, isAttribute(ATTR_MULTIPLE, attributes) ? TARGET_PATH_MULTIPLE_REGEX : TARGET_PATH_REGEX); - setMessageText(INFO_MISSING_VALUE, Messages.TargetPathValidator_Information_MissingTargetPath); - setMessageText(ERROR_INVALID_VALUE, Messages.TargetPathValidator_Error_InvalidTargetPath); - } -} |