Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java61
1 files changed, 42 insertions, 19 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java
index ea74b2396..1d0605d95 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java
@@ -47,12 +47,20 @@ public class PeerModelPropertyTester extends PropertyTester {
final IPeerNode peerNode = (IPeerNode)receiver;
final AtomicBoolean result = new AtomicBoolean();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- result.set(testPeerModel(peerNode, property, args, expectedValue));
- }
- });
+ if ("isValid".equals(property) || //$NON-NLS-1$
+ "hasOfflineService".equals(property) || //$NON-NLS-1$
+ "hasRemoteService".equals(property) || //$NON-NLS-1$
+ "hasLocalService".equals(property)) { //$NON-NLS-1$
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result.set(testPeerModel(peerNode, property, args, expectedValue));
+ }
+ });
+ }
+ else {
+ result.set(testPeer(peerNode.getPeer(), property, args, expectedValue));
+ }
return result.get();
}
@@ -70,11 +78,8 @@ public class PeerModelPropertyTester extends PropertyTester {
* @return <code>True</code> if the property to test has the expected value, <code>false</code>
* otherwise.
*/
- protected boolean testPeerModel(IPeerNode peerNode, String property, Object[] args, Object expectedValue) {
- Assert.isNotNull(peerNode);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- IPeer peer = peerNode.getPeer();
+ protected boolean testPeer(IPeer peer, String property, Object[] args, Object expectedValue) {
+ Assert.isNotNull(peer);
if ("name".equals(property)) { //$NON-NLS-1$
if (peer.getName() != null && peer.getName().equals(expectedValue)) {
@@ -107,13 +112,6 @@ public class PeerModelPropertyTester extends PropertyTester {
}
}
- if ("isValid".equals(property)) { //$NON-NLS-1$
- boolean isValid = peerNode.isValid();
- if (expectedValue instanceof Boolean) {
- return ((Boolean) expectedValue).booleanValue() == isValid;
- }
- }
-
if ("isValueAdd".equals(property)) { //$NON-NLS-1$
String value = peer.getAttributes().get("ValueAdd"); //$NON-NLS-1$
boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$
@@ -171,8 +169,33 @@ public class PeerModelPropertyTester extends PropertyTester {
}
}
+ return false;
+ }
+
+ /**
+ * Test the specific peer model node properties.
+ *
+ * @param node The model node. Must not be <code>null</code>.
+ * @param property The property to test.
+ * @param args The property arguments.
+ * @param expectedValue The expected value.
+ *
+ * @return <code>True</code> if the property to test has the expected value, <code>false</code>
+ * otherwise.
+ */
+ protected boolean testPeerModel(IPeerNode peerNode, String property, Object[] args, Object expectedValue) {
+ Assert.isNotNull(peerNode);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if ("isValid".equals(property)) { //$NON-NLS-1$
+ boolean isValid = peerNode.isValid();
+ if (expectedValue instanceof Boolean) {
+ return ((Boolean) expectedValue).booleanValue() == isValid;
+ }
+ }
+
if ("hasOfflineService".equals(property)) { //$NON-NLS-1$
- String offlineServices = peer.getAttributes().get(IPeerProperties.PROP_OFFLINE_SERVICES);
+ String offlineServices = peerNode.getPeer().getAttributes().get(IPeerProperties.PROP_OFFLINE_SERVICES);
String remoteServices = peerNode.getStringProperty(IPeerNodeProperties.PROPERTY_REMOTE_SERVICES);
List<String> offline = offlineServices != null ? Arrays.asList(offlineServices.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$
List<String> remote = remoteServices != null ? Arrays.asList(remoteServices.split(",\\s*")) : null; //$NON-NLS-1$

Back to the top