Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-11-16 08:59:51 +0000
committerUwe Stieber2011-11-16 08:59:51 +0000
commit8706fb04b6c1417ed8d5ece83bc9fca64ddfc3ce (patch)
tree35ff2855e92a05029eb1a01455c6018c573c7175 /target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal
parent67449886c09c8ec4da4f39082373ab62ccc3d978 (diff)
downloadorg.eclipse.tcf-8706fb04b6c1417ed8d5ece83bc9fca64ddfc3ce.tar.gz
org.eclipse.tcf-8706fb04b6c1417ed8d5ece83bc9fca64ddfc3ce.tar.xz
org.eclipse.tcf-8706fb04b6c1417ed8d5ece83bc9fca64ddfc3ce.zip
Target Explorer: Refactor name space from org.eclipse.tm.te.* to org.eclipse.tcf.te.*
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/DebugEventListener.java33
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PreferencesPropertyTester.java76
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PropertiesContainerPropertyTester.java56
3 files changed, 165 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/DebugEventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/DebugEventListener.java
new file mode 100644
index 000000000..ab56d02ee
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/DebugEventListener.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.runtime.internal;
+
+import java.util.EventObject;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.tcf.te.runtime.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
+import org.eclipse.tcf.te.runtime.interfaces.tracing.ITraceIds;
+
+/**
+ * Event listener for internal debugging purpose.
+ */
+public class DebugEventListener implements IEventListener {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_EVENTS))
+ CoreBundleActivator.getTraceHandler().trace("thread=[" + Thread.currentThread().getName() + "]\n\t" + event.toString(), //$NON-NLS-1$ //$NON-NLS-2$
+ 0, ITraceIds.TRACE_EVENTS, IStatus.INFO, this);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PreferencesPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PreferencesPropertyTester.java
new file mode 100644
index 000000000..7b9f164a1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PreferencesPropertyTester.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.runtime.internal;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.tcf.te.runtime.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+
+/**
+ * Preferences property tester implementation.
+ */
+public class PreferencesPropertyTester extends 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) {
+ // The preferences property tester is not extending a specific object type.
+ // The tester ignores the given receiver object.
+
+ if ("preference".equals(property)) { //$NON-NLS-1$
+ String bundleId = CoreBundleActivator.getUniqueIdentifier();
+ String key = null;
+
+ // Search the args for bundle id, the preference type and the preference key
+ for (Object candidate : args) {
+ // We cannot handle arguments other than strings
+ if (!(candidate instanceof String)) continue;
+
+ String arg = (String)candidate;
+
+ // bundleId=<id>
+ if (arg.toLowerCase().startsWith("bundleid")) { //$NON-NLS-1$
+ String[] tokens = arg.split("=", 2); //$NON-NLS-1$
+ // Check if the given bundle id really resolves to an installed bundle
+ if (tokens.length == 2 && tokens[1] != null && Platform.getBundle(tokens[1].trim()) != null) {
+ bundleId = tokens[1].trim();
+ }
+ }
+
+ // key=<preference key>
+ if (arg.toLowerCase().startsWith("key")) { //$NON-NLS-1$
+ String[] tokens = arg.split("=", 2); //$NON-NLS-1$
+ // Check for the key not being empty or null
+ if (tokens.length == 2 && tokens[1] != null && !"".equals(tokens[1].trim())) { //$NON-NLS-1$
+ key = tokens[1].trim();
+ }
+ }
+ }
+
+ // Lookup the preference
+ if (key != null) {
+ // Check the preference within the instance and default scope
+ ScopedEclipsePreferences preferences = new ScopedEclipsePreferences(bundleId);
+ // If the expected value is not specified or "null", check if the preference
+ // key is set or not. Return "true" if the key is not set.
+ if (expectedValue == null || "null".equals(expectedValue)) return !preferences.containsKey(key); //$NON-NLS-1$
+
+ // Always check against the string value
+ return expectedValue.toString().equals(preferences.getString(key));
+ }
+ }
+
+ return false;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PropertiesContainerPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PropertiesContainerPropertyTester.java
new file mode 100644
index 000000000..34f1bf449
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PropertiesContainerPropertyTester.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.runtime.internal;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+
+/**
+ * Property tester implementation for objects of type {@link IPropertiesContainer}.
+ */
+public class PropertiesContainerPropertyTester extends 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) {
+ // The receiver is expected to be a properties container
+ if (receiver instanceof IPropertiesContainer) {
+
+ if ("isProperty".equals(property)) { // //$NON-NLS-1$
+ // Test for an individual property within the property container
+ return testIsProperty((IPropertiesContainer)receiver, args, expectedValue);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test the specific model node properties.
+ *
+ * @param node The properties container. Must not be <code>null</code>.
+ * @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 testIsProperty(IPropertiesContainer node, Object[] args, Object expectedValue) {
+ Assert.isNotNull(node);
+
+ if (args != null && args.length > 0 && args[0] instanceof String) {
+ return node.isProperty((String)args[0], expectedValue);
+ }
+
+ return false;
+ }
+
+}

Back to the top