diff options
author | Christian W. Damus | 2016-02-11 02:48:20 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-02-12 15:31:41 +0000 |
commit | ecd4928b327f5561364c5068c9ff5f1668e92d13 (patch) | |
tree | 7c34f46cf82a1d65ac753fa92c2a5d55371b8dba /plugins/uml/modelexplorer | |
parent | 751a204d74e15eb2db6b41c937691fc56dcc1252 (diff) | |
download | org.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/uml/modelexplorer')
10 files changed, 177 insertions, 163 deletions
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.widgets/pom.xml b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.widgets/pom.xml index 4fc03ffa74c..81613379d20 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.widgets/pom.xml +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.widgets/pom.xml @@ -2,13 +2,11 @@ <project> <modelVersion>4.0.0</modelVersion> <parent> - <artifactId>org.eclipse.papyrus.releng</artifactId> - <groupId>org.eclipse.papyrus</groupId> - <version>1.2.0-SNAPSHOT</version> - <relativePath>../../../../releng/main</relativePath> + <groupId>org.eclipse.papyrus</groupId> + <artifactId>org.eclipse.papyrus.uml-modelexplorer</artifactId> + <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.modelexplorer.widgets</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/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF index 44baa0d6bab..5076ad882d5 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/META-INF/MANIFEST.MF @@ -1,51 +1,51 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.uml.modelexplorer,
- org.eclipse.papyrus.uml.modelexplorer.factory,
- org.eclipse.papyrus.uml.modelexplorer.handler,
- org.eclipse.papyrus.uml.modelexplorer.queries,
- org.eclipse.papyrus.uml.modelexplorer.util
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.views.modelexplorer;bundle-version="1.2.0",
- org.eclipse.ui.navigator;bundle-version="3.4.0",
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1",
- org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0",
- org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300",
- org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.uml2.uml;bundle-version="4.0.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.service.types;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.2.0",
- org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="1.2.0",
- org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="1.2.0",
- org.eclipse.emf.ecore,
- org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.2.0",
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
- org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.newchild;bundle-version="1.2.0",
- org.eclipse.emf.edit.ui;bundle-version="2.11.0",
- org.eclipse.papyrus.infra.ui;bundle-version="1.2.0",
- org.eclipse.core.expressions,
- org.eclipse.papyrus.infra.ui.emf;bundle-version="1.2.0"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .,
- bin/
-Bundle-Version: 1.2.0.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.uml.modelexplorer.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.uml.modelexplorer;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.uml.modelexplorer, + org.eclipse.papyrus.uml.modelexplorer.factory, + org.eclipse.papyrus.uml.modelexplorer.handler, + org.eclipse.papyrus.uml.modelexplorer.queries, + org.eclipse.papyrus.uml.modelexplorer.util +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.papyrus.views.modelexplorer;bundle-version="1.2.0", + org.eclipse.ui.navigator;bundle-version="3.4.0", + org.eclipse.emf.transaction;bundle-version="1.4.0", + org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1", + org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0", + org.eclipse.gmf.runtime.notation;bundle-version="1.5.0", + org.eclipse.papyrus.infra.emf;bundle-version="1.2.0", + com.google.guava;bundle-version="11.0.0", + org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0", + org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0", + org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300", + org.eclipse.ui.ide;bundle-version="3.8.0", + org.eclipse.uml2.uml;bundle-version="4.0.0", + org.eclipse.papyrus.infra.core;bundle-version="1.2.0", + org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0", + org.eclipse.papyrus.uml.tools;bundle-version="1.2.0", + org.eclipse.papyrus.uml.service.types;bundle-version="1.2.0", + org.eclipse.papyrus.infra.services.edit;bundle-version="1.2.0", + org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="1.2.0", + org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="1.2.0", + org.eclipse.emf.ecore, + org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.2.0", + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0", + org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.2.0", + org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.2.0", + org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0", + org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.2.0", + org.eclipse.papyrus.infra.newchild;bundle-version="1.2.0", + org.eclipse.emf.edit.ui;bundle-version="2.11.0", + org.eclipse.papyrus.infra.ui;bundle-version="1.2.0", + org.eclipse.core.expressions, + org.eclipse.papyrus.infra.ui.emf;bundle-version="1.2.0", + org.eclipse.papyrus.uml.service.types.ui;bundle-version="1.2.0" +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: . +Bundle-Version: 1.2.0.qualifier +Bundle-Name: %pluginName +Bundle-Localization: plugin +Bundle-ManifestVersion: 2 +Bundle-Activator: org.eclipse.papyrus.uml.modelexplorer.Activator +Bundle-SymbolicName: org.eclipse.papyrus.uml.modelexplorer;singleton:=true +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/pom.xml b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/pom.xml index 331c9bf945f..abb5fa71e9e 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/pom.xml +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/pom.xml @@ -2,13 +2,11 @@ <project> <modelVersion>4.0.0</modelVersion> <parent> - <artifactId>org.eclipse.papyrus.releng</artifactId> - <groupId>org.eclipse.papyrus</groupId> - <version>1.2.0-SNAPSHOT</version> - <relativePath>../../../../releng/main</relativePath> + <groupId>org.eclipse.papyrus</groupId> + <artifactId>org.eclipse.papyrus.uml-modelexplorer</artifactId> + <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.modelexplorer</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/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/AssociationBaseHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/AssociationBaseHandler.java index c1020306462..2cbbbe312ba 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/AssociationBaseHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/AssociationBaseHandler.java @@ -18,7 +18,7 @@ public class AssociationBaseHandler extends AbstractUmlModelExplorerCreateComman /** * <pre> - * @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() + * @see org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() * * @return the IElementType this handler is supposed to create * diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/DestructionOccurrenceSpecificationHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/DestructionOccurrenceSpecificationHandler.java index 15ef087ed60..e510a7bc0cb 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/DestructionOccurrenceSpecificationHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/DestructionOccurrenceSpecificationHandler.java @@ -27,7 +27,7 @@ public class DestructionOccurrenceSpecificationHandler extends AbstractUmlModelE /** * <pre> - * @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() + * @see org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() * * @return the IElementType this handler is supposed to create * diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/LiteralRealHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/LiteralRealHandler.java index b245ed8ac77..946fe9c4420 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/LiteralRealHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/LiteralRealHandler.java @@ -27,7 +27,7 @@ public class LiteralRealHandler extends AbstractUmlModelExplorerCreateCommandHan /** * <pre> - * @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() + * @see org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() * * @return the IElementType this handler is supposed to create * diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/RefineHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/RefineHandler.java index df4b1dfb025..7256159880e 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/RefineHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/RefineHandler.java @@ -27,7 +27,7 @@ public class RefineHandler extends AbstractUmlModelExplorerCreateCommandHandler /** * <pre> - * @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() + * @see org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() * * @return the IElementType this handler is supposed to create * diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/TraceHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/TraceHandler.java index 8e018e8faff..37fa26f8d64 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/TraceHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src-gen/org/eclipse/papyrus/uml/modelexplorer/handler/TraceHandler.java @@ -18,7 +18,7 @@ public class TraceHandler extends AbstractUmlModelExplorerCreateCommandHandler { /** * <pre> - * @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() + * @see org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractCreateCommandHandler#getElementTypeToCreate() * * @return the IElementType this handler is supposed to create * diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/AbstractUmlModelExplorerCreateCommandHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/AbstractUmlModelExplorerCreateCommandHandler.java index 64415353f5e..746a3c44843 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/AbstractUmlModelExplorerCreateCommandHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/AbstractUmlModelExplorerCreateCommandHandler.java @@ -1,95 +1,95 @@ -/*****************************************************************************
- * 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:
- * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.modelexplorer.handler;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
-import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
-import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
-import org.eclipse.papyrus.infra.widgets.util.RevealSemanticElementWrapper;
-import org.eclipse.papyrus.uml.modelexplorer.util.ModelExplorerUtils;
-import org.eclipse.papyrus.uml.service.types.handlers.AbstractUmlCreateCommandHandler;
-import org.eclipse.papyrus.uml.service.types.utils.ICommandContext;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.uml2.uml.Element;
-
-import com.google.common.base.Optional;
-
-
-/**
- * Abstract handler supertype for every generated handler for the creation of UML elements from the model explorer.
- * ("Create child")
- */
-public abstract class AbstractUmlModelExplorerCreateCommandHandler extends AbstractUmlCreateCommandHandler {
-
- /**
- *
- * @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCommandHandler#getCommandContext()
- *
- * @return
- */
- @Override
- protected ICommandContext getCommandContext() {
- return ModelExplorerUtils.getSelectionCommandContext();
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- Object result = super.execute(event);
-
- if (result instanceof Element) {
- handleElementsCreated(Collections.singleton((Element) result), event);
- } else if (result instanceof Collection<?>) {
- handleElementsCreated((Collection<?>) result, event);
- }
-
- return result;
- }
-
- protected void handleElementsCreated(Collection<?> elements, ExecutionEvent event) {
- if (elements.isEmpty()) {
- return;
- }
-
- NavigationTarget target = getNavigationTarget(event);
- if (target == null) {
- return;
- }
-
- target.revealElement(elements);
- }
-
- protected NavigationTarget getNavigationTarget(ExecutionEvent event) {
- IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
- if (activePart == null) {
- return null;
- }
-
- Optional<NavigationTarget> navigationTarget = AdapterUtils.adapt(activePart, NavigationTarget.class);
- if (navigationTarget.isPresent()) {
- return navigationTarget.get();
- }
-
- Optional<IRevealSemanticElement> revealSemantic = AdapterUtils.adapt(activePart, IRevealSemanticElement.class);
- if (revealSemantic.isPresent()) {
- return new RevealSemanticElementWrapper(revealSemantic.get());
- }
-
- return null;
- }
-
-}
+/***************************************************************************** + * 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: + * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.modelexplorer.handler; + +import java.util.Collection; +import java.util.Collections; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.infra.core.utils.AdapterUtils; +import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement; +import org.eclipse.papyrus.infra.widgets.util.NavigationTarget; +import org.eclipse.papyrus.infra.widgets.util.RevealSemanticElementWrapper; +import org.eclipse.papyrus.uml.modelexplorer.util.ModelExplorerUtils; +import org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractUmlCreateCommandHandler; +import org.eclipse.papyrus.uml.service.types.utils.ICommandContext; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.uml2.uml.Element; + +import com.google.common.base.Optional; + + +/** + * Abstract handler supertype for every generated handler for the creation of UML elements from the model explorer. + * ("Create child") + */ +public abstract class AbstractUmlModelExplorerCreateCommandHandler extends AbstractUmlCreateCommandHandler { + + /** + * + * @see org.eclipse.papyrus.uml.service.types.ui.handlers.AbstractCommandHandler#getCommandContext() + * + * @return + */ + @Override + protected ICommandContext getCommandContext() { + return ModelExplorerUtils.getSelectionCommandContext(); + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Object result = super.execute(event); + + if (result instanceof Element) { + handleElementsCreated(Collections.singleton((Element) result), event); + } else if (result instanceof Collection<?>) { + handleElementsCreated((Collection<?>) result, event); + } + + return result; + } + + protected void handleElementsCreated(Collection<?> elements, ExecutionEvent event) { + if (elements.isEmpty()) { + return; + } + + NavigationTarget target = getNavigationTarget(event); + if (target == null) { + return; + } + + target.revealElement(elements); + } + + protected NavigationTarget getNavigationTarget(ExecutionEvent event) { + IWorkbenchPart activePart = HandlerUtil.getActivePart(event); + if (activePart == null) { + return null; + } + + Optional<NavigationTarget> navigationTarget = AdapterUtils.adapt(activePart, NavigationTarget.class); + if (navigationTarget.isPresent()) { + return navigationTarget.get(); + } + + Optional<IRevealSemanticElement> revealSemantic = AdapterUtils.adapt(activePart, IRevealSemanticElement.class); + if (revealSemantic.isPresent()) { + return new RevealSemanticElementWrapper(revealSemantic.get()); + } + + return null; + } + +} diff --git a/plugins/uml/modelexplorer/pom.xml b/plugins/uml/modelexplorer/pom.xml new file mode 100644 index 00000000000..bbc7c65bbaa --- /dev/null +++ b/plugins/uml/modelexplorer/pom.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<project> + <modelVersion>4.0.0</modelVersion> + <artifactId>org.eclipse.papyrus.uml-modelexplorer</artifactId> + <packaging>pom</packaging> + <parent> + <groupId>org.eclipse.papyrus</groupId> + <artifactId>org.eclipse.papyrus.uml</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <name>Papyrus UML Model Explorer</name> + <description>Providers of UML model content in the Papyrus Model Explorer View.</description> + + <modules> + <module>org.eclipse.papyrus.uml.modelexplorer</module> + <module>org.eclipse.papyrus.uml.modelexplorer.widgets</module> + </modules> +</project> |