diff options
author | Uwe Stieber | 2012-10-02 07:20:01 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-10-02 07:20:01 +0000 |
commit | 699f78ea8ed77fd213c36633329a151c148f9b04 (patch) | |
tree | c0bde6e766bafb3c3b7df6c86ac65f8f35963ad1 | |
parent | 5ab1fe662867e9a575b604df001149603040d00c (diff) | |
download | org.eclipse.tcf-699f78ea8ed77fd213c36633329a151c148f9b04.tar.gz org.eclipse.tcf-699f78ea8ed77fd213c36633329a151c148f9b04.tar.xz org.eclipse.tcf-699f78ea8ed77fd213c36633329a151c148f9b04.zip |
Target Explorer: Fix properties container thread access issues
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml | 47 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java | 153 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/internal/PropertiesContainerPropertyTester.java) | 7 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.runtime/plugin.xml | 8 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java | 58 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml | 164 |
6 files changed, 217 insertions, 220 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml index 56601c646..2bb24e659 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml @@ -1,20 +1,27 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
-<!-- Extension points -->
- <extension-point id="services" name="%ExtensionPoint.service" schema="schema/services.exsd"/>
-
-<!-- Property tester contributions -->
- <extension point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.tcf.te.runtime.services.internal.PropertyTester"
- id="org.eclipse.tcf.te.runtime.services.PropertyTester"
- namespace="org.eclipse.tcf.te.runtime.services"
- properties="hasService"
- type="java.lang.Object">
- </propertyTester>
-
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + +<!-- Extension points --> + <extension-point id="services" name="%ExtensionPoint.service" schema="schema/services.exsd"/> + +<!-- Property tester contributions --> + <extension point="org.eclipse.core.expressions.propertyTesters"> + <propertyTester + class="org.eclipse.tcf.te.runtime.services.internal.PropertyTester" + id="org.eclipse.tcf.te.runtime.services.PropertyTester" + namespace="org.eclipse.tcf.te.runtime.services" + properties="hasService" + type="java.lang.Object"> + </propertyTester> + + <propertyTester + class="org.eclipse.tcf.te.runtime.services.internal.PropertiesContainerPropertyTester" + id="org.eclipse.tcf.te.runtime.services.PropertiesContainerPropertyTester" + namespace="org.eclipse.tcf.te.runtime" + properties="isProperty" + type="org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer"> + </propertyTester> + </extension> + +</plugin> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java index 905400350..35fb8adb8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java @@ -1,70 +1,83 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 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.services.interfaces;
-
-import java.util.Map;
-
-/**
- * Properties access service.
- * <p>
- * Allows generic access to properties of a given context without having to know all the details and
- * limitations for accessing the desired properties.
- */
-public interface IPropertiesAccessService extends IService {
-
- /**
- * Returns a unmodifiable map containing the target addresses and ports for the given context,
- * if it can be determined.
- * <p>
- * A context may return multiple target addresses and ports if the context can be reached using
- * different connection methods.
- * <p>
- * <b>Note:</b>
- * <ul>
- * <li>See the constants defined in the properties access constants interface for default
- * address and port types.</li>
- * <li>The target address returned must <b>not</b> necessarily be an IP address.</li>
- * <li>The values of the address or port properties might be <code>null</code>.</li>
- * </ul>
- *
- * @param context The context to get the target addresses and ports from. Must not be <code>null</code>.
- * @return The unmodifiable map containing the target addresses and ports, or <code>null</code>.
- */
- public Map<String, String> getTargetAddress(Object context);
-
- /**
- * Returns the property value stored under the given property key. If the property does not
- * exist, <code>null</code> is returned.
- *
- * @param context The context to get the property from. Must not be <code>null</code>.
- * @param key The property key. Must not be <code>null</code>.
- *
- * @return The stored property value or <code>null</code>.
- */
- public Object getProperty(Object context, String key);
-
- /**
- * Set the property with the key with the given value.
- *
- * @param context The context to set the property to. Must not be <code>null</code>.
- * @param key The property key. Must not be <code>null</code>.
- * @param value The value to set.
- * @return <code>true</code> if the value was set.
- */
- public boolean setProperty(Object context, String key, Object value);
-
- /**
- * Returns the direct parent node of the given context object.
- *
- * @param context The context to get the parent from. Must not be <code>null</code>.
- * @return The direct parent node or <code>null</code>.
- */
- public Object getParent(Object context);
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 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.services.interfaces; + +import java.util.Map; + +/** + * Properties access service. + * <p> + * Allows generic access to properties of a given context without having to know all the details and + * limitations for accessing the desired properties. + */ +public interface IPropertiesAccessService extends IService { + + /** + * Returns a unmodifiable map containing the target addresses and ports for the given context, + * if it can be determined. + * <p> + * A context may return multiple target addresses and ports if the context can be reached using + * different connection methods. + * <p> + * <b>Note:</b> + * <ul> + * <li>See the constants defined in the properties access constants interface for default + * address and port types.</li> + * <li>The target address returned must <b>not</b> necessarily be an IP address.</li> + * <li>The values of the address or port properties might be <code>null</code>.</li> + * </ul> + * + * @param context The context to get the target addresses and ports from. Must not be <code>null</code>. + * @return The unmodifiable map containing the target addresses and ports, or <code>null</code>. + */ + public Map<String, String> getTargetAddress(Object context); + + /** + * Returns the property value stored under the given property key. If the property does not + * exist, <code>null</code> is returned. + * + * @param context The context to get the property from. Must not be <code>null</code>. + * @param key The property key. Must not be <code>null</code>. + * + * @return The stored property value or <code>null</code>. + */ + public Object getProperty(Object context, String key); + + /** + * Set the property with the key with the given value. + * + * @param context The context to set the property to. Must not be <code>null</code>. + * @param key The property key. Must not be <code>null</code>. + * @param value The value to set. + * + * @return <code>true</code> if the value was set. + */ + public boolean setProperty(Object context, String key, Object value); + + /** + * Test if the property value stored under the given property is equal to the given + * expected value. + * + * @param context The context. Must not be <code>null</code>. + * @param key The property key. Must not be <code>null</code>. + * @param value The expected property value. + * + * @return <code>true</code> if the expected value is equal to the stored property value, <code>false</code> otherwise. + */ + public boolean isProperty(Object context, String key, Object value); + + /** + * Returns the direct parent node of the given context object. + * + * @param context The context to get the parent from. Must not be <code>null</code>. + * @return The direct parent node or <code>null</code>. + */ + public Object getParent(Object context); +} 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.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java index 34f1bf449..85194fcba 100644 --- 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.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java @@ -7,11 +7,13 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.runtime.internal; +package org.eclipse.tcf.te.runtime.services.internal; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService; /** * Property tester implementation for objects of type {@link IPropertiesContainer}. @@ -47,7 +49,8 @@ public class PropertiesContainerPropertyTester extends PropertyTester { Assert.isNotNull(node); if (args != null && args.length > 0 && args[0] instanceof String) { - return node.isProperty((String)args[0], expectedValue); + IPropertiesAccessService service = ServiceManager.getInstance().getService(node, IPropertiesAccessService.class); + return service != null ? service.isProperty(node, (String)args[0], expectedValue) : node.isProperty((String)args[0], expectedValue); } return false; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.runtime/plugin.xml index 3645bb2e7..3212529f8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/plugin.xml @@ -14,14 +14,6 @@ properties="preference" type="java.lang.Object"> </propertyTester> - - <propertyTester - class="org.eclipse.tcf.te.runtime.internal.PropertiesContainerPropertyTester" - id="org.eclipse.tcf.te.runtime.PropertiesContainerPropertyTester" - namespace="org.eclipse.tcf.te.runtime" - properties="isProperty" - type="org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer"> - </propertyTester> </extension> <!-- Event listener contributions --> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java index 2b800f2cb..31367c2b8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java @@ -60,12 +60,8 @@ public class PropertiesAccessService extends AbstractService implements IPropert } }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); } return !result.isEmpty() ? Collections.unmodifiableMap(result) : null; @@ -91,12 +87,8 @@ public class PropertiesAccessService extends AbstractService implements IPropert } }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); } return value.get(); @@ -121,12 +113,34 @@ public class PropertiesAccessService extends AbstractService implements IPropert } }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + } + + return result.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService#isProperty(java.lang.Object, java.lang.String, java.lang.Object) + */ + @Override + public boolean isProperty(final Object context, final String key, final Object value) { + Assert.isNotNull(context); + Assert.isNotNull(key); + + final AtomicBoolean result = new AtomicBoolean(); + if (context instanceof IPeerModel) { + final IPeerModel peerModel = (IPeerModel) context; + + Runnable runnable = new Runnable() { + @Override + public void run() { + result.set(peerModel.isProperty(key, value)); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); } return result.get(); @@ -150,12 +164,8 @@ public class PropertiesAccessService extends AbstractService implements IPropert } }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); } return value.get(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml index 9afdef8b6..9a6ba5e1d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml @@ -346,28 +346,50 @@ </visibleWhen> </dynamic> </menuContribution> - <menuContribution - locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.filter"> + + <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.filter"> <command commandId="org.eclipse.tcf.te.ui.views.command.quickfilter" label="%menu.filter.label" mnemonic="%menu.filter.mnemonic" style="push"> + <visibleWhen checkEnabled="false"> + <with variable="activePart"> + <adapt type="org.eclipse.ui.navigator.CommonViewer"> + <test property="org.eclipse.tcf.te.ui.views.isFilterable"/> + </adapt> + </with> + </visibleWhen> </command> <command commandId="org.eclipse.tcf.te.ui.views.command.resetfilter" label="%menu.reset.label" mnemonic="%menu.reset.mnemonic" style="push"> + <visibleWhen checkEnabled="false"> + <with variable="activePart"> + <adapt type="org.eclipse.ui.navigator.CommonViewer"> + <test property="org.eclipse.tcf.te.ui.views.isFilterable"/> + </adapt> + </with> + </visibleWhen> </command> </menuContribution> - <menuContribution - locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.search"> + + <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.search"> <command commandId="org.eclipse.tcf.te.ui.views.command.find" label="%menu.find.label" mnemonic="%menu.find.mnemonic" style="push"> + <visibleWhen checkEnabled="false"> + <with variable="selection"> + <iterate> + <adapt type="org.eclipse.tcf.te.ui.interfaces.ISearchable"> + </adapt> + </iterate> + </with> + </visibleWhen> </command> </menuContribution> @@ -499,171 +521,121 @@ class="org.eclipse.tcf.te.ui.views.handler.ConfigFiltersHandler" commandId="org.eclipse.tcf.te.ui.views.command.filters"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.View"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.View"/> </with> </activeWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.ConfigContentHandler" commandId="org.eclipse.tcf.te.ui.views.command.content"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.View"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.View"/> </with> </activeWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.ViewQuickFilterHanlder" commandId="org.eclipse.tcf.te.ui.views.command.quickfilter"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.View"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.View"/> </with> </activeWhen> <enabledWhen> - <with - variable="activePart"> - <adapt - type="org.eclipse.ui.navigator.CommonViewer"> - <test - property="org.eclipse.tcf.te.ui.views.isFilterable"> - </test> + <with variable="activePart"> + <adapt type="org.eclipse.ui.navigator.CommonViewer"> + <test property="org.eclipse.tcf.te.ui.views.isFilterable"/> </adapt> </with> </enabledWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.ViewQuickFilterResetHanlder" commandId="org.eclipse.tcf.te.ui.views.command.resetfilter"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.View"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.View"/> </with> </activeWhen> <enabledWhen> - <with - variable="activePart"> - <adapt - type="org.eclipse.ui.navigator.CommonViewer"> - <test - property="org.eclipse.tcf.te.ui.views.isFiltering"> - </test> + <with variable="activePart"> + <adapt type="org.eclipse.ui.navigator.CommonViewer"> + <test property="org.eclipse.tcf.te.ui.views.isFiltering"/> </adapt> </with> </enabledWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.EditorQuickFilterHanlder" commandId="org.eclipse.tcf.te.ui.views.command.quickfilter"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.Editor"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.Editor"/> </with> </activeWhen> <enabledWhen> - <with - variable="activeEditor"> - <test - property="org.eclipse.tcf.te.ui.views.isEditorFilterable"> - </test> + <with variable="activeEditor"> + <test property="org.eclipse.tcf.te.ui.views.isEditorFilterable"/> </with> </enabledWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.EditorQuickFilterResetHanlder" commandId="org.eclipse.tcf.te.ui.views.command.resetfilter"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.Editor"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.Editor"/> </with> </activeWhen> <enabledWhen> - <with - variable="activeEditor"> - <adapt - type="org.eclipse.jface.viewers.TreeViewer"> - <test - property="org.eclipse.tcf.te.ui.views.isFiltering"> - </test> + <with variable="activeEditor"> + <adapt type="org.eclipse.jface.viewers.TreeViewer"> + <test property="org.eclipse.tcf.te.ui.views.isFiltering"/> </adapt> </with> </enabledWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.ViewSearchHandler" commandId="org.eclipse.tcf.te.ui.views.command.find"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.View"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.View"/> </with> </activeWhen> <enabledWhen> - <with - variable="selection"> - <count - value="1"> - </count> + <with variable="selection"> + <count value="1"/> <iterate> - <or> - <instanceof - value="org.eclipse.tcf.te.ui.interfaces.ISearchable"> - </instanceof> - <adapt - type="org.eclipse.tcf.te.ui.interfaces.ISearchable"> - </adapt> - </or> + <adapt type="org.eclipse.tcf.te.ui.interfaces.ISearchable"> + </adapt> </iterate> </with> </enabledWhen> </handler> + <handler class="org.eclipse.tcf.te.ui.views.handler.EditorSearchHandler" commandId="org.eclipse.tcf.te.ui.views.command.find"> <activeWhen> - <with - variable="activePartId"> - <equals - value="org.eclipse.tcf.te.ui.views.Editor"> - </equals> + <with variable="activePartId"> + <equals value="org.eclipse.tcf.te.ui.views.Editor"/> </with> </activeWhen> <enabledWhen> - <with - variable="selection"> - <count - value="1"> - </count> + <with variable="selection"> + <count value="1"/> <iterate> - <or> - <instanceof - value="org.eclipse.tcf.te.ui.interfaces.ISearchable"> - </instanceof> - <adapt - type="org.eclipse.tcf.te.ui.interfaces.ISearchable"> - </adapt> - </or> + <adapt type="org.eclipse.tcf.te.ui.interfaces.ISearchable"> + </adapt> </iterate> </with> </enabledWhen> |