Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2017-05-12 13:59:58 +0000
committerPierre-Charles David2017-05-16 08:34:40 +0000
commit17bd04bc9985a6a2576a9fafe57a6de91bdd298a (patch)
treec00970632c0686c7edc3b36f7c5d361f676c1433
parentb57cf3a40deb5d33527bd66c737903dff4f186a5 (diff)
downloadorg.eclipse.sirius-17bd04bc9985a6a2576a9fafe57a6de91bdd298a.tar.gz
org.eclipse.sirius-17bd04bc9985a6a2576a9fafe57a6de91bdd298a.tar.xz
org.eclipse.sirius-17bd04bc9985a6a2576a9fafe57a6de91bdd298a.zip
[514682] Add extension point to contribute meta-data to EPackages/metamodels
Bug: 514682 Change-Id: Ia4b8a5668bd4fb7952ef6f18b4b4da2935805489 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.common/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.sirius.common/plugin.properties1
-rw-r--r--plugins/org.eclipse.sirius.common/plugin.xml1
-rw-r--r--plugins/org.eclipse.sirius.common/plugin_fr.properties1
-rw-r--r--plugins/org.eclipse.sirius.common/schema/package_meta_data.exsd116
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/DslCommonPlugin.java39
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/ecore/EPackageMetaData.java114
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistry.java68
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistryReader.java145
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html4
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile1
11 files changed, 482 insertions, 9 deletions
diff --git a/plugins/org.eclipse.sirius.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.common/META-INF/MANIFEST.MF
index 5675897af5..7c81095066 100644
--- a/plugins/org.eclipse.sirius.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.sirius.common/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.sirius.ecore.extender;bundle-version="2.0.0",
Export-Package: org.eclipse.sirius.common.tools;version="3.0.0",
org.eclipse.sirius.common.tools.api.constant;version="2.0.4",
org.eclipse.sirius.common.tools.api.contentassist;version="2.1.0",
+ org.eclipse.sirius.common.tools.api.ecore;version="5.0.0",
org.eclipse.sirius.common.tools.api.editing;version="2.0.4",
org.eclipse.sirius.common.tools.api.find;version="3.0.0",
org.eclipse.sirius.common.tools.api.interpreter;version="3.2.0",
diff --git a/plugins/org.eclipse.sirius.common/plugin.properties b/plugins/org.eclipse.sirius.common/plugin.properties
index 02606ecdab..ce3c217b70 100644
--- a/plugins/org.eclipse.sirius.common/plugin.properties
+++ b/plugins/org.eclipse.sirius.common/plugin.properties
@@ -19,6 +19,7 @@ extension-point.expressionInterpreter.name = org.eclipse.sirius.common.expressio
extension-point.fileModificationValidator.name = File Modification Validator
extension-point.proposalProvider.name = org.eclipse.sirius.common.proposalProvider
extension-point.resourceSetFactory.name = org.eclipse.sirius.common.resourceSetFactory
+extension-point.package_meta_data.name=org.eclipse.sirius.common.package_meta_data
BundleClassLoading_ignoredEPackageDeclaration = An EPackage declaration in project {0} has been ignored because of missing informations.
ClassLoadingService_multipleOverridesDetected = Several overrides are contributed for the class loading override, {0} will be ignored
diff --git a/plugins/org.eclipse.sirius.common/plugin.xml b/plugins/org.eclipse.sirius.common/plugin.xml
index ea325b0acf..f273e12f15 100644
--- a/plugins/org.eclipse.sirius.common/plugin.xml
+++ b/plugins/org.eclipse.sirius.common/plugin.xml
@@ -20,6 +20,7 @@
<extension-point id="fileModificationValidator" name="%extension-point.fileModificationValidator.name" schema="schema/fileModificationValidator.exsd"/>
<extension-point id="resourceSetFactory" name="%extension-point.resourceSetFactory.name" schema="schema/resourceSetFactory.exsd"/>
<extension-point id="classloading_override" name="%extension-point.classloading_override.name" schema="schema/classloading_override.exsd"/>
+ <extension-point id="package_meta_data" name="%extension-point.package_meta_data.name" schema="schema/package_meta_data.exsd"/>
<extension id="org.eclipse.sirius.common.variableInterpreter" point="org.eclipse.sirius.common.expressionInterpreter">
<expressionInterpreterProvider interpreterProviderClass="org.eclipse.sirius.common.tools.internal.interpreter.VariableInterpreter" />
diff --git a/plugins/org.eclipse.sirius.common/plugin_fr.properties b/plugins/org.eclipse.sirius.common/plugin_fr.properties
index c7b63beb4f..b6148ceef6 100644
--- a/plugins/org.eclipse.sirius.common/plugin_fr.properties
+++ b/plugins/org.eclipse.sirius.common/plugin_fr.properties
@@ -19,6 +19,7 @@ extension-point.expressionInterpreter.name = org.eclipse.sirius.common.expressio
extension-point.fileModificationValidator.name = File Modification Validator
extension-point.proposalProvider.name = org.eclipse.sirius.common.proposalProvider
extension-point.resourceSetFactory.name = org.eclipse.sirius.common.resourceSetFactory
+extension-point.package_meta_data.name=org.eclipse.sirius.common.package_meta_data
BundleClassLoading_ignoredEPackageDeclaration = An EPackage declaration in project {0} has been ignored because of missing informations.
ClassLoadingService_multipleOverridesDetected = Several overrides are contributed for the class loading override, {0} will be ignored
diff --git a/plugins/org.eclipse.sirius.common/schema/package_meta_data.exsd b/plugins/org.eclipse.sirius.common/schema/package_meta_data.exsd
new file mode 100644
index 0000000000..7fb42f59a2
--- /dev/null
+++ b/plugins/org.eclipse.sirius.common/schema/package_meta_data.exsd
@@ -0,0 +1,116 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.sirius.common" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.sirius.common" id="package_meta_data" name="EPackage Meta Data"/>
+ </appInfo>
+ <documentation>
+ This extension point can be used to associate extra meta-data (label, documentation, preferred root element) to an EMF EPackage.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="ePackageMetaData"/>
+ </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>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="ePackageMetaData">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="suggestedRoot"/>
+ </sequence>
+ <attribute name="nsURI" type="string" use="required">
+ <annotation>
+ <documentation>
+ The nsURI of the EPackage this applies to.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="displayName" type="string">
+ <annotation>
+ <documentation>
+ A human readable label to associate to the EPackage.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="documentation" type="string">
+ <annotation>
+ <documentation>
+ Documentation to associate to the EPackage. Will be rendered as HTML.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="suggestedRoot">
+ <complexType>
+ <attribute name="className" type="string">
+ <annotation>
+ <documentation>
+ The name of an EClass which is a good candidate for being the root element of a model. The named class must be contained directly in the EPackage.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 5.0.0
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2017 Obeo.
+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:
+ Obeo - initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/DslCommonPlugin.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/DslCommonPlugin.java
index e377307a93..b9208f2280 100644
--- a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/DslCommonPlugin.java
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/DslCommonPlugin.java
@@ -16,12 +16,15 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.sirius.common.tools.api.ecore.EPackageMetaData;
import org.eclipse.sirius.common.tools.api.editing.EditingDomainFactoryRegistry;
import org.eclipse.sirius.common.tools.api.profiler.TimeProfiler;
import org.eclipse.sirius.common.tools.api.profiler.TimeProfiler2;
import org.eclipse.sirius.common.tools.internal.assist.ProposalProviderRegistry;
import org.eclipse.sirius.common.tools.internal.assist.ProposalProviderRegistryListener;
import org.eclipse.sirius.common.tools.internal.ecore.DynamicPackageRegistryReader;
+import org.eclipse.sirius.common.tools.internal.ecore.EPackageMetaDataRegistry;
+import org.eclipse.sirius.common.tools.internal.ecore.EPackageMetaDataRegistryReader;
import org.eclipse.sirius.common.tools.internal.editing.EditingDomainFactoryRegistryListener;
import org.osgi.framework.BundleContext;
@@ -34,7 +37,7 @@ public class DslCommonPlugin extends EMFPlugin {
/** The plugin id. */
public static final String PLUGIN_ID = "org.eclipse.sirius.common"; //$NON-NLS-1$
-
+
/** Keep track of the singleton.. */
public static final DslCommonPlugin INSTANCE = new DslCommonPlugin();
@@ -43,6 +46,8 @@ public class DslCommonPlugin extends EMFPlugin {
private static Implementation plugin;
+ private final EPackageMetaDataRegistry metaDataRegistry = new EPackageMetaDataRegistry();
+
/**
* The constructor.
*/
@@ -56,6 +61,17 @@ public class DslCommonPlugin extends EMFPlugin {
}
/**
+ * Returns tha extra meta-data associated to a given EPackage.
+ *
+ * @param nsURI
+ * the nsURI of the EPackage.
+ * @return extra meta-data associated to the EPackage.
+ */
+ public EPackageMetaData getEPackageMetaData(String nsURI) {
+ return metaDataRegistry.getExtraData(nsURI);
+ }
+
+ /**
* Returns the singleton instance of the Eclipse plugin.
*
* @return the singleton instance.
@@ -70,18 +86,21 @@ public class DslCommonPlugin extends EMFPlugin {
public static class Implementation extends EclipsePlugin {
/**
- * The registry listener that will be used to listen to extension
- * changes.
+ * The registry listener that will be used to listen to extension changes.
*/
private EditingDomainFactoryRegistryListener editingDomainFactoryRegistryListener = new EditingDomainFactoryRegistryListener();
/**
- * The registry listener that will be used to react to changes against
- * the proposal providers extension point.
+ * The registry listener that will be used to react to changes against the proposal providers extension point.
*/
private final ProposalProviderRegistryListener proposalProviderRegistryListener = new ProposalProviderRegistryListener();
/**
+ * The registry of known EPackageMetaData.
+ */
+ private EPackageMetaDataRegistryReader packageMetaDataRegistryReader;
+
+ /**
* Creates an instance.
*/
public Implementation() {
@@ -93,11 +112,12 @@ public class DslCommonPlugin extends EMFPlugin {
super.start(context);
initExtensionRegistries();
new DynamicPackageRegistryReader().readRegistry();
+ packageMetaDataRegistryReader = new EPackageMetaDataRegistryReader(Platform.getExtensionRegistry(), DslCommonPlugin.INSTANCE.metaDataRegistry);
+ packageMetaDataRegistryReader.start();
}
/**
- * Initializes the extension registries and their listeners for this
- * plugin.
+ * Initializes the extension registries and their listeners for this plugin.
*/
private void initExtensionRegistries() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -111,13 +131,14 @@ public class DslCommonPlugin extends EMFPlugin {
@Override
public void stop(final BundleContext context) throws Exception {
+ packageMetaDataRegistryReader.stop();
+ packageMetaDataRegistryReader = null;
super.stop(context);
clearExtensionRegistries();
}
/**
- * Clears the extension registries for this plugin and remove their
- * corresponding listeners.
+ * Clears the extension registries for this plugin and remove their corresponding listeners.
*/
private void clearExtensionRegistries() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/ecore/EPackageMetaData.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/ecore/EPackageMetaData.java
new file mode 100644
index 0000000000..a4b5c580af
--- /dev/null
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/ecore/EPackageMetaData.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.common.tools.api.ecore;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represent extra meta-data that can be associated to an EPackage but that are not modeled in Ecore.
+ *
+ * @author pcdavid
+ */
+public class EPackageMetaData {
+ /**
+ * The nsURI of the EPackage this applies to. We use an nsURI instead of an EPackage to avoid loading the metamodel
+ * (and the plug-in that defines it) if possible.
+ */
+ private final String nsURI;
+
+ /**
+ * The name to display to end-users, which may be different from the technical EPackage.name.
+ */
+ private String displayName;
+
+ /**
+ * User-oriented documentation for the metamodel defined by the EPackage.
+ */
+ private String documentation;
+
+ /**
+ * Names of EClasses from the EPackage that are good candidates as root model elements.
+ */
+ private List<String> suggestedRoots = new ArrayList<>();
+
+ /**
+ * Create a new EPackageExtraData.
+ *
+ * @param nsURI
+ * the nsURI of the EPackage this applies to..
+ */
+ public EPackageMetaData(String nsURI) {
+ this.nsURI = nsURI;
+ }
+
+ /**
+ * The nsURI of the EPackage this meta-data applies to.
+ *
+ * @return the nsURI of the EPackage.
+ */
+ public String getNsURI() {
+ return nsURI;
+ }
+
+ /**
+ * Returns the name to display to end-users, which may be different from the technical EPackage.name.
+ *
+ * @return the name to display to end-users.
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Set the name to display to end-users, which may be different from the technical EPackage.name.
+ *
+ * @param displayName
+ * the name to display to end-users.
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ /**
+ * Returns the user-oriented documentation for the metamodel defined by the EPackage.
+ *
+ * @return the user-oriented documentation for the metamodel.
+ */
+ public String getDocumentation() {
+ return documentation;
+ }
+
+ /**
+ * Set the user-oriented documentation for the metamodel defined by the EPackage.
+ *
+ * @param documentation
+ * the user-oriented documentation for the metamodel.
+ */
+ public void setDocumentation(String documentation) {
+ this.documentation = documentation;
+ }
+
+ /**
+ * Returns the names of EClasses from the EPackage that are good candidates as root model elements.
+ *
+ * @return the names of good root model types.
+ */
+ public List<String> getSuggestedRoots() {
+ return suggestedRoots;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("#<EPackageMetaData %s>", nsURI); //$NON-NLS-1$
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistry.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistry.java
new file mode 100644
index 0000000000..1b2cadb858
--- /dev/null
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistry.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.common.tools.internal.ecore;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.sirius.common.tools.api.ecore.EPackageMetaData;
+import org.eclipse.sirius.common.tools.api.util.StringUtil;
+
+/**
+ * A plain registry of {@link EPackageMetaData}, independent on where the source data come from.
+ *
+ * @author pcdavid
+ */
+public class EPackageMetaDataRegistry {
+
+ private final Map<String, EPackageMetaData> entries = new HashMap<>();
+
+ /**
+ * Registers a new {@link EPackageMetaData}.
+ *
+ * @param data
+ * the {@link EPackageMetaData}
+ */
+ public synchronized void register(EPackageMetaData data) {
+ entries.put(data.getNsURI(), data);
+ }
+
+ /**
+ * Unregisters the {@link EPackageMetaData} for a specific nsURI. Does nothing if not {@link EPackageMetaData} is
+ * registered for this URI.
+ *
+ * @param nsURI
+ * the nsURI of the entry to remove.
+ */
+ public synchronized void unregister(String nsURI) {
+ if (!StringUtil.isEmpty(nsURI)) {
+ entries.remove(nsURI);
+ }
+ }
+
+ /**
+ * Unregisters all known {@link EPackageMetaData}.
+ */
+ public synchronized void clear() {
+ entries.clear();
+ }
+
+ /**
+ * Returns the extra data associated to the specified nsURI, if any.
+ *
+ * @param nsURI
+ * the nsURI of the EPackage to look for.
+ * @return the associated extra data, may be <code>null</code>.
+ */
+ public synchronized EPackageMetaData getExtraData(String nsURI) {
+ return entries.get(nsURI);
+ }
+}
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistryReader.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistryReader.java
new file mode 100644
index 0000000000..576e828d05
--- /dev/null
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/internal/ecore/EPackageMetaDataRegistryReader.java
@@ -0,0 +1,145 @@
+/**
+ * Copyright (c) 2017 Obeo
+ * 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:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.sirius.common.tools.internal.ecore;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IRegistryEventListener;
+import org.eclipse.sirius.common.tools.api.ecore.EPackageMetaData;
+import org.eclipse.sirius.common.tools.api.util.StringUtil;
+
+/**
+ * Feeds an EPackageMetaDataRegistry from extension point configuration data.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ * @author pcdavid
+ */
+public class EPackageMetaDataRegistryReader {
+
+ /** Extension-point ID. */
+ private static final String EPACKAGE_META_DATA_EXTENSION_POINT = "org.eclipse.sirius.common.package_meta_data"; //$NON-NLS-1$
+
+ private static final String EPACKAGE_META_DATA_ELEMENT = "ePackageMetaData"; //$NON-NLS-1$
+
+ /** nsURI attribute. */
+ private static final String NS_URI_ATTRIBUTE = "nsURI"; //$NON-NLS-1$
+
+ /** Display name attribute. */
+ private static final String DISPLAY_NAME_ATTRIBUTE = "displayName"; //$NON-NLS-1$
+
+ /** Documentation attribute. */
+ private static final String DOCUMENTATION_ATTRIBUTE = "documentation"; //$NON-NLS-1$
+
+ /** Preferred root element attribute. */
+ private static final String SUGGESTED_ROOT_ELEMENT = "suggestedRoot"; //$NON-NLS-1$
+
+ private static final String SUGGESTED_ROOT_CLASS_NAME_ATTRIBUTE = "className"; //$NON-NLS-1$
+
+ private final IExtensionRegistry extensionRegistry;
+
+ private final EPackageMetaDataRegistry metaDataRegistry;
+
+ private IRegistryEventListener listener = new EPackageExtraDataListener();
+
+ /**
+ * Creates a new EPackageExtraDataRegistry reading from the specified registry.
+ *
+ * @param extRegistry
+ * the registry to read configuration from.
+ * @param mdRegistry
+ * the registry to register package metadata into.
+ */
+ public EPackageMetaDataRegistryReader(IExtensionRegistry extRegistry, EPackageMetaDataRegistry mdRegistry) {
+ this.extensionRegistry = extRegistry;
+ this.metaDataRegistry = mdRegistry;
+ }
+
+ /**
+ * Initialize the regsitry and start listening for dynamic changes.
+ */
+ public synchronized void start() {
+ for (IConfigurationElement cfg : extensionRegistry.getConfigurationElementsFor(EPACKAGE_META_DATA_EXTENSION_POINT)) {
+ EPackageMetaData data = parse(cfg);
+ if (data != null) {
+ metaDataRegistry.register(data);
+ }
+ }
+ this.extensionRegistry.addListener(listener, EPACKAGE_META_DATA_EXTENSION_POINT);
+ }
+
+ /**
+ * Clears the registry and stop listening for dynamic changes.
+ */
+ public synchronized void stop() {
+ this.extensionRegistry.removeListener(listener);
+ metaDataRegistry.clear();
+ }
+
+ private EPackageMetaData parse(IConfigurationElement cfg) {
+ if (EPACKAGE_META_DATA_ELEMENT.equals(cfg.getName())) {
+ EPackageMetaData result = new EPackageMetaData(cfg.getAttribute(NS_URI_ATTRIBUTE));
+ result.setDisplayName(cfg.getAttribute(DISPLAY_NAME_ATTRIBUTE));
+ result.setDocumentation(cfg.getAttribute(DOCUMENTATION_ATTRIBUTE));
+ for (IConfigurationElement child : cfg.getChildren(SUGGESTED_ROOT_ELEMENT)) {
+ String className = child.getAttribute(SUGGESTED_ROOT_CLASS_NAME_ATTRIBUTE);
+ if (!StringUtil.isEmpty(className)) {
+ result.getSuggestedRoots().add(className.trim());
+ }
+ }
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ private final class EPackageExtraDataListener implements IRegistryEventListener {
+ @Override
+ public void added(IExtension[] extensions) {
+ synchronized (EPackageMetaDataRegistryReader.this) {
+ for (IExtension ext : extensions) {
+ for (IConfigurationElement cfg : ext.getConfigurationElements()) {
+ EPackageMetaData data = parse(cfg);
+ if (data != null) {
+ metaDataRegistry.register(data);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void removed(IExtension[] extensions) {
+ synchronized (EPackageMetaDataRegistryReader.this) {
+ for (IExtension ext : extensions) {
+ for (IConfigurationElement cfg : ext.getConfigurationElements()) {
+ if (EPACKAGE_META_DATA_ELEMENT.equals(cfg.getName())) {
+ String nsURI = cfg.getAttribute(NS_URI_ATTRIBUTE);
+ metaDataRegistry.unregister(nsURI);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void removed(IExtensionPoint[] extensionPoints) {
+ // no need to listen to this event
+ }
+
+ @Override
+ public void added(IExtensionPoint[] extensionPoints) {
+ // no need to listen to this event
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 8178cc4d02..3bb32dbbe9 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -257,6 +257,10 @@
<li><span class="label label-success">Added</span>
<code>org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl.isIncluded(EReference)</code> has been overridden to consider features in the white list.
</li>
+ <li><span class="label label-success">Added</span> A new extension point,
+ <code>org.eclipse.sirius.common.package_meta_data</code> has been added. It can be used to associate user-oriented meta-data to Ecore metamodels, identified by their
+ <code>nsURI</code>: a user-oriented name/label (as opposed to the technical nsURI), a (short) description/documentation, and a list of suggested EClasses defined in the EPackage that are good candidates as root model elements.
+ </li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.common.ui">Changes in
<code>org.eclipse.sirius.common.ui</code>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 05e461b8f0..db2e5793b1 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -58,6 +58,7 @@ h4. Changes in @org.eclipse.sirius.common@
* <span class="label label-success">Added</span> @org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl.setFeatureToBeCrossReferencedWhiteList(Collection<EReference>)@ to set a white list of references that must be referenced even if the reference is derived.
* <span class="label label-success">Added</span> @org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl.isIncluded(EReference)@ has been overridden to consider features in the white list.
+* <span class="label label-success">Added</span> A new extension point, @org.eclipse.sirius.common.package_meta_data@ has been added. It can be used to associate user-oriented meta-data to Ecore metamodels, identified by their @nsURI@: a user-oriented name/label (as opposed to the technical nsURI), a (short) description/documentation, and a list of suggested EClasses defined in the EPackage that are good candidates as root model elements.
h4. Changes in @org.eclipse.sirius.common.ui@

Back to the top