From 7fb8b83faf758f57321cbb70b52b813abe69aa69 Mon Sep 17 00:00:00 2001 From: Tobias Schwarz Date: Wed, 18 Dec 2013 14:56:42 +0100 Subject: Target Explorer: peer and peer ndoe selection dialogs --- .../ui/actions/AbstractPeerTypeToolbarAction.java | 21 +- .../tcf/te/tcf/ui/actions/ToolbarAction.java | 8 - .../ui/dialogs/AbstractArraySelectionDialog.java | 218 +++++++++++++++++++ .../te/tcf/ui/dialogs/PeerNodeSelectionDialog.java | 127 +++++++++++ .../tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java | 231 ++------------------- .../ui/dialogs/RedirectPeerSelectionDialog.java | 71 ------- .../tcf/te/tcf/ui/help/IContextHelpIds.java | 9 +- .../org/eclipse/tcf/te/tcf/ui/nls/Messages.java | 11 +- .../eclipse/tcf/te/tcf/ui/nls/Messages.properties | 11 +- .../ui/sections/SimulatorTypeSelectionSection.java | 7 +- 10 files changed, 386 insertions(+), 328 deletions(-) create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf') diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java index f8535aa55..313d6c3fb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java @@ -25,7 +25,6 @@ import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; @@ -44,10 +43,9 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.ModelManager; -import org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog; +import org.eclipse.tcf.te.tcf.ui.dialogs.PeerNodeSelectionDialog; import org.eclipse.tcf.te.ui.views.editor.EditorInput; import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; -import org.eclipse.tcf.te.ui.views.navigator.ViewerSorter; import org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardRegistry; import org.eclipse.ui.IActionDelegate2; import org.eclipse.ui.IEditorInput; @@ -89,7 +87,6 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA protected abstract ImageDescriptor getSelectExistingActionImageDescriptor(); protected abstract String getSelectExistingDialogTitle(); protected abstract String getSelectExistingDialogDescription(); - protected abstract String getSelectExistingDialogReachableOnlyLabel(); protected abstract ViewerFilter getSelectExistingDialogViewerFilter(); /* (non-Javadoc) @@ -283,7 +280,7 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA // Get the active page IWorkbenchPage page = window.getActivePage(); // Create the agent selection dialog - PeerSelectionDialog dialog = new PeerSelectionDialog(null) { + PeerNodeSelectionDialog dialog = new PeerNodeSelectionDialog(null) { @Override protected String getTitle() { return getSelectExistingDialogTitle(); @@ -293,18 +290,8 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA return getSelectExistingDialogDescription(); } @Override - protected String getShowOnlyReachableLabel() { - return getSelectExistingDialogReachableOnlyLabel(); - } - @Override - protected boolean supportsMultiSelection() { - return false; - } - @Override - protected void configureTableViewer(TableViewer viewer) { - super.configureTableViewer(viewer); - viewer.addFilter(getSelectExistingDialogViewerFilter()); - viewer.setSorter(new ViewerSorter()); + protected String getType() { + return getPeerTypeId(); } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java index 03357c335..02353c780 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java @@ -64,14 +64,6 @@ public class ToolbarAction extends AbstractPeerTypeToolbarAction { return Messages.ToolbarAction_selectionDialog_description; } - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingDialogReachableOnlyLabel() - */ - @Override - protected String getSelectExistingDialogReachableOnlyLabel() { - return Messages.ToolbarAction_selectionDialog_button_showOnlyReachable; - } - /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingDialogViewerFilter() */ 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 new file mode 100644 index 000000000..a4d487a5a --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java @@ -0,0 +1,218 @@ +/******************************************************************************* + * Copyright (c) 2011, 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.tcf.ui.dialogs; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +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.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog; +import org.eclipse.tcf.te.ui.swt.SWTControlUtil; +import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; +import org.eclipse.tcf.te.ui.views.navigator.ViewerSorter; + +/** + * Selection dialog implementation. + */ +public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog { + // The table viewer + /* default */ TableViewer viewer; + + // The selection. Will be filled in if "OK" is pressed + private ISelection selection; + + /** + * Constructor. + * + * @param parent The parent shell used to view the dialog, or null. + * @param services The list of (remote) services the agents must provide to be selectable, or null. + */ + public AbstractArraySelectionDialog(Shell shell, String contextHelpId) { + super(shell, contextHelpId); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#isResizable() + */ + @Override + protected boolean isResizable() { + return true; + } + + /** + * Returns whether the dialog shall support multi selection or not. + *

