Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-12-19 07:37:23 -0500
committerTobias Schwarz2013-12-19 07:37:23 -0500
commit6c596f4bea584d14e80c9c9b6dc33bd6a37fd305 (patch)
tree7957e3f1a228d7ea1526c0da34a293e8793c5eaa /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf
parentf0f4baeea56babed12127580c80092fd993a963b (diff)
downloadorg.eclipse.tcf-6c596f4bea584d14e80c9c9b6dc33bd6a37fd305.tar.gz
org.eclipse.tcf-6c596f4bea584d14e80c9c9b6dc33bd6a37fd305.tar.xz
org.eclipse.tcf-6c596f4bea584d14e80c9c9b6dc33bd6a37fd305.zip
Target Explorer: selection dialogs
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerNodeSelectionDialog.java34
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java69
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java2
4 files changed, 110 insertions, 19 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 a4d487a5a..1c900d05b 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
@@ -18,6 +18,8 @@ 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.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
@@ -28,6 +30,7 @@ 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.runtime.concurrent.util.ExecutorsUtil;
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;
@@ -124,11 +127,28 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog
}
}
});
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateEnablement(viewer);
+ }
+ });
viewer.refresh();
updateEnablement(viewer);
}
+ protected void refresh() {
+ ExecutorsUtil.executeInUI(new Runnable() {
+ @Override
+ public void run() {
+ viewer.setInput(getInput());
+ viewer.refresh();
+ updateEnablement(viewer);
+ }
+ });
+ }
+
protected abstract Object[] getInput();
/* (non-Javadoc)
@@ -151,7 +171,9 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog
// Adjust the OK button enablement
Button okButton = getButton(IDialogConstants.OK_ID);
- SWTControlUtil.setEnabled(okButton, viewer.getTable().getItems().length > 0);
+ int selCount = viewer.getTable().getSelectionCount();
+ boolean selOk = supportsMultiSelection() ? selCount > 0 : selCount == 1;
+ SWTControlUtil.setEnabled(okButton, viewer.getTable().getItems().length > 0 && selOk);
}
/**
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 1b98b4bff..4121f8cf5 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
@@ -17,6 +17,8 @@ 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.IPeerModelListener;
+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.nodes.IPeerNodeProperties;
import org.eclipse.tcf.te.tcf.locator.model.ModelManager;
@@ -26,7 +28,7 @@ import org.eclipse.tcf.te.tcf.ui.nls.Messages;
/**
* Peer selection dialog implementation.
*/
-public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog {
+public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog implements IPeerModelListener {
final String[] services;
@@ -36,9 +38,7 @@ public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog {
* @param shell The shell used to view the dialog, or <code>null</code>.
*/
public PeerNodeSelectionDialog(Shell shell) {
- super(shell, IContextHelpIds.PEER_NODE_SELECTION_DIALOG);
-
- this.services = null;
+ this(shell, null);
}
/**
@@ -50,6 +50,17 @@ public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog {
super(shell, IContextHelpIds.PEER_NODE_SELECTION_DIALOG);
this.services = services;
+
+ ModelManager.getPeerModel().addListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#dispose()
+ */
+ @Override
+ protected void dispose() {
+ super.dispose();
+ ModelManager.getPeerModel().removeListener(this);
}
@Override
@@ -124,4 +135,19 @@ public class PeerNodeSelectionDialog extends AbstractArraySelectionDialog {
protected String getDefaultMessage() {
return Messages.PeerNodeSelectionDialog_message;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean)
+ */
+ @Override
+ public void modelChanged(IPeerModel model, IPeerNode peerNode, boolean added) {
+ refresh();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelDisposed(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ */
+ @Override
+ public void modelDisposed(IPeerModel model) {
+ }
}
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 e5b3b9199..962a3ebb8 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,7 +9,15 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.ui.dialogs;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.tcf.locator.interfaces.ILocatorModelListener;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
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;
@@ -17,7 +25,7 @@ import org.eclipse.tcf.te.tcf.ui.nls.Messages;
/**
* Peer selection dialog implementation.
*/
-public class PeerSelectionDialog extends AbstractArraySelectionDialog {
+public class PeerSelectionDialog extends AbstractArraySelectionDialog implements ILocatorModelListener {
/**
* Constructor.
@@ -26,40 +34,75 @@ public class PeerSelectionDialog extends AbstractArraySelectionDialog {
*/
public PeerSelectionDialog(Shell shell) {
super(shell, IContextHelpIds.PEER_SELECTION_DIALOG);
+
+ ModelManager.getLocatorModel().addListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#dispose()
+ */
+ @Override
+ protected void dispose() {
+ super.dispose();
+ ModelManager.getLocatorModel().removeListener(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#getInput()
+ */
@Override
protected Object[] getInput() {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ final ILocatorModelRefreshService service = ModelManager.getLocatorModel().getService(ILocatorModelRefreshService.class);
+ if (service != null) {
+ final Callback cb = new Callback();
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ service.refresh(cb);
+ }
+ });
+ ExecutorsUtil.waitAndExecute(0, cb.getDoneConditionTester(null));
+ }
return ModelManager.getLocatorModel().getPeers();
}
- /**
- * Returns the dialog title.
- *
- * @return The dialog title.
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#getDialogTitle()
*/
@Override
protected String getDialogTitle() {
return Messages.PeerSelectionDialog_dialogTitle;
}
- /**
- * Returns the title.
- *
- * @return The title.
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#getTitle()
*/
@Override
protected String getTitle() {
return Messages.PeerSelectionDialog_title;
}
- /**
- * Returns the default message.
- *
- * @return The default message.
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#getDefaultMessage()
*/
@Override
protected String getDefaultMessage() {
return Messages.PeerSelectionDialog_message;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.ILocatorModelListener#modelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.protocol.IPeer, boolean)
+ */
+ @Override
+ public void modelChanged(ILocatorModel model, IPeer peer, boolean added) {
+ refresh();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.ILocatorModelListener#modelDisposed(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel)
+ */
+ @Override
+ public void modelDisposed(ILocatorModel model) {
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
index ef83fcc20..1014f8cca 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
@@ -147,7 +147,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent
filtered |= isValueAdd(peer) && hideValueAdds;
filtered |= peer.getName() != null
- && peer.getName().endsWith("Command Server"); //$NON-NLS-1$
+ && (peer.getName().endsWith("Command Server") || peer.getName().endsWith("CLI Server")); //$NON-NLS-1$ //$NON-NLS-2$
return filtered;
}

Back to the top