Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-01-15 13:27:40 -0500
committerChristian W. Damus2016-01-22 10:57:12 -0500
commit929e9738301b35cef5cc1ab00f47047671940bd5 (patch)
tree3557a10c2577b834d83909689755a39b86162517 /plugins/infra/org.eclipse.papyrus.infra.extendedtypes
parent652333238a0a1651c1b69a4563b72961250c5398 (diff)
downloadorg.eclipse.papyrus-929e9738301b35cef5cc1ab00f47047671940bd5.tar.gz
org.eclipse.papyrus-929e9738301b35cef5cc1ab00f47047671940bd5.tar.xz
org.eclipse.papyrus-929e9738301b35cef5cc1ab00f47047671940bd5.zip
Bug 485220: [Architecture] Provide a more modular architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485220 Move UI-dependent APIs from the org.eclipse.papyrus.infra.constraints bundle to a new org.eclipse.papyrus.infra.constraints.ui bundle. Replace usage of ISelection and IStructuredSelection in Constraint and ConstraintEngine API methods with Object and Collection<?>, respectively. Move the ElementTypesPreferences class from the infra.elementtypesconfigurations bundle to a new infra.elementtypesconfigurations.ui bundle. For compatibility, it still persists its data via an `IMemento` in the preferences of the core `infra.elementtypesconfigurations` bundle. It implements a new provider extension interface that allows the core bundle's element-type registry to call out to it to get user-defined element types from the workspace. Move the RuntimeValuesEditionAdviceEditHelperAdvice class and some of its attendants from the infra.elementtypesconfigurations.emf bundle to the new infra.elementtypesconfigurations.ui bundle because it needs to open the EditionDialog to let the user edit objects. Likewise the similar APIs in the infra.extendedtypes bundle, including also the entire providers package for action-providers, with the ExtendedElementTypeActionService class, the IExtendedElementTypeActionProvider interface, and the corresponding extension point namespace. Move the ElementTypeValidator class from the infra.services.edit bundle to a new infra.services.edit.ui bundle. Other fixes for simple inessential UI dependencies and also conflicts in bundle classpaths (such as in the Sequence Diagram particularly) that cause deadlocks in class loading in a complete Papyrus environment, such as the AllTests suite. Factor the UI dependencies out of the infra.onefile bundle into a new infra.onefile.ui bundle. Tests all still pass (inasmuch as they do in the nightly master builds). Change-Id: I43510c84f54c3e0e52cd7d2aa3ca6aca95b894a7
Diffstat (limited to 'plugins/infra/org.eclipse.papyrus.infra.extendedtypes')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.classpath4
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF10
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/build.properties3
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/configuration.gifbin341 -> 0 bytes
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/error.gifbin353 -> 0 bytes
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml71
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd198
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/userExtendedTypes.exsd100
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java19
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AspectConfigurationFactoryRegistry.java124
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ConfigurableElementMatcherFactoryRegistry.java124
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSetRegistry.java131
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/UserExtendedTypesRegistry.java107
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/DeployExtendedTypeSetConfigurationHandler.java147
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/UndeployExtendedTypeSetConfigurationHandler.java148
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/internal/spi/IUserExtendedTypesProvider.java39
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/RuleConfigurationFactoryRegistry.java120
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java297
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java201
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java82
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java48
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java53
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java61
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java36
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/InternalUtils.java157
26 files changed, 437 insertions, 1849 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.classpath b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.classpath
index 756f4289006..50aae142c50 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.classpath
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.classpath
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.settings/org.eclipse.jdt.core.prefs
index 4759947300a..62a08f4494d 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF
index 10c826400b9..7d4781596c9 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF
@@ -1,26 +1,20 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
- org.eclipse.emf.ecore;bundle-version="2.7.0";visibility:=reexport,
- org.eclipse.emf.ecore.xmi;bundle-version="2.6.0";visibility:=reexport,
- org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.9.0",
org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- org.eclipse.gmf.runtime.common.ui.services;bundle-version="1.3.0",
org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
org.eclipse.papyrus.infra.services.edit;bundle-version="1.2.0",
org.eclipse.papyrus.infra.elementtypesconfigurations;bundle-version="1.2.0"
Export-Package: org.eclipse.papyrus.infra.extendedtypes,
org.eclipse.papyrus.infra.extendedtypes.advices,
- org.eclipse.papyrus.infra.extendedtypes.handler,
org.eclipse.papyrus.infra.extendedtypes.impl,
+ org.eclipse.papyrus.infra.extendedtypes.internal.spi;x-friends:="org.eclipse.papyrus.infra.extendedtypes.ui",
org.eclipse.papyrus.infra.extendedtypes.invariantcontainerconfiguration,
org.eclipse.papyrus.infra.extendedtypes.invariantcontainerconfiguration.impl,
org.eclipse.papyrus.infra.extendedtypes.invariantcontainerconfiguration.util,
org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration,
org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration.impl,
org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration.util,
- org.eclipse.papyrus.infra.extendedtypes.preferences,
- org.eclipse.papyrus.infra.extendedtypes.providers,
org.eclipse.papyrus.infra.extendedtypes.semantic,
org.eclipse.papyrus.infra.extendedtypes.types,
org.eclipse.papyrus.infra.extendedtypes.util
@@ -33,4 +27,4 @@ Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.infra.extendedtypes.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.infra.extendedtypes;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/build.properties b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/build.properties
index 0fcee5a52b8..9e8f4164078 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/build.properties
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/build.properties
@@ -7,8 +7,7 @@ bin.includes = .,\
plugin.xml,\
plugin.properties,\
schema/,\
- about.html,\
- icons/
+ about.html
jars.compile.order=.
src.includes = about.html
source.. = src-gen/,\
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/configuration.gif b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/configuration.gif
deleted file mode 100644
index 0b1be97b8cf..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/configuration.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/error.gif b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/error.gif
deleted file mode 100644
index 9b048d60532..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/icons/error.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml
index dcd66e2b8f5..43bc21c42d9 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml
@@ -10,11 +10,12 @@
<plugin>
<extension-point id="extendedElementTypeSet" name="ExtendedElementTypeSet Configuration Model" schema="schema/extendedElementTypeSet.exsd"/>
- <extension-point id="extendedElementTypeActionProvider" name="Extended Element Type Action Provider" schema="schema/extendedElementTypeActionProvider.exsd"/>
<extension-point id="extendedTypeConfiguration" name="extended type configuration" schema="schema/extendedTypeConfiguration.exsd"/>
<extension-point id="invariantRule" name="Invariant Rule Extension Point" schema="schema/invariantRule.exsd"/>
<extension-point id="elementMatcherConfiguration" name="Element Macher Configuration" schema="schema/elementMatcherConfiguration.exsd"/>
<extension-point id="aspectActionConfiguration" name="Aspect Action Configuration" schema="schema/aspectActionConfiguration.exsd"/>
+ <extension-point id="userExtendedTypes" name="User Extended Types Definitions" schema="schema/userExtendedTypes.exsd"/>
+
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated InvariantSemanticTypeConfiguration -->
<package
@@ -125,74 +126,6 @@
</binding>
</extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.ui.popup.any?after=additions">
- <command
- commandId="org.eclipse.papyrus.infra.extendedtypes.deploy"
- icon="icons/configuration.gif"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="selection">
- <iterate
- ifEmpty="false"
- operator="and">
- <adapt
- type="org.eclipse.core.resources.IFile">
- <or>
- <test
- property="org.eclipse.core.resources.extension"
- value="extendedtypes">
- </test>
- </or>
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.eclipse.papyrus.infra.extendedtypes.undeploy"
- icon="icons/configuration.gif"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="selection">
- <iterate
- ifEmpty="false"
- operator="and">
- <adapt
- type="org.eclipse.core.resources.IFile">
- <or>
- <test
- property="org.eclipse.core.resources.extension"
- value="extendedtypes">
- </test>
- </or>
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
-</menuContribution>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
- defaultHandler="org.eclipse.papyrus.infra.extendedtypes.handler.DeployExtendedTypeSetConfigurationHandler"
- id="org.eclipse.papyrus.infra.extendedtypes.deploy"
- name="Deploy Extended Types Set configuration">
- </command>
- <command
- defaultHandler="org.eclipse.papyrus.infra.extendedtypes.handler.UndeployExtendedTypeSetConfigurationHandler"
- id="org.eclipse.papyrus.infra.extendedtypes.undeploy"
- name="Disable Extended Types Set configuration">
- </command>
- </extension>
<extension
point="org.eclipse.papyrus.infra.extendedtypes.extendedTypeConfiguration">
<configuration
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd
deleted file mode 100644
index 5ddeeda67ac..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd
+++ /dev/null
@@ -1,198 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.infra.extendedtypes" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.papyrus.infra.extendedtypes" id="extendedElementTypeActionProvider" name="Extended ElementType Action Provider"/>
- </appInfo>
- <documentation>
- This extension point provides the mechanism to add providers that create aspect actions on extended element types
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="extendedElementTypeActionProvider"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="extendedElementTypeActionProvider">
- <complexType>
- <sequence>
- <element ref="Priority"/>
- </sequence>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- name of this provider, used for example in menus
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- unique identifier for this provider
- </documentation>
- </annotation>
- </attribute>
- <attribute name="description" type="string">
- <annotation>
- <documentation>
- description of the behavior of this provider
- </documentation>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
- Icon used when displaying this factory
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- This is the class that implements the provider.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.extendedtypes.providers.IExtendedElementTypeActionProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="configurationClass" type="string" use="required">
- <annotation>
- <documentation>
- Class that describes the action configuration
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="Priority">
- <annotation>
- <documentation>
- The description for the priority of the palette provider
- </documentation>
- </annotation>
- <complexType>
- <attribute name="name" use="required">
- <annotation>
- <documentation>
- The priority of the provider. It can be one of the following values:
-[Lowest, Low, Medium, High, Highest]. Consideration of dependencies has to be done when choosing the priority. A provider that adds contributions to paths (menus | groups) contributed by other providers has to have a higher priority than them. Similarly, a provider that contributes palette entries that have been predefined by other providers has to have a higher priority than them.
- </documentation>
- </annotation>
- <simpleType>
- <restriction base="string">
- <enumeration value="Lowest">
- </enumeration>
- <enumeration value="Low">
- </enumeration>
- <enumeration value="Medium">
- </enumeration>
- <enumeration value="High">
- </enumeration>
- <enumeration value="Highest">
- </enumeration>
- </restriction>
- </simpleType>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 0.7.1
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- See this plugin for some examples
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- /*****************************************************************************
- * Copyright (c) 2010 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
- </documentation>
- </annotation>
-
-</schema>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/userExtendedTypes.exsd b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/userExtendedTypes.exsd
new file mode 100644
index 00000000000..2ef22bd14e0
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/userExtendedTypes.exsd
@@ -0,0 +1,100 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.elementtypesconfigurations" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.elementtypesconfigurations" id="userExtendedTypes" name="User Extended Type Definitions"/>
+ </appInfo>
+ <documentation>
+ &lt;p&gt;
+This extension point is used to register providers of user-defined extended types.
+&lt;/p&gt;&lt;p&gt;
+&lt;b&gt;Note&lt;/b&gt; that this extension point is intended for internal use within the Papyrus
+extended-types framework only.
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="provider" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.extendedtypes.internal.spi.IUserExtendedTypesProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.&lt;br/&gt;
+&lt;br/&gt;
+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&lt;br/&gt;
+&lt;br/&gt;
+Contributors:&lt;br/&gt;
+&amp;nbsp;&amp;nbsp;CEA LIST - initial API and implementation&lt;br/&gt;
+&amp;nbsp;&amp;nbsp;Christian W. Damus - bug 485220&lt;br/&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java
index 8e6c13ddc9b..ba4815c1708 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,17 +8,19 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
/*****************************************************************************/
package org.eclipse.papyrus.infra.extendedtypes;
+import org.eclipse.core.runtime.Plugin;
import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
-public class Activator extends AbstractUIPlugin {
+public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.extendedtypes"; //$NON-NLS-1$
@@ -36,11 +37,6 @@ public class Activator extends AbstractUIPlugin {
public Activator() {
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -48,11 +44,6 @@ public class Activator extends AbstractUIPlugin {
log = new LogHelper(this);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
@Override
public void stop(BundleContext context) throws Exception {
log = null;
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AspectConfigurationFactoryRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AspectConfigurationFactoryRegistry.java
index cb2fa65454e..c8561cccb9b 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AspectConfigurationFactoryRegistry.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/AspectConfigurationFactoryRegistry.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,24 +8,20 @@
*
* Contributors:
* Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.extendedtypes;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.Dictionary;
+import static org.eclipse.papyrus.infra.extendedtypes.util.InternalUtils.loadClass;
+
import java.util.HashMap;
-import java.util.HashSet;
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.IContainerDescriptor;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
-import org.osgi.framework.Bundle;
/**
* Registry that manages all possible pre/post action configurations
@@ -274,116 +270,4 @@ public class AspectConfigurationFactoryRegistry {
}
- // /////////////////////////////////////////////////////////////////////////
- // 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/ConfigurableElementMatcherFactoryRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ConfigurableElementMatcherFactoryRegistry.java
index 7f132f6c225..22fec1b1ebe 100644
--- 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,25 +8,21 @@
*
* Contributors:
* Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.extendedtypes;
-import java.lang.ref.WeakReference;
+import static org.eclipse.papyrus.infra.extendedtypes.util.InternalUtils.loadClass;
+
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}.
@@ -133,116 +129,4 @@ public class ConfigurableElementMatcherFactoryRegistry {
}
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/ExtendedElementTypeSetRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSetRegistry.java
index 8c2dc378506..0c2aa4964ec 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSetRegistry.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSetRegistry.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2015 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,24 +8,20 @@
*
* Contributors:
* Remi Schnekenburger (CEA LIST) - Initial API and implementation
- * Christian W. Damus - bug 459174
- * Christian W. Damus - bug 459825
+ * Christian W. Damus - bugs 459174, 459825, 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.extendedtypes;
+import static org.eclipse.papyrus.infra.extendedtypes.util.InternalUtils.loadClass;
+
import java.io.IOException;
-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.Map.Entry;
import java.util.Set;
-import java.util.StringTokenizer;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
@@ -43,7 +39,6 @@ import org.eclipse.gmf.runtime.emf.type.core.internal.descriptors.IEditHelperAdv
import org.eclipse.gmf.runtime.emf.type.core.internal.impl.SpecializationTypeRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.elementtypesconfigurations.registries.ElementTypeSetConfigurationRegistry;
-import org.eclipse.papyrus.infra.extendedtypes.preferences.ExtendedTypesPreferences;
import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
import org.osgi.framework.Bundle;
@@ -131,7 +126,7 @@ public class ExtendedElementTypeSetRegistry {
}
// retrieve the path from the identifier
- String path = ExtendedTypesPreferences.getLocalExtendedTypesDefinitions().get(identifier);
+ String path = UserExtendedTypesRegistry.getInstance().getLocalExtendedTypesDefinitions().get(identifier);
if (path == null) {
return;
}
@@ -312,7 +307,7 @@ public class ExtendedElementTypeSetRegistry {
* @return
*/
protected Map<String, ExtendedElementTypeSet> loadExtendedTypeSetsFromWorkspace() {
- Map<String, String> localFilesPath = ExtendedTypesPreferences.getLocalExtendedTypesDefinitions();
+ Map<String, String> localFilesPath = UserExtendedTypesRegistry.getInstance().getLocalExtendedTypesDefinitions();
Map<String, ExtendedElementTypeSet> workspaceElementTypeSets = new HashMap<String, ExtendedElementTypeSet>();
if (localFilesPath != null && !localFilesPath.isEmpty()) {
for (Entry<String, String> idToPath : localFilesPath.entrySet()) {
@@ -381,7 +376,7 @@ public class ExtendedElementTypeSetRegistry {
*/
protected ExtendedElementTypeSet getExtendedElementTypeSet(String extendedTypesID, String modelPath, String bundleId) {
// 1. look in preferences.
- String filePath = ExtendedTypesPreferences.getExtendedTypesRedefinition(extendedTypesID);
+ String filePath = UserExtendedTypesRegistry.getInstance().getExtendedTypesRedefinition(extendedTypesID);
if (filePath != null) {
getExtendedElementTypeSetInPluginStateArea(extendedTypesID);
}
@@ -467,118 +462,6 @@ public class ExtendedElementTypeSetRegistry {
return set;
}
- // /////////////////////////////////////////////////////////////////////////
- // 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);
- }
-
/**
* @return the extendedTypeSets
*/
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/UserExtendedTypesRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/UserExtendedTypesRegistry.java
new file mode 100644
index 00000000000..e94d7291781
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/UserExtendedTypesRegistry.java
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.extendedtypes;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.Activator;
+import org.eclipse.papyrus.infra.extendedtypes.internal.spi.IUserExtendedTypesProvider;
+
+/**
+ * Registry of {@link IUserExtendedTypesProvider}s.
+ */
+class UserExtendedTypesRegistry implements IUserExtendedTypesProvider {
+
+ private static final UserExtendedTypesRegistry INSTANCE = new UserExtendedTypesRegistry();
+
+ // Only should have the one in the UI bundle
+ private final List<IUserExtendedTypesProvider> providers = new ArrayList<>(1);
+
+ private UserExtendedTypesRegistry() {
+ super();
+
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, "userExtendedTypes"); //$NON-NLS-1$
+ for (IConfigurationElement next : elements) {
+ switch (next.getName()) {
+ case "provider": //$NON-NLS-1$
+ try {
+ providers.add(createProvider(next));
+ } catch (ClassCastException e) {
+ Activator.log.error(e);
+ } catch (CoreException e) {
+ Activator.log.log(e.getStatus());
+ }
+ break;
+ }
+ }
+ }
+
+ public static UserExtendedTypesRegistry getInstance() {
+ return INSTANCE;
+ }
+
+ private IUserExtendedTypesProvider createProvider(IConfigurationElement config) throws CoreException {
+ Object result = config.createExecutableExtension("class"); //$NON-NLS-1$
+
+ if (!(result instanceof IUserExtendedTypesProvider)) {
+ throw new ClassCastException("Extension does not implement IUserExtendedTypesProvider interface in contributor " + config.getContributor().getName()); //$NON-NLS-1$
+ }
+
+ return (IUserExtendedTypesProvider) result;
+ }
+
+ @Override
+ public String getExtendedTypesRedefinition(String extendedTypesID) {
+ switch (providers.size()) {
+ case 0:
+ return null;
+ case 1:
+ return providers.get(0).getExtendedTypesRedefinition(extendedTypesID);
+ default:
+ return providers.stream()
+ .map(p -> p.getExtendedTypesRedefinition(extendedTypesID))
+ .filter(Objects::nonNull)
+ .findFirst()
+ .orElse(null);
+ }
+ }
+
+ @Override
+ public Map<String, String> getLocalExtendedTypesDefinitions() {
+ switch (providers.size()) {
+ case 0:
+ return Collections.emptyMap();
+ case 1:
+ return providers.get(0).getLocalExtendedTypesDefinitions();
+ default:
+ return providers.stream()
+ .map(IUserExtendedTypesProvider::getLocalExtendedTypesDefinitions)
+ .filter(Objects::nonNull)
+ .filter(((Predicate<? super Map<String, String>>) Map::isEmpty).negate())
+ .reduce(new HashMap<>(), (acc, elem) -> {
+ acc.putAll(elem);
+ return acc;
+ });
+ }
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/DeployExtendedTypeSetConfigurationHandler.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/DeployExtendedTypeSetConfigurationHandler.java
deleted file mode 100644
index 2b77c976537..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/DeployExtendedTypeSetConfigurationHandler.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*****************************************************************************
- * 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.handler;
-
-import java.util.Iterator;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.extendedtypes.Activator;
-import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSetRegistry;
-import org.eclipse.papyrus.infra.extendedtypes.preferences.ExtendedTypesPreferences;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-
-/**
- * Handler to deploy new configuration
- */
-public class DeployExtendedTypeSetConfigurationHandler extends AbstractHandler implements IHandler {
-
- /**
- * {@inheritDoc}
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
- return null;
- }
-
- final IStructuredSelection selection = (IStructuredSelection) currentSelection;
-
- final Shell activeShell = HandlerUtil.getActiveShell(event);
-
- Job job = new Job("Deploy extended type set configuration") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Deploying selected configurations", selection.size());
-
- return doExecute(selection, monitor);
- }
- };
-
- job.addJobChangeListener(new JobChangeAdapter() {
-
- @Override
- public void done(final IJobChangeEvent event) {
- activeShell.getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- if (event.getResult().isOK()) {
- MessageDialog.openInformation(activeShell, "Success", event.getResult().getMessage());
- } else if (event.getResult().getSeverity() < IStatus.ERROR) { // Errors are already logged
- StatusManager.getManager().handle(event.getResult(), StatusManager.SHOW);
- }
- }
- });
- }
- });
-
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- protected IStatus doExecute(IStructuredSelection selection, IProgressMonitor monitor) {
- Iterator<?> selectionIterator = selection.iterator();
-
- MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, "The properties view configuration has been successfully deployed and activated", null);
-
- while (selectionIterator.hasNext()) {
- Object selectedElement = selectionIterator.next();
- if (selectedElement instanceof IAdaptable) {
- IFile selectedFile = (IFile) ((IAdaptable) selectedElement).getAdapter(IFile.class);
- if (selectedFile == null) {
- monitor.worked(1);
- result.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The selected element is not a file"));
- continue;
- }
-
-
- String fileName = selectedFile.getFullPath().removeFileExtension().lastSegment();
- monitor.subTask("Deploy " + fileName);
-
- URI emfURI = null;
- if (selectedFile.getFullPath() != null) {
- emfURI = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);
- } else if (selectedFile.getRawLocation() != null) {
- emfURI = URI.createFileURI(selectedFile.getRawLocation().toString());
- }
-
- if (emfURI == null) {
- monitor.worked(1);
- result.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The selected element is not a valid configuration file"));
- continue;
- }
-
- ExtendedTypesPreferences.registerWorkspaceDefinition(fileName, selectedFile.getFullPath().toString());
-
- monitor.subTask("Reset Element Types Registry");
- ExtendedElementTypeSetRegistry.getInstance().loadExtendedElementTypeSet(fileName);
- monitor.worked(1);
-
- result.add(new Status(IStatus.OK, Activator.PLUGIN_ID, "The extended types configuration has been successfully deployed and activated"));
- }
- }
-
- if (result.getChildren().length == 1) {
- return result.getChildren()[0];
- } else { // Merge the result and specify an appropriate message based on the result
- if (result.isOK()) {
- return result;
- } else {
- MultiStatus actualResult = new MultiStatus(Activator.PLUGIN_ID, result.getCode(), "Some errors occurred during the deployment", result.getException());
- actualResult.merge(result);
- return actualResult;
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/UndeployExtendedTypeSetConfigurationHandler.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/UndeployExtendedTypeSetConfigurationHandler.java
deleted file mode 100644
index 0adf047882f..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/handler/UndeployExtendedTypeSetConfigurationHandler.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*****************************************************************************
- * 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.handler;
-
-import java.util.Iterator;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.extendedtypes.Activator;
-import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSetRegistry;
-import org.eclipse.papyrus.infra.extendedtypes.preferences.ExtendedTypesPreferences;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-
-/**
- * @author RS211865
- */
-public class UndeployExtendedTypeSetConfigurationHandler extends AbstractHandler {
-
- /**
- * {@inheritDoc}
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
- return null;
- }
-
- final IStructuredSelection selection = (IStructuredSelection) currentSelection;
-
- final Shell activeShell = HandlerUtil.getActiveShell(event);
-
- Job job = new Job("Undeploy extended type set configuration") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Undeploying selected configurations", selection.size());
-
- return doExecute(selection, monitor);
- }
- };
-
- job.addJobChangeListener(new JobChangeAdapter() {
-
- @Override
- public void done(final IJobChangeEvent event) {
- activeShell.getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- if (event.getResult().isOK()) {
- MessageDialog.openInformation(activeShell, "Success", event.getResult().getMessage());
- } else if (event.getResult().getSeverity() < IStatus.ERROR) { // Errors are already logged
- StatusManager.getManager().handle(event.getResult(), StatusManager.SHOW);
- }
- }
- });
- }
- });
-
- job.setUser(true);
- job.schedule();
-
- return null;
- }
-
- protected IStatus doExecute(IStructuredSelection selection, IProgressMonitor monitor) {
- Iterator<?> selectionIterator = selection.iterator();
-
- MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, "The extended types configuration has been successfully undeployed", null);
-
- while (selectionIterator.hasNext()) {
- Object selectedElement = selectionIterator.next();
- if (selectedElement instanceof IAdaptable) {
- IFile selectedFile = (IFile) ((IAdaptable) selectedElement).getAdapter(IFile.class);
- if (selectedFile == null) {
- monitor.worked(1);
- result.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The selected element is not a file"));
- continue;
- }
-
-
- String fileName = selectedFile.getFullPath().removeFileExtension().lastSegment();
- monitor.subTask("Deploy " + fileName);
-
- URI emfURI = null;
- if (selectedFile.getFullPath() != null) {
- emfURI = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);
- } else if (selectedFile.getRawLocation() != null) {
- emfURI = URI.createFileURI(selectedFile.getRawLocation().toString());
- }
-
- if (emfURI == null) {
- monitor.worked(1);
- result.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The selected element is not a valid configuration file"));
- continue;
- }
-
- ExtendedTypesPreferences.unregisterWorkspaceDefinition(fileName);
-
- monitor.subTask("Reset Element Types Registry");
- ExtendedElementTypeSetRegistry.getInstance().unload(fileName);
- monitor.worked(1);
-
- // relaunch papyrus service
-
- result.add(new Status(IStatus.OK, Activator.PLUGIN_ID, "The extended types configuration has been successfully undeployed"));
- }
- }
-
- if (result.getChildren().length == 1) {
- return result.getChildren()[0];
- } else { // Merge the result and specify an appropriate message based on the result
- if (result.isOK()) {
- return result;
- } else {
- MultiStatus actualResult = new MultiStatus(Activator.PLUGIN_ID, result.getCode(), "Some errors occurred during the undeployment", result.getException());
- actualResult.merge(result);
- return actualResult;
- }
- }
- }
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/internal/spi/IUserExtendedTypesProvider.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/internal/spi/IUserExtendedTypesProvider.java
new file mode 100644
index 00000000000..ca558417d00
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/internal/spi/IUserExtendedTypesProvider.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, 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:
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.extendedtypes.internal.spi;
+
+import java.util.Map;
+
+/**
+ * An extension protocol for providers of user-defined extended types models.
+ */
+public interface IUserExtendedTypesProvider {
+ /**
+ * Returns the path for a given extended type local redefinition
+ *
+ * @param extendedTypesID
+ * the unique identifier of the extended type to retrieve
+ * @return the path to the configuration of the extended types or <code>null</code> if no customization exists for this extended type
+ * configuration
+ */
+ String getExtendedTypesRedefinition(String extendedTypesID);
+
+ /**
+ * Returns all the paths in the workspace that should be an extended type set to load, with the id as a key
+ *
+ * @return
+ */
+ Map<String, String> getLocalExtendedTypesDefinitions();
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/RuleConfigurationFactoryRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/RuleConfigurationFactoryRegistry.java
index 0f217f29869..1f5c0f214f8 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/RuleConfigurationFactoryRegistry.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/invariantsemantictypeconfiguration/RuleConfigurationFactoryRegistry.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,24 +8,20 @@
*
* Contributors:
* Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.extendedtypes.invariantsemantictypeconfiguration;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.Dictionary;
+import static org.eclipse.papyrus.infra.extendedtypes.util.InternalUtils.loadClass;
+
import java.util.HashMap;
-import java.util.HashSet;
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.eclipse.papyrus.infra.extendedtypes.Activator;
-import org.osgi.framework.Bundle;
/**
* Registry for all matcher factories.
@@ -349,112 +345,4 @@ public class RuleConfigurationFactoryRegistry {
// /////////////////////////////////////////////////////////////////////////
// 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/preferences/ExtendedTypesPreferences.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java
deleted file mode 100644
index 3d07126e089..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.preferences;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.extendedtypes.Activator;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
-
-/**
- * Preferences management for extended types
- */
-public class ExtendedTypesPreferences {
-
- /** id for the preference store for extended types redefinitions */
- public final static String EXTENDED_TYPES_REDEFINITIONS = "extendedTypesRedefinitions"; //$NON-NLS-1$
-
- /** id for the node: extended types redefinition */
- public final static String EXTENDED_TYPES_REDEFINITION = "extendedTypesRedefinition"; //$NON-NLS-1$
-
- public static final String EXTENDED_TYPES_SET_WORKSPACE_DEFINITION = "extendedTypeSetsWorkspaceDefinition";
-
- /** name of the ID attribute */
- public final static String ID = "id"; //$NON-NLS-1$
-
- /** name for the field giving the path to the XML file */
- public final static String PATH = "path"; //$NON-NLS-1$
-
- /**
- * Returns the preference store used to store extended types preferences.
- *
- * @return the preference store of the plugin
- */
- protected static IPreferenceStore getPreferenceStore() {
- return Activator.getDefault().getPreferenceStore();
- }
-
- /**
- * Retrieves the root memento from the plugin preferences for all extended types redefinition
- * redefinitions.
- *
- * @return the root memento if there were existing customizations, a newly created one otherwise (empty one)
- */
- protected static XMLMemento getLocalRedefinitions() {
- String sValue = getPreferenceStore().getString(EXTENDED_TYPES_REDEFINITIONS);
- try {
- if (sValue != null && !sValue.equals("")) { //$NON-NLS-1$
- XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue));
- return rootMemento;
- } else {
- return XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS);
- }
- } catch (WorkbenchException e) {
- Activator.log.error("Impossible to read preferences for extended types local redefinitions", e);
- }
- return null;
- }
-
- /**
- * Register a new local redefinition of a extendedTypes.
- *
- * @param extendedTypesID
- * the id of the extendedTypes to register
- * @param path
- * the path to the configuration of the extendedTypes
- * @return the memento that has been registered
- */
- public static IMemento registerLocalRedefinition(String extendedTypesID, String path) {
- XMLMemento rootMemento = getLocalRedefinitions();
- // try to find an existing local definition for this extendedTypes
- IMemento memento = getExtendedTypesRedefinitionNode(extendedTypesID);
- // if one exists, remove it from the preferences
- if (memento != null) {
- unregisterLocalRedefinition(extendedTypesID);
- }
- // then register the new one
- IMemento newMemento = rootMemento.createChild(EXTENDED_TYPES_REDEFINITION);
- newMemento.putString(ID, extendedTypesID);
- newMemento.putString(PATH, path);
- saveLocalRedefinitions(rootMemento);
- return newMemento;
- }
-
- /**
- * Returns the memento associated to the extendedTypes, or <code>null</code> if none exists
- *
- * @param extendedTypesID
- * the identifier of the extendedTypes to find
- * @return the memento found or <code>null</code> if no customization exists for this extendedTypes
- */
- private static IMemento getExtendedTypesRedefinitionNode(String extendedTypesID) {
- XMLMemento rootMemento = getLocalRedefinitions();
- IMemento[] redefinitions = rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION);
- for (IMemento redefinitionMemento : redefinitions) {
- String extendedTypesNodeID = redefinitionMemento.getString(ID);
- // check equals. extendedTypes ID is not null, as checked at the begining of the method.
- if (extendedTypesID.equals(extendedTypesNodeID)) {
- return redefinitionMemento;
- }
- }
- return null;
- }
-
- /**
- * Returns the memento associated to the extendedTypes set definition in workspace, or <code>null</code> if none exists
- *
- * @return the memento found or <code>null</code> if no customization exists for this extendedTypes
- */
- protected static IMemento[] getWorkspaceDefinitions() {
- XMLMemento rootMemento = getLocalRedefinitions();
- IMemento[] workspaceDefinitions = rootMemento.getChildren(EXTENDED_TYPES_SET_WORKSPACE_DEFINITION);
- return workspaceDefinitions;
- }
-
- /**
- * Returns the memento associated to the extendedTypes set definition in workspace, or <code>null</code> if none exists
- *
- * @return the memento found or <code>null</code> if no customization exists for this extendedTypes
- */
- protected static IMemento getWorkspaceDefinition(String extendedTypeSetsID) {
- if (extendedTypeSetsID == null) {
- return null;
- }
- IMemento[] workspaceDefinitions = getWorkspaceDefinitions();
- if (workspaceDefinitions == null || workspaceDefinitions.length == 0) {
- return null;
- }
- for (IMemento memento : workspaceDefinitions) {
- String id = memento.getString(ID);
- if (extendedTypeSetsID.equals(id)) {
- return memento;
- }
- }
- return null;
- }
-
- /**
- * Returns the path for a given extended type local redefinition
- *
- * @param extendedTypesID
- * the unique identifier of the extended type to retrieve
- * @return the path to the configuration of the extended types or <code>null</code> if no customization exists for this extended type
- * configuration
- */
- public static String getExtendedTypesRedefinition(String extendedTypesID) {
- if (extendedTypesID == null) {
- Activator.log.debug("Trying to find preferences for a null extended type set identifier");
- }
- IMemento memento = getExtendedTypesRedefinitionNode(extendedTypesID);
- if (memento != null) {
- return memento.getString(PATH);
- }
- return null;
- }
-
- /**
- * Unregister a specific local redefinition
- *
- * @param extendedTypesID
- * the identifier of the extended types set to unregister
- */
- public static void unregisterLocalRedefinition(String extendedTypesID) {
- XMLMemento rootMemento = getLocalRedefinitions();
- // no remove method...
- // so, creation of a new root memento, then, duplicate all entries
- // except the one to
- // delete...
- XMLMemento newRootMemento = XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS);
- for (IMemento memento : rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION)) {
- if (!memento.getString(ID).equals(extendedTypesID)) {
- newRootMemento.putMemento(memento);
- }
- }
- for (IMemento memento : rootMemento.getChildren(EXTENDED_TYPES_SET_WORKSPACE_DEFINITION)) {
- newRootMemento.putMemento(memento);
- }
- // save new Memento
- saveLocalRedefinitions(newRootMemento);
- }
-
- /**
- * @param extendedTypesID
- */
- public static void unregisterWorkspaceDefinition(String extendedTypesID) {
- XMLMemento rootMemento = getLocalRedefinitions();
- // no remove method...
- // so, creation of a new root memento, then, duplicate all entries
- // except the one to
- // delete...
- XMLMemento newRootMemento = XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS);
- for (IMemento memento : rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION)) {
- newRootMemento.putMemento(memento);
- }
- for (IMemento memento : rootMemento.getChildren(EXTENDED_TYPES_SET_WORKSPACE_DEFINITION)) {
- if (!memento.getString(ID).equals(extendedTypesID)) {
- newRootMemento.putMemento(memento);
- }
- }
- // save new Memento
- saveLocalRedefinitions(newRootMemento);
- }
-
- /**
- * saves the given root memento with the given key in the preference area
- *
- * @param xmlMemento
- * the memento to save
- * @param key
- * the key for the preference store
- */
- private static void saveMemento(XMLMemento xmlMemento, String key) {
- // save memento
- StringWriter writer = new StringWriter();
- try {
- xmlMemento.save(writer);
- if (getPreferenceStore() != null) {
- getPreferenceStore().setValue(key, writer.toString());
- }
- } catch (IOException e) {
- Activator.log.error("input/ouput exception", e);
- }
- }
-
- /**
- * Saves the set of local redefinitions into the preference store
- *
- * @param rootMemento
- * the memento to save
- */
- public static void saveLocalRedefinitions(XMLMemento rootMemento) {
- saveMemento(rootMemento, EXTENDED_TYPES_REDEFINITIONS);
- }
-
- /**
- * Returns all the paths in the workspace that should be an extended type set to load, with the id as a key
- *
- * @return
- */
- public static Map<String, String> getLocalExtendedTypesDefinitions() {
- IMemento[] mementos = getWorkspaceDefinitions();
- if (mementos != null && mementos.length > 0) {
- Map<String, String> idToPath = new HashMap<String, String>();
- for (IMemento memento : mementos) {
- String id = memento.getString(ID);
- String path = memento.getString(PATH);
- if (id != null && !"".equals(id) && path != null && !"".equals(PATH)) {
- idToPath.put(id, path);
- }
- }
- return idToPath;
- }
- return null;
- }
-
- /**
- * Register a new local redefinition of a extendedTypes.
- *
- * @param extendedTypesID
- * the id of the extendedTypes to register
- * @param path
- * the path to the configuration of the extendedTypes
- * @return the memento that has been registered
- */
- public static IMemento registerWorkspaceDefinition(String extendedTypesID, String path) {
- XMLMemento rootMemento = getLocalRedefinitions();
- // try to find an existing local definition for this extendedTypes
- IMemento memento = getWorkspaceDefinition(extendedTypesID);
- // if one exists, remove it from the preferences
- if (memento != null) {
- unregisterWorkspaceDefinition(extendedTypesID);
- }
- // then register the new one
- IMemento newMemento = rootMemento.createChild(EXTENDED_TYPES_SET_WORKSPACE_DEFINITION);
- newMemento.putString(ID, extendedTypesID);
- newMemento.putString(PATH, path);
- saveLocalRedefinitions(rootMemento);
- return newMemento;
- }
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java
deleted file mode 100644
index 2d991ee9c4a..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.providers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.service.ExecutionStrategy;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.core.service.IProvider;
-import org.eclipse.gmf.runtime.common.core.service.Service;
-import org.eclipse.gmf.runtime.common.ui.services.util.ActivityFilterProviderDescriptor;
-import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration;
-import org.eclipse.papyrus.infra.extendedtypes.Activator;
-
-
-/**
- * Service to retrieve the provider giving the command for a specific {@link ActionConfiguration}
- */
-public class ExtendedElementTypeActionService extends Service {
-
- /** singleton instance of this service */
- protected final static ExtendedElementTypeActionService instance = new ExtendedElementTypeActionService();
-
- /**
- * initialize the service
- */
- static {
- instance.configureProviders(Activator.PLUGIN_ID, "extendedElementTypeActionProvider"); //$NON-NLS-1$
- }
-
- /**
- * Default constructor.
- */
- protected ExtendedElementTypeActionService() {
-
- }
-
- /**
- * Returns the singleton instance of this service
- *
- * @return the singleton instance of this service
- */
- synchronized public static ExtendedElementTypeActionService getInstance() {
- return instance;
- }
-
- /**
- * @see org.eclipse.gmf.runtime.common.core.service.Service#newProviderDescriptor(org.eclipse.core.runtime.IConfigurationElement)
- */
- @Override
- protected Service.ProviderDescriptor newProviderDescriptor(IConfigurationElement element) {
- return new ProviderDescriptor(element);
- }
-
- /**
- * Returns all providers in the service
- *
- * @return the list of providers found or an empty list.
- */
- public List<IExtendedElementTypeActionProvider> getProviders() {
- List<IExtendedElementTypeActionProvider> providers = new ArrayList<IExtendedElementTypeActionProvider>();
- execute(ExecutionStrategy.REVERSE, new GetAllExtendedElementTypeActionProvidersOperation(providers));
- return providers;
- }
-
- /**
- * Returns the provider with the given identifier
- *
- * @param actionConfiguration
- * the actionConfiguration for the provider to retrieve
- * @return the provider found or <code>null</code>.
- */
- public IExtendedElementTypeActionProvider getProvider(ActionConfiguration actionConfiguration) {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- List<IExtendedElementTypeActionProvider> providers = execute(ExecutionStrategy.REVERSE, new GetExtendedElementTypeActionProviderOperation(actionConfiguration));
- Iterator<IExtendedElementTypeActionProvider> it = providers.iterator();
- while (it.hasNext()) {
- IExtendedElementTypeActionProvider aspectActionProvider = it.next();
- if (aspectActionProvider != null) {
- return aspectActionProvider;
- }
- }
- return null; // backward compatibility
- }
-
- /**
- * Returns the command for the given {@link ActionConfiguration}.
- *
- * @param elementsToEdit
- * list of elements to edit
- *
- * @param configuration
- * the configuration of the action
- * @return the {@link ICommand} configured by the parameter or <code>null</code>.
- * @throws ProviderNotFoundException
- * exception thrown when the provider was not found for this configuration
- */
- public ICommand getICommand(List<? extends Object> elementsToEdit, ActionConfiguration configuration) throws ProviderNotFoundException {
- IExtendedElementTypeActionProvider provider = getProvider(configuration);
- if (provider != null) {
- return provider.getICommand(elementsToEdit, configuration);
- }
- throw new ProviderNotFoundException(configuration);
- }
-
- /**
- * Returns the command for the given {@link ActionConfiguration}.
- *
- * @param elementsToEdit
- * list of elements to edit
- *
- * @param configuration
- * the configuration of the action
- * @return the {@link ICommand} configured by the parameter or <code>null</code>.
- * @throws ProviderNotFoundException
- * exception thrown when the provider was not found for this configuration
- */
- public ICommand getPreValidationCommand(List<? extends Object> elementsToEdit, ActionConfiguration configuration) throws ProviderNotFoundException {
- IExtendedElementTypeActionProvider provider = getProvider(configuration);
- if (provider != null) {
- return provider.getBeforeCreateValidationCommand(elementsToEdit, configuration);
- }
- throw new ProviderNotFoundException(configuration);
- }
-
- /**
- * A descriptor for aspect tool providers defined by a configuration element.
- */
- protected static class ProviderDescriptor extends ActivityFilterProviderDescriptor {
-
- /** the provider configuration parsed from XML */
- protected ExtentedElementTypeActionProviderConfiguration providerConfiguration;
-
- /**
- * Constructs a <code>ISemanticProvider</code> descriptor for
- * the specified configuration element.
- *
- * @param element
- * The configuration element describing the provider.
- */
- public ProviderDescriptor(IConfigurationElement element) {
- super(element);
- this.providerConfiguration = ExtentedElementTypeActionProviderConfiguration.parse(element);
- Assert.isNotNull(providerConfiguration);
- }
-
- /**
- * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)
- */
- @Override
- public boolean provides(IOperation operation) {
- if (!super.provides(operation)) {
- return false;
- }
- if (operation instanceof GetAllExtendedElementTypeActionProvidersOperation) {
- return true;
- }
- if (operation instanceof GetExtendedElementTypeActionProviderOperation) {
- String providerConfigurationClassName = providerConfiguration.getConfigurationClassName();
- if (providerConfigurationClassName == null) {
- Activator.log.error("Error during the parsing of the action configuration extension point", null);
- return false;
- }
- String configurationClassName = ((GetExtendedElementTypeActionProviderOperation) operation).getActionConfiguration().eClass().getInstanceClassName();
- return providerConfigurationClassName.equals(configurationClassName);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.gmf.runtime.common.core.service.Service.ProviderDescriptor#getProvider()
- */
- @Override
- public IProvider getProvider() {
- if (provider == null) {
- IProvider newProvider = super.getProvider();
- if (provider instanceof IExtendedElementTypeActionProvider) {
- IExtendedElementTypeActionProvider defaultProvider = (IExtendedElementTypeActionProvider) newProvider;
- defaultProvider.setConfiguration(getElement());
- }
- return newProvider;
- }
- return super.getProvider();
- }
- }
-
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java
deleted file mode 100644
index 5c0bb334e56..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.providers;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProviderConfiguration;
-
-/**
- * Provider configuration for the aspect tool factory extension point.
- */
-public class ExtentedElementTypeActionProviderConfiguration extends AbstractProviderConfiguration {
-
- /** field for provider class name */
- protected static final String CLASS = "class";
-
- /** field for configuration class name */
- private static final String CONFIGURATION_CLASS = "configurationClass";
-
- /** class name of the provider */
- protected final String className;
-
- /** class name of the configuration */
- private final String configurationClassName;
-
- /**
- * Creates and builds a new provider contribution descriptor by parsing its configuration element.
- *
- * @param configElement
- * A provider XML configuration element
- * @return A provider XML contribution descriptor
- */
- public static ExtentedElementTypeActionProviderConfiguration parse(IConfigurationElement configElement) {
- Assert.isNotNull(configElement, "null provider configuration element"); //$NON-NLS-1$
- return new ExtentedElementTypeActionProviderConfiguration(configElement);
- }
-
- /**
- * Creates a new <code>ProviderContributionDescriptor</code> instance
- * by parsing its configuration element.
- *
- * @param configElement
- * The provider XML configuration element
- */
- protected ExtentedElementTypeActionProviderConfiguration(IConfigurationElement configElement) {
- // retrieve only ID, to test if the factory is the right one before creating whole element
- className = configElement.getAttribute(CLASS);
- Assert.isNotNull(className, "impossible to get the class name for the provider");
-
- configurationClassName = configElement.getAttribute(CONFIGURATION_CLASS);
- Assert.isNotNull(className, "impossible to get the class name for the provider");
- }
-
-
- /**
- * Returns the class name of the provider configured by this configuration
- *
- * @return the id of the factory
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * Name of the configuration class
- *
- * @return the configuration Class Name
- */
- public String getConfigurationClassName() {
- return configurationClassName;
- }
-
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java
deleted file mode 100644
index c4bde78e783..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.providers;
-
-import java.util.List;
-
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.core.service.IProvider;
-
-
-/**
- * Operation that returns all providers for the {@link ExtendedElementTypeActionService}.
- */
-public class GetAllExtendedElementTypeActionProvidersOperation implements IOperation {
-
- /** list of providers to fill */
- private final List<IExtendedElementTypeActionProvider> providers;
-
- /**
- * Creates a new GetAllExtendedElementTypeActionProvidersOperation.
- *
- * @param providers
- * the list of providers to fill
- */
- public GetAllExtendedElementTypeActionProvidersOperation(List<IExtendedElementTypeActionProvider> providers) {
- this.providers = providers;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object execute(IProvider provider) {
- if (provider instanceof IExtendedElementTypeActionProvider) {
- providers.add((IExtendedElementTypeActionProvider) provider);
- }
- return providers;
- }
-
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java
deleted file mode 100644
index e2498fe4564..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.providers;
-
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.core.service.IProvider;
-import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration;
-
-
-/**
- * Operation that returns the first provider with given id
- */
-public class GetExtendedElementTypeActionProviderOperation implements IOperation {
-
- /** action configuration for the provider to find */
- private final ActionConfiguration actionConfiguration;
-
- /**
- * Creates a new {@link GetExtendedElementTypeActionProviderOperation}.
- *
- * @param actionConfiguration
- * action configuration for the provider to find
- */
- public GetExtendedElementTypeActionProviderOperation(ActionConfiguration actionConfiguration) {
- this.actionConfiguration = actionConfiguration;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object execute(IProvider provider) {
- return provider;
- }
-
- /**
- * Returns the action configuration for this operation
- *
- * @return the action configuration for this operation
- */
- public ActionConfiguration getActionConfiguration() {
- return actionConfiguration;
- }
-
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java
deleted file mode 100644
index ef5cd74870e..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.providers;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.service.IProvider;
-import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration;
-
-
-/**
- * Provider for extended element types action
- */
-public interface IExtendedElementTypeActionProvider extends IProvider {
-
- /**
- * Returns the command to execute for the given configuration
- *
- * @param elementsToEdit
- * list of elements to edit
- *
- * @param configuration
- * the configuration for the command
- *
- * @return the command to execute for the given configuration
- */
- public ICommand getICommand(List<? extends Object> elementsToEdit, ActionConfiguration configuration);
-
- /**
- * Returns the command to execute for the given configuration to check if it will be executable
- *
- * @param elementsToEdit
- * list of elements to edit
- *
- * @param configuration
- * the configuration for the command
- *
- * @return the command to execute for the given configuration. should do nothing on the model (either null or identity command), only return an
- * Unexecutable command if creation is not allowed
- */
- public ICommand getBeforeCreateValidationCommand(List<? extends Object> elementsToEdit, ActionConfiguration configuration);
-
- /**
- * Sets the configuration for this provider, given the configuration element
- *
- * @param element
- * the element that configures this provider
- */
- public void setConfiguration(IConfigurationElement element);
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java
deleted file mode 100644
index b1ebded1443..00000000000
--- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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) remi.schnekenburger@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.extendedtypes.providers;
-
-import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration;
-
-
-/**
- * Exception thrown when a provider was not found
- */
-public class ProviderNotFoundException extends Exception {
-
- /** serial UID */
- private static final long serialVersionUID = 8919294410894098831L;
-
- /**
- * Constructor.
- *
- * @param configuration
- * the configuration for which a provider was searched
- *
- */
- public ProviderNotFoundException(ActionConfiguration configuration) {
- super();
- }
-
-}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/InternalUtils.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/InternalUtils.java
new file mode 100644
index 00000000000..8ae43cff4e3
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/InternalUtils.java
@@ -0,0 +1,157 @@
+/*****************************************************************************
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, 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:
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.extendedtypes.util;
+
+import java.lang.ref.WeakReference;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+/**
+ * Utilities for internal use by rthe ExtendedTypes bundle.
+ */
+public class InternalUtils {
+
+ /** 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>>();
+
+ private InternalUtils() {
+ super();
+ }
+
+ /**
+ * 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
+ */
+ public static Class<?> loadClass(String className, String pluginId) {
+ // FIXME: This method is grossly flawed, as it requires the class being loaded to be contained within the identified bundle, not anywhere on its classpath
+ 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;
+ }
+
+ 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();
+ int index = -1;
+ String value = dict.get("Bundle-ActivationPolicy"); //$NON-NLS-1$
+ if (value != null) {
+ index = value.indexOf("lazy"); //$NON-NLS-1$
+ if (index >= 0) {
+ index = value.indexOf("exclude", index); //$NON-NLS-1$
+ }
+ }
+ if (index < 0) {
+ // Try the (very) old way
+ value = dict.get("Eclipse-LazyStart"); //$NON-NLS-1$
+ if (value != null) {
+ index = value.indexOf("exceptions"); //$NON-NLS-1$
+ }
+ }
+ if (index >= 0) {
+ 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();
+ }
+ bundleToExceptionsSetMap.put(bundle, exceptionSet);
+ }
+ return exceptionSet.contains(packageName);
+ }
+
+ /**
+ * 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
+ */
+ private 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);
+ }
+
+}

Back to the top