Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-11-10 12:16:07 +0000
committerUwe Stieber2011-11-10 12:16:07 +0000
commitfbd21fbc1c6a6314d089231e9bcfa7e4c9b1d01a (patch)
tree8313cc028e1e9520c0708ec08fa30f236670c850
parent5407ffdf6ead4a83ddc5bc0132e2d37b12df735e (diff)
downloadorg.eclipse.tcf-fbd21fbc1c6a6314d089231e9bcfa7e4c9b1d01a.tar.gz
org.eclipse.tcf-fbd21fbc1c6a6314d089231e9bcfa7e4c9b1d01a.tar.xz
org.eclipse.tcf-fbd21fbc1c6a6314d089231e9bcfa7e4c9b1d01a.zip
Target Explorer: Added core agent selection dialog implementation
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/dialogs/AgentSelectionDialog.java239
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.swt/src/org/eclipse/tm/te/ui/jface/dialogs/CustomTitleAreaDialog.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/dialogs/NameValuePairDialog.java4
7 files changed, 265 insertions, 5 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/META-INF/MANIFEST.MF
index 0b5e46a8a..ddf80729d 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/META-INF/MANIFEST.MF
@@ -25,6 +25,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.tm.te.tcf.ui.activator;x-internal:=true,
+ org.eclipse.tm.te.tcf.ui.dialogs,
org.eclipse.tm.te.tcf.ui.internal;x-internal:=true,
org.eclipse.tm.te.tcf.ui.internal.editor.pages;x-internal:=true,
org.eclipse.tm.te.tcf.ui.internal.filter;x-internal:=true,
@@ -36,4 +37,5 @@ Export-Package: org.eclipse.tm.te.tcf.ui.activator;x-internal:=true,
org.eclipse.tm.te.tcf.ui.nls;x-internal:=true,
org.eclipse.tm.te.tcf.ui.tables,
org.eclipse.tm.te.tcf.ui.wizards;x-internal:=true,
+ org.eclipse.tm.te.tcf.ui.wizards.controls,
org.eclipse.tm.te.tcf.ui.wizards.pages;x-internal:=true
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/dialogs/AgentSelectionDialog.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/dialogs/AgentSelectionDialog.java
new file mode 100644
index 000000000..57dc9c3d7
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/dialogs/AgentSelectionDialog.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.tcf.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+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.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.tm.tcf.protocol.Protocol;
+import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tm.te.tcf.ui.internal.help.IContextHelpIds;
+import org.eclipse.tm.te.tcf.ui.internal.model.Model;
+import org.eclipse.tm.te.tcf.ui.internal.navigator.LabelProviderDelegate;
+import org.eclipse.tm.te.tcf.ui.nls.Messages;
+import org.eclipse.tm.te.ui.jface.dialogs.CustomTitleAreaDialog;
+import org.eclipse.tm.te.ui.swt.SWTControlUtil;
+
+/**
+ * TCF agent selection dialog implementation.
+ */
+public class AgentSelectionDialog extends CustomTitleAreaDialog {
+ // The list of remote services the agents must provide to be included
+ /* default */ final String[] services;
+
+ // The table viewer
+ private 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 <code>null</code>.
+ */
+ public AgentSelectionDialog(String[] services) {
+ this(null, services);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parent The parent shell used to view the dialog, or <code>null</code>.
+ * @param services The list of (remote) services the agents must provide to be selectable, or <code>null</code>.
+ */
+ public AgentSelectionDialog(Shell parent, String[] services) {
+ super(parent, IContextHelpIds.AGENT_SELECTION_DIALOG);
+
+ this.services = services != null && services.length > 0 ? services : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#isResizable()
+ */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite top = (Composite)super.createDialogArea(parent);
+
+ setDialogTitle(getDialogTitle());
+ setTitle(getTitle());
+ setDefaultMessage(getDefaultMessage(), IMessageProvider.NONE);
+
+ // Create the table viewer
+ viewer = new TableViewer(top, SWT.MULTI | 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());
+ LabelProviderDelegate labelProvider = new LabelProviderDelegate() {
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.tcf.ui.internal.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));
+
+ // The content to show is static. Do the filtering manually so that
+ // we can disable the OK Button if the dialog would not show any content.
+ List<IPeerModel> nodes = new ArrayList<IPeerModel>(Arrays.asList(Model.getModel().getPeers()));
+ Iterator<IPeerModel> iterator = nodes.iterator();
+ while (iterator.hasNext()) {
+ IPeerModel peerModel = iterator.next();
+ if (isFiltered(peerModel)) iterator.remove();
+ }
+
+ // Set the remaining nodes as input
+ viewer.setInput(nodes.toArray(new IPeerModel[nodes.size()]));
+
+ return top;
+ }
+
+ /* (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);
+
+ // Adjust the OK button enablement
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ SWTControlUtil.setEnabled(okButton, ((IPeerModel[])viewer.getInput()).length > 0);
+
+ return buttonBar;
+ }
+ /**
+ * Returns the dialog title.
+ *
+ * @return The dialog title.
+ */
+ protected String getDialogTitle() {
+ return Messages.AgentSelectionDialog_dialogTitle;
+ }
+
+ /**
+ * Returns the title.
+ *
+ * @return The title.
+ */
+ protected String getTitle() {
+ return Messages.AgentSelectionDialog_title;
+ }
+
+ /**
+ * Returns the default message.
+ *
+ * @return The default message.
+ */
+ protected String getDefaultMessage() {
+ return Messages.AgentSelectionDialog_message;
+ }
+
+ /**
+ * Returns if the given peer model node is filtered or not.
+ *
+ * @param peerModel The peer model node. Must not be <code>null</code>.
+ * @return
+ */
+ protected boolean isFiltered(final IPeerModel peerModel) {
+ Assert.isNotNull(peerModel);
+
+ final AtomicReference<String> remoteServices = new AtomicReference<String>();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ remoteServices.set(peerModel.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES));
+ }
+ });
+
+ boolean matchedService = false;
+ if (remoteServices.get() != null) {
+ for (String service : services) {
+ if (remoteServices.get().contains(service)) {
+ matchedService = true;
+ break;
+ }
+ }
+ }
+
+ return !matchedService;
+ }
+
+ /**
+ * 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 <code>null</code>.
+ */
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.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.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java
index f7098b75e..00e4f94e7 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java
@@ -17,20 +17,33 @@ import org.eclipse.tm.te.tcf.ui.activator.UIPlugin;
public interface IContextHelpIds {
/**
- * TCF data source UI plug-in common context help id prefix.
+ * TCF UI plug-in common context help id prefix.
*/
public final static String PREFIX = UIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
+ // ***** Wizards and Wizard Pages *****
+
/**
* New TCF target wizard main page.
*/
public final static String NEW_TARGET_WIZARD_PAGE = PREFIX + "NewTargetWizardPage"; //$NON-NLS-1$
+ // ***** Editors and Editor Pages *****
+
/**
* Target Explorer details editor page: Node properties
*/
public final static String NODE_PROPERTIES_EDITOR_PAGE = PREFIX + "NodePropertiesEditorPage"; //$NON-NLS-1$
+ // ***** Dialogs and Dialog Pages *****
+
+ /**
+ * TCF agent selection dialog.
+ */
+ public final static String AGENT_SELECTION_DIALOG = PREFIX + "AgentSelectionDialog"; //$NON-NLS-1$
+
+ // ***** Message dialog boxes *****
+
/**
* Delete command handler: Delete operation failed.
*/
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.java
index d0ea309b3..81279c0c5 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.java
@@ -129,4 +129,8 @@ public class Messages extends NLS {
public static String DeleteCommandHandler_error_title;
public static String DeleteCommandHandler_error_deleteFailed;
+
+ public static String AgentSelectionDialog_dialogTitle;
+ public static String AgentSelectionDialog_title;
+ public static String AgentSelectionDialog_message;
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.properties
index 935e88316..c2d6912cc 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/nls/Messages.properties
@@ -63,3 +63,7 @@ PeerAttributesTablePart_edit_message=Edit the selected peer attribute.
DeleteCommandHandler_error_title=Error
DeleteCommandHandler_error_deleteFailed=Failed to delete static peer.
+
+AgentSelectionDialog_dialogTitle=Select Agent(s)
+AgentSelectionDialog_title=Select Agent(s)
+AgentSelectionDialog_message=Select the agent(s) for the operation to perform.
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.swt/src/org/eclipse/tm/te/ui/jface/dialogs/CustomTitleAreaDialog.java b/target_explorer/plugins/org.eclipse.tm.te.ui.swt/src/org/eclipse/tm/te/ui/jface/dialogs/CustomTitleAreaDialog.java
index d2c080070..3dc62a72a 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.swt/src/org/eclipse/tm/te/ui/jface/dialogs/CustomTitleAreaDialog.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.swt/src/org/eclipse/tm/te/ui/jface/dialogs/CustomTitleAreaDialog.java
@@ -57,7 +57,7 @@ public class CustomTitleAreaDialog extends TitleAreaDialog implements IMessagePr
/**
* Constructor.
*
- * @param parent The parent shell used to view the dialog.
+ * @param parent The parent shell used to view the dialog, or <code>null</code>.
* @param contextHelpId The dialog context help id or <code>null</code>.
*/
public CustomTitleAreaDialog(Shell parent, String contextHelpId) {
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/dialogs/NameValuePairDialog.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/dialogs/NameValuePairDialog.java
index 178129bf5..4ce423367 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/dialogs/NameValuePairDialog.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/dialogs/NameValuePairDialog.java
@@ -29,7 +29,6 @@ import org.eclipse.tm.te.ui.interfaces.IContextHelpIds;
import org.eclipse.tm.te.ui.jface.dialogs.CustomTitleAreaDialog;
import org.eclipse.tm.te.ui.nls.Messages;
import org.eclipse.tm.te.ui.swt.SWTControlUtil;
-import org.eclipse.ui.PlatformUI;
/**
* Dialog implementation allowing to enter the data for name/value pairs.
@@ -61,7 +60,7 @@ public class NameValuePairDialog extends CustomTitleAreaDialog {
* @param usedNames The list of used names. Must not be <code>null</code>.
*/
public NameValuePairDialog(Shell shell, String dialogTitle, String title, String message, String[] fieldLabels, String[] initialValues, Set<String> usedNames) {
- super(shell);
+ super(shell, IContextHelpIds.NAME_VALUE_PAIR_DIALOG);
Assert.isNotNull(dialogTitle);
Assert.isNotNull(title);
@@ -84,7 +83,6 @@ public class NameValuePairDialog extends CustomTitleAreaDialog {
@Override
protected Control createDialogArea(Composite parent) {
Composite top = (Composite)super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(top, IContextHelpIds.NAME_VALUE_PAIR_DIALOG);
setDialogTitle(dialogTitle);
setTitle(title);

Back to the top