Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2014-01-16 07:52:56 +0000
committerrschnekenbu2014-01-27 14:41:40 +0000
commitf0e4b5f3065d5334cebbc6f8f55212abce4ba4a3 (patch)
tree7b1ab769bffc664d4b47b8384532ca115f2e14df /plugins
parent619fa9cb6b06a98157bd42e6a3f4113539be0a43 (diff)
downloadorg.eclipse.papyrus-f0e4b5f3065d5334cebbc6f8f55212abce4ba4a3.tar.gz
org.eclipse.papyrus-f0e4b5f3065d5334cebbc6f8f55212abce4ba4a3.tar.xz
org.eclipse.papyrus-f0e4b5f3065d5334cebbc6f8f55212abce4ba4a3.zip
424402: [Core] Runtime deployment of the element types shall be possible
https://bugs.eclipse.org/bugs/show_bug.cgi?id=424402 - Update element matcher and element matcher factory, so element matchers can be added to any elemen type configuration
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/elementMatcherConfiguration.exsd2
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AbstractConfigurableElementTypeFactory.java (renamed from plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/AbstractExtendedElementTypeFactory.java)18
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ComposedElementMatcher.java56
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ConfigurableElementMatcherFactoryRegistry.java246
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcher.java28
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcherFactory.java (renamed from plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IElementMatcherFactory.java)5
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/InvariantElementTypeFactory.java12
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes.edit/plugin.properties4
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcher.java14
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcherFactory.java6
10 files changed, 371 insertions, 20 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/elementMatcherConfiguration.exsd b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/elementMatcherConfiguration.exsd
index 323f4997683..6a3b87e33ad 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/elementMatcherConfiguration.exsd
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/elementMatcherConfiguration.exsd
@@ -72,7 +72,7 @@
class name of the factory used to create new element matchers based on the given configuration
</documentation>
<appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.extendedtypes.IElementMatcherFactory"/>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.extendedtypes.IConfigurableElementMatcherFactory"/>
</appInfo>
</annotation>
</attribute>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/AbstractExtendedElementTypeFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AbstractConfigurableElementTypeFactory.java
index c5ad8b461bf..5313f6aa1d7 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/AbstractExtendedElementTypeFactory.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AbstractConfigurableElementTypeFactory.java
@@ -10,7 +10,7 @@
* Remi Schnekenburger (CEA LIST) - Initial API and implementation
*
*****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration;
+package org.eclipse.papyrus.infra.extendedtypes;
import java.net.MalformedURLException;
import java.net.URL;
@@ -24,17 +24,15 @@ import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
import org.eclipse.papyrus.infra.extendedtypes.ElementTypeConfiguration;
-import org.eclipse.papyrus.infra.extendedtypes.ICreationElementValidator;
-import org.eclipse.papyrus.infra.extendedtypes.IExtendedElementTypeFactory;
import org.eclipse.papyrus.infra.extendedtypes.IconEntry;
import org.eclipse.papyrus.infra.extendedtypes.types.ExtendedHintedElementType;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.osgi.framework.Bundle;
/**
- *
+ * Factory to create element type from its {@link ElementTypeConfiguration}
*/
-public abstract class AbstractExtendedElementTypeFactory<T extends ElementTypeConfiguration> implements IExtendedElementTypeFactory<T> {
+public abstract class AbstractConfigurableElementTypeFactory<T extends ElementTypeConfiguration> implements IExtendedElementTypeFactory<T> {
/**
* {@inheritDoc}
@@ -82,7 +80,15 @@ public abstract class AbstractExtendedElementTypeFactory<T extends ElementTypeCo
* @param configuration
* @return
*/
- protected abstract IElementMatcher createElementMatcher(T configuration);
+ protected IElementMatcher createElementMatcher(T configuration) {
+ MatcherConfiguration matcherConfiguration = configuration.getMatcherConfiguration();
+ if(matcherConfiguration==null) {
+ return null;
+ }
+ // create matcher from the configuration
+ IElementMatcher matcher = ConfigurableElementMatcherFactoryRegistry.getInstance().createElementMatcher(matcherConfiguration);
+ return matcher;
+ }
/**
* {@inheritDoc}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ComposedElementMatcher.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ComposedElementMatcher.java
new file mode 100644
index 00000000000..531267159ca
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ComposedElementMatcher.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.extendedtypes;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+
+
+/**
+ * @author RS211865
+ */
+public class ComposedElementMatcher implements IElementMatcher {
+
+ protected final IElementMatcher mainMatcher;
+ protected final IElementMatcher composedElementMatcher;
+
+ public ComposedElementMatcher(IElementMatcher mainMatcher, IElementMatcher composedElementMatcher) {
+ this.composedElementMatcher = composedElementMatcher;
+ this.mainMatcher = mainMatcher;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init(MatcherConfiguration configuration) {
+ throw new RuntimeException("Not Expected to be called");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches(EObject eObject) {
+ // matches if both matcher matches
+ if(mainMatcher!=null) {
+ if(!mainMatcher.matches(eObject)) {
+ return false;
+ }
+ }
+ if(composedElementMatcher!=null) {
+ if(!composedElementMatcher.matches(eObject)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ConfigurableElementMatcherFactoryRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ConfigurableElementMatcherFactoryRegistry.java
new file mode 100644
index 00000000000..533e7b86434
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ConfigurableElementMatcherFactoryRegistry.java
@@ -0,0 +1,246 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.extendedtypes;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+import org.osgi.framework.Bundle;
+
+/**
+ * Registry for all element matcher factories for element matcher based on {@link MatcherConfiguration}.
+ */
+public class ConfigurableElementMatcherFactoryRegistry {
+
+ /** private singleton instance */
+ private static ConfigurableElementMatcherFactoryRegistry registry;
+
+ protected Map<String, IConfigurableElementMatcherFactory<MatcherConfiguration>> configurationTypeToMatcherFactory = null;
+
+ protected List<String> configurationTypeFactoryExceptions = null;
+
+ /**
+ * returns the singleton instance of this registry
+ *
+ * @return the singleton instance of this registry
+ */
+ public static synchronized ConfigurableElementMatcherFactoryRegistry getInstance() {
+ if(registry == null) {
+ registry = new ConfigurableElementMatcherFactoryRegistry();
+ registry.init();
+ }
+ return registry;
+ }
+
+ /**
+ * Inits the registry.
+ */
+ protected void init() {
+ configurationTypeToMatcherFactory = new HashMap<String, IConfigurableElementMatcherFactory<MatcherConfiguration>>();
+
+ }
+
+ /**
+ * Creates the {@link IElementMatcher} specific to the given rule configuration
+ *
+ * @param ruleConfiguration
+ * the rule configuration that will configure the created matcher
+ * @return the {@link IElementMatcher} created or <code>null</code> if none could be created
+ */
+ public IConfigurableElementMatcher<MatcherConfiguration> createElementMatcher(MatcherConfiguration matcherConfiguration) {
+ String configurationType = matcherConfiguration.eClass().getInstanceTypeName();
+ IConfigurableElementMatcherFactory<MatcherConfiguration> factory = configurationTypeToMatcherFactory.get(configurationType);
+ // check factory is not on the exception table
+ if(factory == null && isNotInFactoryExceptionList(configurationType)) {
+ Class<IConfigurableElementMatcherFactory<MatcherConfiguration>> factoryClass = retrieveFactoryClassFromExtensionPoint(configurationType);
+ if(factoryClass != null) {
+ try {
+ factory = factoryClass.newInstance();
+ } catch (InstantiationException e) {
+ if(configurationTypeFactoryExceptions == null) {
+ configurationTypeFactoryExceptions = new ArrayList<String>();
+ }
+ configurationTypeFactoryExceptions.add(configurationType);
+ } catch (IllegalAccessException e) {
+ if(configurationTypeFactoryExceptions == null) {
+ configurationTypeFactoryExceptions = new ArrayList<String>();
+ }
+ configurationTypeFactoryExceptions.add(configurationType);
+ }
+ configurationTypeToMatcherFactory.put(configurationType, factory);
+ }
+ }
+ if(factory != null) {
+ IConfigurableElementMatcher<MatcherConfiguration> elementMatcher = factory.createElementMatcher(matcherConfiguration);
+ if(elementMatcher !=null) {
+ //elementMatcher.init(matcherConfiguration);
+ return elementMatcher;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * check this configuration type has not already caused issues du
+ *
+ * @param configurationType
+ * @return
+ */
+ protected boolean isNotInFactoryExceptionList(String configurationType) {
+ if(configurationTypeFactoryExceptions == null) {
+ return true;
+ }
+ // this is not null, check the configuration type is not in the list
+ return !configurationTypeFactoryExceptions.contains(configurationType);
+ }
+
+ /**
+ * Returns the {@link IExtendedElementTypeFactory} class used to instantiate element type for the given configuration
+ *
+ * @return the {@link IExtendedElementTypeFactory} found or <code>null</code> if none was found
+ */
+ @SuppressWarnings("unchecked")
+ protected Class<IConfigurableElementMatcherFactory<MatcherConfiguration>> retrieveFactoryClassFromExtensionPoint(String configurationType) {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(IElementMatcherExtensionPoint.EXTENSION_POINT_ID);
+ for(IConfigurationElement configurationElement : elements) {
+ String eCoreClassName = configurationElement.getAttribute(IElementMatcherExtensionPoint.MATCHER_CONFIGURATION_CLASS);
+ if(configurationType.equals(eCoreClassName)) {
+ // retrieve factory to load
+ String factoryClassName = configurationElement.getAttribute(IElementMatcherExtensionPoint.MATCHER_FACTORY_CLASS);
+ return (Class<IConfigurableElementMatcherFactory<MatcherConfiguration>>)loadClass(factoryClassName, configurationElement.getContributor().getName());
+ }
+ }
+ return null;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // loading resource
+ ///////////////////////////////////////////////////////////////////////////
+ /** A map of classes that have been successfully loaded, keyed on the class name optionally prepended by the plugin ID, if specified. */
+ private static Map<String, WeakReference<Class<?>>> successLookupTable = new HashMap<String, WeakReference<Class<?>>>();
+
+ /** A map of classes that could not be loaded, keyed on the class name, optionally prepended by the plugin ID if specified. */
+ private static Set<String> failureLookupTable = new HashSet<String>();
+
+ /** A map to hold the bundle to exception list */
+ private static Map<Bundle, Set<String>> bundleToExceptionsSetMap = new HashMap<Bundle, Set<String>>();
+
+ /**
+ * A utility method to load a class using its name and a given class loader.
+ *
+ * @param className
+ * The class name
+ * @param bundle
+ * The class loader
+ * @return The loaded class or <code>null</code> if could not be loaded
+ */
+ protected static Class<?> loadClass(String className, String pluginId) {
+ StringBuffer keyStringBuf = new StringBuffer(className.length() + pluginId.length() + 2); // 2 is for . and extra.
+ keyStringBuf.append(pluginId);
+ keyStringBuf.append('.');
+ keyStringBuf.append(className);
+ String keyString = keyStringBuf.toString();
+ WeakReference<Class<?>> ref = successLookupTable.get(keyString);
+ Class<?> found = (ref != null) ? ref.get() : null;
+ if(found == null) {
+ if(ref != null)
+ successLookupTable.remove(keyString);
+ if(!failureLookupTable.contains(keyString)) {
+ try {
+ Bundle bundle = basicGetPluginBundle(pluginId);
+ if(bundle != null) {
+ // never load the class if the bundle is not active other wise
+ // we will cause the plugin to load
+ // unless the class is in the exception list
+ int state = bundle.getState();
+ if(state == org.osgi.framework.Bundle.ACTIVE || isInExceptionList(bundle, className)) {
+ found = bundle.loadClass(className);
+ successLookupTable.put(keyString, new WeakReference<Class<?>>(found));
+ if(state == org.osgi.framework.Bundle.ACTIVE) {
+ bundleToExceptionsSetMap.remove(bundle);
+ }
+ }
+ } else {
+ failureLookupTable.add(keyString);
+ }
+ } catch (ClassNotFoundException e) {
+ failureLookupTable.add(keyString);
+ }
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Given a bundle id, it checks if the bundle is found and activated. If it
+ * is, the method returns the bundle, otherwise it returns <code>null</code>.
+ *
+ * @param pluginId
+ * the bundle ID
+ * @return the bundle, if found
+ */
+ protected static Bundle getPluginBundle(String pluginId) {
+ Bundle bundle = basicGetPluginBundle(pluginId);
+ if(null != bundle && bundle.getState() == org.osgi.framework.Bundle.ACTIVE)
+ return bundle;
+ return null;
+ }
+
+ private static Bundle basicGetPluginBundle(String pluginId) {
+ return Platform.getBundle(pluginId);
+ }
+
+ private static boolean isInExceptionList(Bundle bundle, String className) {
+ String packageName = className.substring(0, className.lastIndexOf('.'));
+ Set<String> exceptionSet = bundleToExceptionsSetMap.get(bundle);
+ if(exceptionSet == null) {
+ Dictionary<String, String> dict = bundle.getHeaders();
+ String value = dict.get("Eclipse-LazyStart"); //$NON-NLS-1$
+ if(value != null) {
+ int index = value.indexOf("exceptions"); //$NON-NLS-1$
+ if(index != -1) {
+ try {
+ int start = value.indexOf('"', index + 1);
+ int end = value.indexOf('"', start + 1);
+ String exceptions = value.substring(start + 1, end);
+ exceptionSet = new HashSet<String>(2);
+ StringTokenizer tokenizer = new StringTokenizer(exceptions, ","); //$NON-NLS-1$
+ while(tokenizer.hasMoreTokens()) {
+ exceptionSet.add(tokenizer.nextToken().trim());
+ }
+ } catch (IndexOutOfBoundsException exception) {
+ // this means the MF did not follow the documented format for the exceptions list so i'll consider it empty
+ exceptionSet = Collections.emptySet();
+ }
+ } else {
+ exceptionSet = Collections.emptySet();
+ }
+ } else {
+ exceptionSet = Collections.emptySet();
+ }
+ bundleToExceptionsSetMap.put(bundle, exceptionSet);
+ }
+ return exceptionSet.contains(packageName);
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcher.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcher.java
new file mode 100644
index 00000000000..b1b39334db9
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcher.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.extendedtypes;
+
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+
+
+/**
+ * Interface implemented by all element matchers configured by a {@link MatcherConfiguration}
+ */
+public interface IConfigurableElementMatcher<T extends MatcherConfiguration> extends IElementMatcher {
+
+ /**
+ * Inits the element matcher with the given contribution. Should be called once, after element matcher instantiation
+ * @param configuration the configuration of this {@link IElementMatcher}
+ */
+ // public void init(T configuration);
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IElementMatcherFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcherFactory.java
index e83afb89ee6..41d059aa581 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IElementMatcherFactory.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IConfigurableElementMatcherFactory.java
@@ -13,18 +13,17 @@
package org.eclipse.papyrus.infra.extendedtypes;
import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
-import org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration.IConfigurableElementMatcher;
/**
* interface for factories that instantiate {@link IConfigurableElementMatcher} with their given configuration
*/
-public interface IElementMatcherFactory<T extends MatcherConfiguration> {
+public interface IConfigurableElementMatcherFactory<T extends MatcherConfiguration> {
/**
* Creates an element matcher with the specified configuration
* @param configuration the configuration of the {@link IElementMatcher}
* @return the created element matcher or <code>null</code> if none was created
*/
- public IElementMatcher createElementMatcher(T configuration);
+ public IConfigurableElementMatcher<T> createElementMatcher(T configuration);
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/InvariantElementTypeFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/InvariantElementTypeFactory.java
index 59884560cbb..5c129c2c7d5 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/InvariantElementTypeFactory.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/InvariantElementTypeFactory.java
@@ -15,12 +15,14 @@ package org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfigurati
import org.eclipse.gmf.runtime.emf.type.core.IContainerDescriptor;
import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+import org.eclipse.papyrus.infra.extendedtypes.AbstractConfigurableElementTypeFactory;
+import org.eclipse.papyrus.infra.extendedtypes.ComposedElementMatcher;
import org.eclipse.papyrus.infra.extendedtypes.ICreationElementValidator;
/**
* Factory used to create ElementType from a {@link InvariantSemanticTypeConfiguration}.
*/
-public class InvariantElementTypeFactory extends AbstractExtendedElementTypeFactory<InvariantSemanticTypeConfiguration> {
+public class InvariantElementTypeFactory extends AbstractConfigurableElementTypeFactory<InvariantSemanticTypeConfiguration> {
/**
* {@inheritDoc}
@@ -58,6 +60,14 @@ public class InvariantElementTypeFactory extends AbstractExtendedElementTypeFact
*/
@Override
protected IElementMatcher createElementMatcher(InvariantSemanticTypeConfiguration configuration) {
+ IElementMatcher superMatcher = super.createElementMatcher(configuration);
+ if(superMatcher !=null) {
+ // create a composed matcher to have the matcher described by the model configuration element type and the one for the specific invariants
+ IElementMatcher invariantMatcher = RuleConfigurationFactoryRegistry.getInstance().createMatcher(configuration.getInvariantRuleConfiguration());
+ ComposedElementMatcher composedMatcher = new ComposedElementMatcher(superMatcher, invariantMatcher);
+ return composedMatcher;
+ }
+ // no configured matcher. Return the invariant one
return RuleConfigurationFactoryRegistry.getInstance().createMatcher(configuration.getInvariantRuleConfiguration());
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes.edit/plugin.properties b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes.edit/plugin.properties
index 6ad2e720134..f5130f2382d 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes.edit/plugin.properties
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes.edit/plugin.properties
@@ -29,8 +29,8 @@ _UI_Unknown_datatype= Value
_UI_StereotypedElementMatcher_stereotypedQualifiedName_feature = Stereotyped Qualified Name
_UI_Unknown_feature = Unspecified
-_UI_StereotypedElementMatcherConfiguration_type = Configuration
-_UI_StereotypedElementMatcherConfiguration_stereotypedQualifiedName_feature = Stereotyped Qualified Name
+_UI_StereotypedElementMatcherConfiguration_type = Stereotyped Element Matcher Configuration
+_UI_StereotypedElementMatcherConfiguration_stereotypedQualifiedName_feature = Stereotype Qualified Name
_UI_InvariantStereotypeConfiguration_type = Invariant Stereotype Configuration
_UI_InvariantStereotypeConfiguration_stereotypeQualifiedName_feature = Stereotype Qualified Name
_UI_InvariantStereotypeConfiguration_requiredProfile_feature = Required Profile
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcher.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcher.java
index 04f1fde860d..45317f091c6 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcher.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcher.java
@@ -13,22 +13,21 @@
package org.eclipse.papyrus.uml.tools.extendedtypes.stereotypedelementmatcherconfiguration;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+import org.eclipse.papyrus.infra.extendedtypes.IConfigurableElementMatcher;
import org.eclipse.uml2.uml.Element;
/**
* Matcher for UML elements that should be stereotypes
*/
-public class StereotypedElementMatcher implements IElementMatcher {
+public class StereotypedElementMatcher implements IConfigurableElementMatcher<StereotypedElementMatcherConfiguration> {
private String stereotypedQualifiedName;
/**
* @param stereotypedQualifiedName
*/
- public StereotypedElementMatcher(String stereotypedQualifiedName) {
- this.setStereotypedQualifiedName(stereotypedQualifiedName);
+ public StereotypedElementMatcher() {
}
/**
@@ -56,4 +55,11 @@ public class StereotypedElementMatcher implements IElementMatcher {
public void setStereotypedQualifiedName(String stereotypedQualifiedName) {
this.stereotypedQualifiedName = stereotypedQualifiedName;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init(StereotypedElementMatcherConfiguration configuration) {
+ this.setStereotypedQualifiedName(stereotypedQualifiedName);
+ }
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcherFactory.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcherFactory.java
index 157961aa40d..c50897ff529 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcherFactory.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.extendedtypes/src/org/eclipse/papyrus/uml/tools/extendedtypes/stereotypedelementmatcherconfiguration/StereotypedElementMatcherFactory.java
@@ -12,19 +12,19 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.extendedtypes.stereotypedelementmatcherconfiguration;
-import org.eclipse.papyrus.infra.extendedtypes.IElementMatcherFactory;
+import org.eclipse.papyrus.infra.extendedtypes.IConfigurableElementMatcherFactory;
import org.eclipse.papyrus.uml.tools.extendedtypes.stereotypedelementmatcherconfiguration.StereotypedElementMatcherConfiguration;
/**
* Factory to create matcher based on stereotypes applied on the element
*/
-public class StereotypedElementMatcherFactory implements IElementMatcherFactory<StereotypedElementMatcherConfiguration> {
+public class StereotypedElementMatcherFactory implements IConfigurableElementMatcherFactory<StereotypedElementMatcherConfiguration> {
/**
* {@inheritDoc}
*/
public StereotypedElementMatcher createElementMatcher(StereotypedElementMatcherConfiguration configuration) {
- return new StereotypedElementMatcher(configuration.getStereotypedQualifiedName());
+ return new StereotypedElementMatcher();
}
}

Back to the top