diff options
author | ustieber | 2011-05-13 09:36:03 +0000 |
---|---|---|
committer | ustieber | 2011-05-13 09:36:03 +0000 |
commit | dd01934953e1ec4b8a527bec1a297c264836702f (patch) | |
tree | 34b7b76183ce32620f6ec98d64b5968941f50bdb | |
parent | ed3a671f1c7a8420d4f778f22ecc6a806b5cbe2c (diff) | |
download | org.eclipse.tcf-dd01934953e1ec4b8a527bec1a297c264836702f.tar.gz org.eclipse.tcf-dd01934953e1ec4b8a527bec1a297c264836702f.tar.xz org.eclipse.tcf-dd01934953e1ec4b8a527bec1a297c264836702f.zip |
Target Explorer: Add common filter to hide unreachable TCF remote targets
3 files changed, 62 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties index 3d656b10a..4cb50fdbc 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties @@ -11,6 +11,10 @@ pluginName = Target Explorer, TCF UI Plug-in providerName = Eclipse.org +# ***** Filter ***** + +UnreachablePeersFilter.name=Unreachable Remote Targets (TCF) + # ***** Wizards ***** NewPeerWizard.name=TCF Remote Target diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml index 75d1ffe32..bddba4fef 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml @@ -37,6 +37,13 @@ </enablement> </commonWizard> </navigatorContent> + <commonFilter + activeByDefault="false" + class="org.eclipse.tm.te.tcf.ui.internal.filter.UnreachablePeersFilter" + id="org.eclipse.tm.te.tcf.ui.navigator.UnreachablePeersFilter" + name="%UnreachablePeersFilter.name" + visibleInUI="true"> + </commonFilter> </extension> <!-- New wizard contributions --> diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/filter/UnreachablePeersFilter.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/filter/UnreachablePeersFilter.java new file mode 100644 index 000000000..238308b39 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/filter/UnreachablePeersFilter.java @@ -0,0 +1,51 @@ +/*******************************************************************************
+ * 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:
+ * Uwe Stieber (Wind River) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.tcf.ui.internal.filter;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+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;
+
+/**
+ * Filter implementation filtering unreachable peers.
+ */
+public class UnreachablePeersFilter extends ViewerFilter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+
+ // Filter only elements of type IPeerModel
+ if (element instanceof IPeerModel) {
+ final IPeerModel peerModel = (IPeerModel)element;
+
+ // Determine the current state of the peer model
+ final int[] state = new int[1];
+ if (Protocol.isDispatchThread()) {
+ state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE);
+ } else {
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE);
+ }
+ });
+ }
+
+ return state[0] != IPeerModelProperties.STATE_NOT_REACHABLE && state[0] != IPeerModelProperties.STATE_ERROR;
+ }
+
+ return true;
+ }
+
+}
|