Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/PropertyTester.java60
3 files changed, 73 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF
index 3c3a60530..fc52156d6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.tcf.te.core.activator.CoreBundleActivator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.eclipse.core.expressions;bundle-version="3.4.300",
org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
org.eclipse.tcf.te.runtime.stepper;bundle-version="1.0.0",
org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml
index 4162ecfe9..9f6bc9fc2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml
@@ -15,6 +15,18 @@
</factory>
</extension>
+<!-- Property tester contributions -->
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.te.core.adapters.PropertyTester"
+ id="org.eclipse.tcf.te.core.adapters.PropertyTester"
+ namespace="org.eclipse.tcf.te.core"
+ properties="hasAdapter,canAdaptTo"
+ type="org.eclipse.core.runtime.IAdaptable">
+ </propertyTester>
+
+ </extension>
+
<!-- Reusable core expression fragments -->
<extension point="org.eclipse.core.expressions.definitions">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/PropertyTester.java
new file mode 100644
index 000000000..1f6d50041
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/adapters/PropertyTester.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.tcf.te.core.adapters;
+
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Adapter helper property tester implementation.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ IAdapterManager manager = Platform.getAdapterManager();
+ if (manager == null) return false;
+
+ // "hasAdapter": Checks if the adapter given by the arguments is registered for the given receiver
+ if ("hasAdapter".equals(property)) { //$NON-NLS-1$
+ // The class to adapt to is within the expected value
+ String adapterType = expectedValue instanceof String ? (String)expectedValue : null;
+ if (adapterType != null) {
+ return manager.hasAdapter(receiver, adapterType);
+ }
+ }
+ if ("canAdaptTo".equals(property)) { //$NON-NLS-1$
+ // Read the arguments and look for "forceAdapterLoad"
+ boolean forceAdapterLoad = false;
+ for (Object arg : args) {
+ if (arg instanceof String && "forceAdapterLoad".equalsIgnoreCase((String)arg)) { //$NON-NLS-1$
+ forceAdapterLoad = true;
+ }
+ }
+
+ // The class to adapt to is within the expected value
+ String adapterType = expectedValue instanceof String ? (String)expectedValue : null;
+ if (adapterType != null) {
+ Object adapter = manager.getAdapter(receiver, adapterType);
+ if (adapter != null) return true;
+
+ // No adapter. This can happen too if the plug-in contributing the adapter
+ // factory hasn't been loaded yet.
+ if (forceAdapterLoad) adapter = manager.loadAdapter(receiver, adapterType);
+ if (adapter != null) return true;
+ }
+ }
+
+ return false;
+ }
+}

Back to the top