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
parentf0f4baeea56babed12127580c80092fd993a963b (diff)
downloadorg.eclipse.tcf-6c596f4bea584d14e80c9c9b6dc33bd6a37fd305.tar.gz
org.eclipse.tcf-6c596f4bea584d14e80c9c9b6dc33bd6a37fd305.tar.xz
org.eclipse.tcf-6c596f4bea584d14e80c9c9b6dc33bd6a37fd305.zip
Target Explorer: selection dialogs
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java26
-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
8 files changed, 137 insertions, 24 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java
index 8df69f05a..29752ac10 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java
@@ -56,7 +56,7 @@ public final class LocatorListener implements ILocator.LocatorListener {
filtered |= isValueAdd && 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;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
index c8db50492..bc7c13977 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
@@ -76,7 +76,6 @@ public class LocatorModel extends PlatformObject implements ILocatorModel {
@Override
public void addListener(ILocatorModelListener listener) {
Assert.isNotNull(listener);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
CoreBundleActivator.getTraceHandler().trace("PeerModel.addListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
@@ -91,7 +90,6 @@ public class LocatorModel extends PlatformObject implements ILocatorModel {
@Override
public void removeListener(ILocatorModelListener listener) {
Assert.isNotNull(listener);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
CoreBundleActivator.getTraceHandler().trace("PeerModel.removeListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java
index 6c5943ae0..de46a28bb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java
@@ -75,7 +75,6 @@ public class PeerModel extends PlatformObject implements IPeerModel {
@Override
public void addListener(IPeerModelListener listener) {
Assert.isNotNull(listener);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_PEER_MODEL)) {
CoreBundleActivator.getTraceHandler().trace("PeerModel.addListener( " + listener + " )", ITracing.ID_TRACE_PEER_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
@@ -90,7 +89,6 @@ public class PeerModel extends PlatformObject implements IPeerModel {
@Override
public void removeListener(IPeerModelListener listener) {
Assert.isNotNull(listener);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_PEER_MODEL)) {
CoreBundleActivator.getTraceHandler().trace("PeerModel.removeListener( " + listener + " )", ITracing.ID_TRACE_PEER_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
index 399e15ad8..8d0a59ee1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
@@ -21,6 +21,7 @@ import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
@@ -106,6 +107,8 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
for (Entry<String, IPeer> entry : peers.entrySet()) {
// Get the peer instance for the current peer id
IPeer peer = entry.getValue();
+
+ if (isFiltered(peer)) continue;
// Try to find an existing peer node first
IPeer lkupPeer = model.getService(ILocatorModelLookupService.class).lkupPeerById(entry.getKey());
// And create a new one if we cannot find it
@@ -123,4 +126,27 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
}
}
+
+ /**
+ * Returns if or if not the given peer is filtered.
+ *
+ * @param peer The peer or <code>null</code>.
+ * @return <code>True</code> if the given peer is filtered, <code>false</code> otherwise.
+ */
+ private boolean isFiltered(IPeer peer) {
+ boolean filtered = peer == null;
+ boolean hideValueAdds = CoreBundleActivator.getScopedPreferences().getBoolean(org.eclipse.tcf.te.tcf.locator.interfaces.preferences.IPreferenceKeys.PREF_HIDE_VALUEADDS);
+
+ if (!filtered) {
+ String value = peer.getAttributes().get("ValueAdd"); //$NON-NLS-1$
+ boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$
+
+ filtered |= isValueAdd && hideValueAdds;
+
+ filtered |= peer.getName() != null
+ && (peer.getName().endsWith("Command Server") || peer.getName().endsWith("CLI Server")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return filtered;
+ }
}
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