+ * The default implementation returns true. + * + * @return True if multi selection is supported, false otherwise. + */ + protected boolean supportsMultiSelection() { + return false; + } + + /** + * Returns the table viewer instance. + * + * @return The table viewer instance or null. + */ + protected final TableViewer getViewer() { + return viewer; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite) + */ + @Override + protected void createDialogAreaContent(Composite parent) { + super.createDialogAreaContent(parent); + + setDialogTitle(getDialogTitle()); + setTitle(getTitle()); + setDefaultMessage(getDefaultMessage(), IMessageProvider.NONE); + + // Create the table viewer + viewer = new TableViewer(parent, (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); + + // Configure the table + Table table = viewer.getTable(); + + @SuppressWarnings("unused") + TableColumn column = new TableColumn(table, SWT.LEFT); + + 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); + + viewer.setContentProvider(new ArrayContentProvider()); + DelegatingLabelProvider labelProvider = new DelegatingLabelProvider(); + viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider)); + + // Subclasses may customize the viewer before setting the input + configureTableViewer(viewer); + + viewer.setInput(getInput()); + viewer.addDoubleClickListener(new IDoubleClickListener() { + @Override + public void doubleClick(DoubleClickEvent event) { + if (!viewer.getSelection().isEmpty()) { + okPressed(); + } + } + }); + + viewer.refresh(); + updateEnablement(viewer); + } + + protected abstract Object[] getInput(); + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createButtonBar(Composite parent) { + Control buttonBar = super.createButtonBar(parent); + updateEnablement(viewer); + return buttonBar; + } + + /** + * Update the enablement of the dialog widgets. + * + * @param viewer The table viewer. Must not be null. + */ + protected void updateEnablement(TableViewer viewer) { + Assert.isNotNull(viewer); + + // Adjust the OK button enablement + Button okButton = getButton(IDialogConstants.OK_ID); + SWTControlUtil.setEnabled(okButton, viewer.getTable().getItems().length > 0); + } + + /** + * Configure the table viewer. + *

+ * The default implementation does nothing. Subclasses may overwrite this + * method to customize the table viewer before the input gets set. + * + * @param viewer The table viewer. Must not be null. + */ + protected void configureTableViewer(TableViewer viewer) { + Assert.isNotNull(viewer); + viewer.setSorter(new ViewerSorter()); + } + + /** + * Returns the dialog title. + * + * @return The dialog title. + */ + protected abstract String getDialogTitle(); + + /** + * Returns the title. + * + * @return The title. + */ + protected abstract String getTitle(); + + /** + * Returns the default message. + * + * @return The default message. + */ + protected abstract String getDefaultMessage(); + + /** + * Returns the selection which had been set to the viewer at + * the time of closing the dialog with either "OK" or "Cancel". + * + * @return The selection or null. + */ + public ISelection getSelection() { + return selection; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#okPressed() + */ + @Override + protected void okPressed() { + selection = viewer.getSelection(); + super.okPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + @Override + protected void cancelPressed() { + selection = null; + super.cancelPressed(); + } +} 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 new file mode 100644 index 000000000..1b98b4bff --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2011, 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.tcf.ui.dialogs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.swt.widgets.Shell; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.model.ModelManager; +import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; +import org.eclipse.tcf.te.tcf.ui.nls.Messages; + +/** + * Peer selection dialog implementation. + */ +public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog { + + final String[] services; + + /** + * Constructor. + * + * @param shell The shell used to view the dialog, or null. + */ + public PeerNodeSelectionDialog(Shell shell) { + super(shell, IContextHelpIds.PEER_NODE_SELECTION_DIALOG); + + this.services = null; + } + + /** + * Constructor. + * + * @param shell The shell used to view the dialog, or null. + */ + public PeerNodeSelectionDialog(Shell shell, String[] services) { + super(shell, IContextHelpIds.PEER_NODE_SELECTION_DIALOG); + + this.services = services; + } + + @Override + protected Object[] getInput() { + List peerNodes = new ArrayList(); + for (final IPeerNode peerNode : ModelManager.getPeerModel().getPeerNodes()) { + if (getType() == null || getType().equals(peerNode.getPeerType())) { + if (services != null && services.length > 0) { + final AtomicBoolean hasServices = new AtomicBoolean(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + String offlineServices = peerNode.getStringProperty(IPeerNodeProperties.PROP_OFFLINE_SERVICES); + String remoteServices = peerNode.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES); + List offline = offlineServices != null ? Arrays.asList(offlineServices.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$ + List remote = remoteServices != null ? Arrays.asList(remoteServices.split(",\\s*")) : null; //$NON-NLS-1$ + boolean hasOfflineService = true; + for (String service : services) { + hasOfflineService &= (remote == null) ? offline.contains(service) : remote.contains(service); + if (!hasOfflineService) { + break; + } + } + hasServices.set(hasOfflineService); + } + }); + if (!hasServices.get()) { + continue; + } + } + peerNodes.add(peerNode); + } + } + + return peerNodes.toArray(); + } + + /** + * Get the peer node type to filter. + * @return The peer type id or null for all peer nodes. + */ + protected String getType() { + return null; + } + + /** + * Returns the dialog title. + * + * @return The dialog title. + */ + @Override + protected String getDialogTitle() { + return Messages.PeerNodeSelectionDialog_dialogTitle; + } + + /** + * Returns the title. + * + * @return The title. + */ + @Override + protected String getTitle() { + return Messages.PeerNodeSelectionDialog_title; + } + + /** + * Returns the default message. + * + * @return The default message. + */ + @Override + protected String getDefaultMessage() { + return Messages.PeerNodeSelectionDialog_message; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java index 9898b03a7..e5b3b9199 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java @@ -9,194 +9,28 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.ui.dialogs; -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -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.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.model.ModelManager; import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.nls.Messages; -import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog; -import org.eclipse.tcf.te.ui.swt.SWTControlUtil; -import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; /** - * TCF agent selection dialog implementation. + * Peer selection dialog implementation. */ -public class PeerSelectionDialog extends CustomTitleAreaDialog { - // The list of remote services the agents must provide to be included - /* default */ final String[] services; - - // The table viewer - /* default */ TableViewer viewer; - - // The selection. Will be filled in if either "OK" or "Cancel" is pressed - private ISelection selection; - - /** - * Constructor. - * - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public PeerSelectionDialog(String[] services) { - this(null, services); - } +public class PeerSelectionDialog extends AbstractArraySelectionDialog { /** * Constructor. * - * @param parent The parent shell used to view the dialog, or null. - * @param services The list of (remote) services the agents must provide to be selectable, or null. + * @param shell The shell used to view the dialog, or null. */ - public PeerSelectionDialog(Shell parent, String[] services) { - super(parent, IContextHelpIds.AGENT_SELECTION_DIALOG); - - this.services = services != null && services.length > 0 ? services : null; + public PeerSelectionDialog(Shell shell) { + super(shell, IContextHelpIds.PEER_SELECTION_DIALOG); } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#isResizable() - */ @Override - protected boolean isResizable() { - return true; - } - - /** - * Returns whether the dialog shall support multi selection or not. - *

- * The default implementation returns true. - * - * @return True if multi selection is supported, false otherwise. - */ - protected boolean supportsMultiSelection() { - return true; - } - - /** - * Returns the table viewer instance. - * - * @return The table viewer instance or null. - */ - protected final TableViewer getViewer() { - return viewer; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite) - */ - @Override - protected void createDialogAreaContent(Composite parent) { - super.createDialogAreaContent(parent); - - setDialogTitle(getDialogTitle()); - setTitle(getTitle()); - setDefaultMessage(getDefaultMessage(), IMessageProvider.NONE); - - // Create the table viewer - viewer = new TableViewer(parent, (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); - - // Configure the table - Table table = viewer.getTable(); - - @SuppressWarnings("unused") - TableColumn column = new TableColumn(table, SWT.LEFT); - - 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); - - viewer.setContentProvider(new ArrayContentProvider()); - DelegatingLabelProvider labelProvider = new DelegatingLabelProvider() { - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) - */ - @Override - public Image decorateImage(Image image, Object element) { - return image; - } - }; - viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider)); - - // Subclasses may customize the viewer before setting the input - configureTableViewer(viewer); - - viewer.setInput(ModelManager.getLocatorModel().getPeers()); - viewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - if (!viewer.getSelection().isEmpty()) { - okPressed(); - } - } - }); - - viewer.refresh(); - updateEnablement(viewer); - } - - /** - * Returns the label of the "Show only reachable targets" filter button. - * - * @return The label. - */ - protected String getShowOnlyReachableLabel() { - return Messages.AgentSelectionDialog_button_showOnlyReachable; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createButtonBar(Composite parent) { - Control buttonBar = super.createButtonBar(parent); - updateEnablement(viewer); - return buttonBar; - } - - /** - * Update the enablement of the dialog widgets. - * - * @param viewer The table viewer. Must not be null. - */ - protected void updateEnablement(TableViewer viewer) { - Assert.isNotNull(viewer); - - // Adjust the OK button enablement - Button okButton = getButton(IDialogConstants.OK_ID); - SWTControlUtil.setEnabled(okButton, viewer.getTable().getItems().length > 0); - } - - /** - * Configure the table viewer. - *

- * The default implementation does nothing. Subclasses may overwrite this - * method to customize the table viewer before the input gets set. - * - * @param viewer The table viewer. Must not be null. - */ - protected void configureTableViewer(TableViewer viewer) { - Assert.isNotNull(viewer); + protected Object[] getInput() { + return ModelManager.getLocatorModel().getPeers(); } /** @@ -204,8 +38,9 @@ public class PeerSelectionDialog extends CustomTitleAreaDialog { * * @return The dialog title. */ - protected String getDialogTitle() { - return Messages.AgentSelectionDialog_dialogTitle; + @Override + protected String getDialogTitle() { + return Messages.PeerSelectionDialog_dialogTitle; } /** @@ -213,8 +48,9 @@ public class PeerSelectionDialog extends CustomTitleAreaDialog { * * @return The title. */ - protected String getTitle() { - return Messages.AgentSelectionDialog_title; + @Override + protected String getTitle() { + return Messages.PeerSelectionDialog_title; } /** @@ -222,45 +58,8 @@ public class PeerSelectionDialog extends CustomTitleAreaDialog { * * @return The default message. */ - protected String getDefaultMessage() { - return Messages.AgentSelectionDialog_message; - } - - /** - * Returns the locator model instance to use for determining - * the dialogs input. - * - * @return The locator model instance. - */ - protected IPeerModel getModel() { - return ModelManager.getPeerModel(); - } - - /** - * Returns the selection which had been set to the viewer at - * the time of closing the dialog with either "OK" or "Cancel". - * - * @return The selection or null. - */ - public ISelection getSelection() { - return selection; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#okPressed() - */ - @Override - protected void okPressed() { - selection = viewer.getSelection(); - super.okPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() - */ @Override - protected void cancelPressed() { - selection = null; - super.cancelPressed(); + protected String getDefaultMessage() { + return Messages.PeerSelectionDialog_message; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java deleted file mode 100644 index fb3c1125b..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.dialogs; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.tcf.te.tcf.ui.nls.Messages; - - -/** - * Agent selection dialog implementation to choose the proxy to redirect the communication through. - */ -public class RedirectPeerSelectionDialog extends PeerSelectionDialog { - - /** - * Constructor. - * - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public RedirectPeerSelectionDialog(String[] services) { - super(services); - } - - /** - * Constructor. - * - * @param parent The parent shell used to view the dialog, or null. - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public RedirectPeerSelectionDialog(Shell parent, String[] services) { - super(parent, services); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#getDialogTitle() - */ - @Override - protected String getDialogTitle() { - return Messages.RedirectAgentSelectionDialog_dialogTitle; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#getTitle() - */ - @Override - protected String getTitle() { - return Messages.RedirectAgentSelectionDialog_title; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#getDefaultMessage() - */ - @Override - protected String getDefaultMessage() { - return Messages.RedirectAgentSelectionDialog_message; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#supportsMultiSelection() - */ - @Override - protected boolean supportsMultiSelection() { - return false; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java index 4869fb75b..257c7bacb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java @@ -43,9 +43,14 @@ public interface IContextHelpIds { // ***** Dialogs and Dialog Pages ***** /** - * TCF agent selection dialog. + * Peer selection dialog. */ - public final static String AGENT_SELECTION_DIALOG = PREFIX + "PeerSelectionDialog"; //$NON-NLS-1$ + public final static String PEER_SELECTION_DIALOG = PREFIX + "PeerSelectionDialog"; //$NON-NLS-1$ + + /** + * Peer node selection dialog. + */ + public final static String PEER_NODE_SELECTION_DIALOG = PREFIX + "PeerNodeSelectionDialog"; //$NON-NLS-1$ // ***** Message dialog boxes ***** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java index d473cfca1..bde661eba 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java @@ -150,10 +150,13 @@ public class Messages extends NLS { public static String DeleteHandlerDelegate_MsgDeleteOnePeer; - public static String AgentSelectionDialog_dialogTitle; - public static String AgentSelectionDialog_title; - public static String AgentSelectionDialog_message; - public static String AgentSelectionDialog_button_showOnlyReachable; + public static String PeerSelectionDialog_dialogTitle; + public static String PeerSelectionDialog_title; + public static String PeerSelectionDialog_message; + + public static String PeerNodeSelectionDialog_dialogTitle; + public static String PeerNodeSelectionDialog_title; + public static String PeerNodeSelectionDialog_message; public static String RedirectHandler_error_title; public static String RedirectHandler_error_redirectFailed; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties index 1b96b383f..7040ca8d6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties @@ -106,10 +106,13 @@ DeleteHandlerDelegate_DialogTitle=Confirm Delete DeleteHandlerDelegate_MsgDeleteMultiplePeers=Are you sure you want to delete these {0} targets? DeleteHandlerDelegate_MsgDeleteOnePeer=Are you sure you want to delete target ''{0}''? -AgentSelectionDialog_dialogTitle=Select Agent(s) -AgentSelectionDialog_title=Select Agent(s) -AgentSelectionDialog_message=Select the agent(s) for the operation to perform. -AgentSelectionDialog_button_showOnlyReachable=Show only reachable targets +PeerSelectionDialog_dialogTitle=Select +PeerSelectionDialog_title=Select Peer +PeerSelectionDialog_message=Select the discovered peer for the operation to perform. + +PeerNodeSelectionDialog_dialogTitle=Select +PeerNodeSelectionDialog_title=Select Configuration +PeerNodeSelectionDialog_message=Select the configuration for the operation to perform. RedirectHandler_error_title=Error RedirectHandler_error_redirectFailed=Failed to redirect target communication. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java index bcc6713f9..8f73ac015 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java @@ -154,12 +154,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } @Override protected void onButtonControlSelected() { - PeerSelectionDialog dialog = new PeerSelectionDialog(null) { - @Override - protected boolean supportsMultiSelection() { - return false; - } - }; + PeerSelectionDialog dialog = new PeerSelectionDialog(null); // Open the dialog if (dialog.open() == Window.OK) { -- cgit v1.2.3