Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-02-11 02:48:20 +0000
committerGerrit Code Review @ Eclipse.org2016-02-12 15:31:41 +0000
commitecd4928b327f5561364c5068c9ff5f1668e92d13 (patch)
tree7c34f46cf82a1d65ac753fa92c2a5d55371b8dba /plugins/infra/emf/org.eclipse.papyrus.infra.emf
parent751a204d74e15eb2db6b41c937691fc56dcc1252 (diff)
downloadorg.eclipse.papyrus-ecd4928b327f5561364c5068c9ff5f1668e92d13.tar.gz
org.eclipse.papyrus-ecd4928b327f5561364c5068c9ff5f1668e92d13.tar.xz
org.eclipse.papyrus-ecd4928b327f5561364c5068c9ff5f1668e92d13.zip
Bug 485220: [Architecture] Provide a more modular architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485220 Factor UI dependencies out of the UML Element Types bundle. This includes moving some advices that interact with the user into a new org.eclipse.papyrus.uml.service.types.ui bundle. Pull up the PasteCommandService and IPasteCommandProvider API into the Infra Diagram layer where the extension point is defined. Deprecate the old API in the UML layer. Introduce a service for participation of languages in CSS styling: * styling reset actions in the Reset Style command * access to semantic model classes and properties to make available to CSS Factor PapyrusObservableValue and cohorts out of the UML Tools bundle into the Infra Layer for more general reuse and to relieve the Diagram Infrastructure layer of UML dependencies. The old API remains as deprecated. Remove the Infra Diagram Layer dependency on UML Layer for property testers governing deletion in the diagram. Includes introduction of a new IGraphicalDeletionHelper OSGi service for delegation of the determination of whether an element can be deleted from the diagram and replacement of the XML expression properties * org.eclipse.papyrus.uml.diagram.common.isSemanticDeletion * org.eclipse.papyrus.uml.diagram.common.isReadOnly by * org.eclipse.papyrus.infra.gmfdiag.common.isSemanticDeletion * org.eclipse.papyrus.infra.gmfdiag.common.canDelete (where the latter is the negation of the property that it supersedes) Extract UML dependencies from the Diagram Outline and CSS Editor bundles. Remove unused MDTUtil APIs that referenced a UML-specific annotation. Move the Diagram Infrastructure CSS Palette bundle into the UML layer because it serves to provide extensions on the Palette Service, which is an overtly UML-specific capability. All client APIs for the Properties View are moved from org.eclipse.papyrus.views.properties bundle to a new org.eclipse.papyrus.infra.properties.ui bundle. This includes renaming of: * extension points * label-provider contexts * XWT namespaces Add an "all UI tests" suite. Define a componentized hierarchical build layout of the main plug-ins Change-Id: I43f8f3644857a18b69715f5a2f1da9b1cf286d67
Diffstat (limited to 'plugins/infra/emf/org.eclipse.papyrus.infra.emf')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java259
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/spi/resolver/EObjectResolverService.java48
3 files changed, 145 insertions, 170 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml
index 63ffd3757a1..cc4360ddd2d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/pom.xml
@@ -2,13 +2,11 @@
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>org.eclipse.papyrus.releng</artifactId>
+ <artifactId>org.eclipse.papyrus.infra-emf</artifactId>
<groupId>org.eclipse.papyrus</groupId>
- <version>1.2.0-SNAPSHOT</version>
- <relativePath>../../../../releng/main</relativePath>
+ <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.emf</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
<version>1.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
-</project> \ No newline at end of file
+</project>
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
index fe845446d23..a3c0e69cc06 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
@@ -1,130 +1,129 @@
-/*****************************************************************************
- * 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:
- * Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
- * Christian W. Damus - bug 485220
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.papyrus.infra.emf.spi.resolver.EObjectResolverService;
-import org.eclipse.papyrus.infra.emf.spi.resolver.IEObjectResolver;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin {
-
- /**
- * The plug-in ID
- */
- public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.emf"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The plug-in's logger
- */
- public static LogHelper log;
-
- private ICustomizationManager fCustomizationManager;
- // temp resourceSet
- private ResourceSet facetRecsourceSet = new ResourceSetImpl();
-
- private EObjectResolverService resolverService;
-
- /**
- * The constructor
- */
- public Activator() {
- super();
- }
-
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
-
- resolverService = new EObjectResolverService(context);
- resolverService.open();
- }
-
- @Override
- public void stop(final BundleContext context) throws Exception {
- resolverService.close();
- resolverService = null;
-
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- *
- * @return the customization manager in charge to adapt element in modisco
- */
- public ICustomizationManager getCustomizationManager() {
- if (this.fCustomizationManager == null) {
- this.fCustomizationManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(facetRecsourceSet);
- }
- return this.fCustomizationManager;
- }
-
- /** @return the qualified name of the given metaclass */
- public static String getMetaclassQualifiedName(final EClassifier eClass) {
- final ArrayList<String> qualifiedNameParts = new ArrayList<String>();
- final StringBuilder builder = new StringBuilder();
-
- EPackage ePackage = eClass.getEPackage();
- while (ePackage != null) {
- qualifiedNameParts.add(ePackage.getName());
- ePackage = ePackage.getESuperPackage();
- }
-
- for (int i = qualifiedNameParts.size() - 1; i >= 0; i--) {
- builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$
- }
-
- builder.append(eClass.getName());
-
- return builder.toString();
- }
-
- /**
- * Obtain the instance of the {@link EObject} resolver service, if any.
- *
- * @return the object resolver service (never {@code null} while this bundle is active)
- */
- public IEObjectResolver getEObjectResolver() {
- return resolverService;
- }
-
-}
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.papyrus.infra.emf.spi.resolver.EObjectResolverService;
+import org.eclipse.papyrus.infra.emf.spi.resolver.IEObjectResolver;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ /**
+ * The plug-in ID
+ */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.emf"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The plug-in's logger
+ */
+ public static LogHelper log;
+
+ private ICustomizationManager fCustomizationManager;
+ // temp resourceSet
+ private ResourceSet facetRecsourceSet = new ResourceSetImpl();
+
+ private EObjectResolverService resolverService;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ super();
+ }
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+
+ resolverService = new EObjectResolverService(context);
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ resolverService.dispose();
+ resolverService = null;
+
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ *
+ * @return the customization manager in charge to adapt element in modisco
+ */
+ public ICustomizationManager getCustomizationManager() {
+ if (this.fCustomizationManager == null) {
+ this.fCustomizationManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(facetRecsourceSet);
+ }
+ return this.fCustomizationManager;
+ }
+
+ /** @return the qualified name of the given metaclass */
+ public static String getMetaclassQualifiedName(final EClassifier eClass) {
+ final ArrayList<String> qualifiedNameParts = new ArrayList<String>();
+ final StringBuilder builder = new StringBuilder();
+
+ EPackage ePackage = eClass.getEPackage();
+ while (ePackage != null) {
+ qualifiedNameParts.add(ePackage.getName());
+ ePackage = ePackage.getESuperPackage();
+ }
+
+ for (int i = qualifiedNameParts.size() - 1; i >= 0; i--) {
+ builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$
+ }
+
+ builder.append(eClass.getName());
+
+ return builder.toString();
+ }
+
+ /**
+ * Obtain the instance of the {@link EObject} resolver service, if any.
+ *
+ * @return the object resolver service (never {@code null} while this bundle is active)
+ */
+ public IEObjectResolver getEObjectResolver() {
+ return resolverService;
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/spi/resolver/EObjectResolverService.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/spi/resolver/EObjectResolverService.java
index 9b2e0ecb239..dd9f1e67d95 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/spi/resolver/EObjectResolverService.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/spi/resolver/EObjectResolverService.java
@@ -13,20 +13,15 @@
package org.eclipse.papyrus.infra.emf.spi.resolver;
-import java.util.Objects;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Stream;
-
+import org.eclipse.papyrus.infra.tools.util.CompositeServiceTracker;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
/**
* A resolver that delegates to registered OSGi services in a <em>Chain of Command</em>
* pattern to provide the first available service result.
*/
-public class EObjectResolverService extends ServiceTracker<IEObjectResolver, IEObjectResolver> implements IEObjectResolver {
- private final AtomicReference<IEObjectResolver> delegate = new AtomicReference<>(IEObjectResolver.identity());
+public class EObjectResolverService implements IEObjectResolver {
+ private final CompositeServiceTracker<IEObjectResolver> tracker;
/**
* Initializes me with the bundle context in which I track resolver services.
@@ -35,38 +30,21 @@ public class EObjectResolverService extends ServiceTracker<IEObjectResolver, IEO
* the bundle context
*/
public EObjectResolverService(BundleContext context) {
- super(context, IEObjectResolver.class, null);
- }
-
- @Override
- public Object resolve(Object object) {
- IEObjectResolver delegate = this.delegate.get();
- if (delegate == null) {
- // Recompute
- delegate = Stream.of(getServices(new IEObjectResolver[getTrackingCount()]))
- .filter(Objects::nonNull) // If the array has more slots than we have services
- .reduce(IEObjectResolver.identity(), IEObjectResolver::compose);
- this.delegate.set(delegate);
- }
+ super();
- return delegate.resolve(object);
+ tracker = new CompositeServiceTracker<>(context,
+ IEObjectResolver.class,
+ IEObjectResolver.identity(),
+ IEObjectResolver::compose);
+ tracker.open();
}
- @Override
- public IEObjectResolver addingService(ServiceReference<IEObjectResolver> reference) {
- IEObjectResolver result = super.addingService(reference);
-
- // We will have to recompute our delegates
- delegate.set(null);
-
- return result;
+ public void dispose() {
+ tracker.close();
}
@Override
- public void removedService(ServiceReference<IEObjectResolver> reference, IEObjectResolver service) {
- super.removedService(reference, service);
-
- // We will have to recompute our delegates
- delegate.set(null);
+ public Object resolve(Object object) {
+ return tracker.getService().resolve(object);
}
}

Back to the top