Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-12-02 14:45:38 +0000
committerGerrit Code Review @ Eclipse.org2015-12-04 12:59:05 +0000
commitf8dedc59a0e9bc39beaa61b7a8c2cad1252c9438 (patch)
tree0e03fa04aaa10fd1c0c48028dec5a61b64bd06c9 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common
parent1f171bd0213d10d1d791f622e7ebf0b6484c40c5 (diff)
downloadorg.eclipse.papyrus-f8dedc59a0e9bc39beaa61b7a8c2cad1252c9438.tar.gz
org.eclipse.papyrus-f8dedc59a0e9bc39beaa61b7a8c2cad1252c9438.tar.xz
org.eclipse.papyrus-f8dedc59a0e9bc39beaa61b7a8c2cad1252c9438.zip
Bug 477384: [Canonical] Should not use drop requests to create views
https://bugs.eclipse.org/bugs/show_bug.cgi?id=477384 Changes to core APIs to remove PapyrusCanonicalEditPolicy's dependence on the generated diagram drag-and-drop behavior: * extract the CommonDiagramDragDropEditPolicy's abstract API for information about diagram-specific view types into a new service * update the canonical edit-policy and diagram-to-diagram synchronization infrastructure to use the new VisualTypeService to obtain information about the diagram's specific view types to then let the view service create views without resorting to drop commands * update extensions of various canonical strategies in the UML diagrams to adapt to the new drop-free synchronization mechanism Update the Papyrus Diagram GMFGen extensions and code generation templates to add generation of the IVisualTypeProvider that plugs into the new VisualTypeService to support canonical synchronization and drag-and-drop. Includes regeneration of the GMFGen extension model using EMF's most recent templates, which result in minor changes to most model source files. Regenerate all UML diagrams to create and register the visual type provider extensions. Also update the BREE for diagrams to 1.8 because at least one of them requires Java 8 to compile properly. * Note that the interaction overview diagram uses a code generator that is not published on Eclipse.org, so I had to emulate the code generation step for this one * Note also that the SysML 1.1 diagrams likewise cannot be re-generated but, moreover, they do not implement the common pattern for Visual ID Registry, so they are also updated "by hand" for parity with the Mars implementation of drag-and-drop (which had gaps) Deprecate the ICreationTargetStrategy extension API which was only needed to redirect drag-and-drop requests, but these are no longer employed in the canonical synchronization. Also some fixes for region layout problems in the State Machine Diagram: * update custom creation edit policies to re-use the commands used by drag-and-drop and untargeted creation that perform initial placement of new regions * fix the GMFGen to register the custom creation edit policy for the state machine compartment Change-Id: I3afc68d6f0f1bfe05e336c9138a7f1acbc8f643b
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.classpath14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/canonical/DefaultUMLSemanticChildrenStrategy.java176
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommonDiagramDragDropEditPolicy.java37
5 files changed, 221 insertions, 16 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.classpath b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.classpath
index 8a8f1668cdc..eca7bdba8f0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.classpath
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.classpath
@@ -1,7 +1,7 @@
-<?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.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?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"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.settings/org.eclipse.jdt.core.prefs
index 94d61f00da6..b3aa6d60f94 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/.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.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+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.6
+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/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
index df8c33781e8..04a0f338f60 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
@@ -49,8 +49,7 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Name: %pluginName
Bundle-Localization: plugin
-Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
org.eclipse.gmf.runtime.diagram.ui.resources.editor,
org.eclipse.gmf.runtime.diagram.ui.providers;bundle-version="1.1.0",
@@ -115,7 +114,6 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
org.eclipse.papyrus.infra.services.viewersearch;bundle-version="1.2.0",
org.eclipse.papyrus.infra.hyperlink;bundle-version="1.2.0"
Bundle-Vendor: %providerName
-Ant-Version: Apache Ant 1.7.0
Bundle-Version: 1.2.0.qualifier
Eclipse-BuddyPolicy: dependent
Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.Activator
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/canonical/DefaultUMLSemanticChildrenStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/canonical/DefaultUMLSemanticChildrenStrategy.java
index eda99cbdc03..9c19d60f67f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/canonical/DefaultUMLSemanticChildrenStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/canonical/DefaultUMLSemanticChildrenStrategy.java
@@ -11,6 +11,7 @@
* Christian W. Damus - bug 433206
* Christian W. Damus - bug 473148
* Christian W. Damus - bug 478558
+ * Christian W. Damus - bug 477384
*
*****************************************************************************/
@@ -32,15 +33,22 @@ import org.eclipse.papyrus.infra.gmfdiag.canonical.strategy.ISemanticChildrenStr
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.EdgeWithNoSemanticElementRepresentationImpl;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
import org.eclipse.papyrus.infra.tools.util.TypeUtils;
+import org.eclipse.uml2.uml.ActivityEdge;
import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.ConnectableElement;
+import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.ConnectorEnd;
import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.DirectedRelationship;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.MessageEnd;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Relationship;
+import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.Vertex;
import org.eclipse.uml2.uml.util.UMLSwitch;
@@ -159,10 +167,25 @@ public class DefaultUMLSemanticChildrenStrategy implements ISemanticChildrenStra
return result;
}
+ @Override
+ public Object getSource(EObject connectionElement) {
+ return ConnectionSourceSwitch.INSTANCE.doSwitch(connectionElement);
+ }
+
+ @Override
+ public Object getTarget(EObject connectionElement) {
+ return ConnectionTargetSwitch.INSTANCE.doSwitch(connectionElement);
+ }
+
//
// Nested types
//
+ /**
+ * A computation of the elements associated with some element
+ * that are not {@link Relationship}s but are visualized as
+ * connections in a manner similar to {@link Relationship}s.
+ */
private class ConnectionsSwitch extends UMLSwitch<List<EObject>> {
private final View visualContext;
private final List<EObject> result;
@@ -231,6 +254,11 @@ public class DefaultUMLSemanticChildrenStrategy implements ISemanticChildrenStra
}
}
+ /**
+ * An algorithm that removes relationships or relationship-like elements
+ * from an element's semantic connections that it is not appropriate to
+ * try to visualize in a given diagram context.
+ */
private class CleanRelationshipsSwitch extends UMLSwitch<List<EObject>> {
@SuppressWarnings("unused") // It isn't used, *yet*
private final View visualContext;
@@ -259,4 +287,152 @@ public class DefaultUMLSemanticChildrenStrategy implements ISemanticChildrenStra
}
}
+ /**
+ * A computation of the source element of a relationship or
+ * relationship-like element that is to be visualized.
+ */
+ private static class ConnectionSourceSwitch extends UMLSwitch<Object> {
+ static final ConnectionSourceSwitch INSTANCE = new ConnectionSourceSwitch();
+
+ @Override
+ public Object caseDirectedRelationship(DirectedRelationship object) {
+ List<Element> sources = object.getSources();
+ return sources.isEmpty() ? null : sources.get(0);
+ }
+
+ @Override
+ public Object caseRelationship(Relationship object) {
+ List<Element> related = object.getRelatedElements();
+ return related.isEmpty() ? null : related.get(0);
+ }
+
+ @Override
+ public Object caseAssociation(Association object) {
+ Property sourceEnd = getSourceEnd(object);
+
+ // The classifier at the source end is the other end's type (the
+ // source end may not be owned by the source type)
+ return (sourceEnd == null) ? null : sourceEnd.getOtherEnd().getType();
+ }
+
+ static Property getSourceEnd(Association association) {
+
+ Property result;
+
+ List<Property> ends = association.getMemberEnds();
+ if (ends.size() != 2) {
+ result = null;
+ } else {
+ Property end1 = ends.get(0);
+ Property end2 = ends.get(1);
+
+ // The first end that is classifier-owned is the "source"
+ if (end1.getOwningAssociation() == null) {
+ result = end1;
+ } else if (end2.getOwningAssociation() == null) {
+ result = end2;
+ } else {
+ // Otherwise, the first end that is navigable is the "source"
+ if (association.getNavigableOwnedEnds().contains(end1)) {
+ result = end1;
+ } else if (association.getNavigableOwnedEnds().contains(end2)) {
+ result = end2;
+ } else {
+ // Otherwise, it's just the first end
+ result = end1;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object caseConnector(Connector object) {
+ Object result = null;
+
+ List<ConnectorEnd> ends = object.getEnds();
+ ConnectorEnd source = ends.isEmpty() ? null : ends.get(0);
+ if (source != null) {
+ result = (source.getPartWithPort() != null)
+ ? ISemanticChildrenStrategy.createVisualStack(source.getPartWithPort(), source.getRole())
+ : source.getRole();
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object caseTransition(Transition object) {
+ return object.getSource();
+ }
+
+ @Override
+ public Object caseActivityEdge(ActivityEdge object) {
+ return object.getSource();
+ }
+
+ @Override
+ public Object caseMessage(Message object) {
+ return object.getSendEvent();
+ }
+ }
+
+ /**
+ * A computation of the target element of a relationship or
+ * relationship-like element that is to be visualized.
+ */
+ private static class ConnectionTargetSwitch extends UMLSwitch<Object> {
+ static final ConnectionTargetSwitch INSTANCE = new ConnectionTargetSwitch();
+
+ @Override
+ public Object caseDirectedRelationship(DirectedRelationship object) {
+ List<Element> targets = object.getTargets();
+ return targets.isEmpty() ? null : targets.get(0);
+ }
+
+ @Override
+ public Object caseRelationship(Relationship object) {
+ List<Element> related = object.getRelatedElements();
+ return (related.size() < 2) ? null : related.get(1);
+ }
+
+ @Override
+ public Object caseAssociation(Association object) {
+ Property sourceEnd = ConnectionSourceSwitch.getSourceEnd(object);
+
+ // The target type is the type of the source end
+ return (sourceEnd == null) ? null : sourceEnd.getType();
+ }
+
+ @Override
+ public Object caseConnector(Connector object) {
+ Object result = null;
+
+ List<ConnectorEnd> ends = object.getEnds();
+ ConnectorEnd source = ends.isEmpty() ? null : ends.get(1);
+ if (source != null) {
+ result = (source.getPartWithPort() != null)
+ ? ISemanticChildrenStrategy.createVisualStack(source.getPartWithPort(), source.getRole())
+ : source.getRole();
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object caseTransition(Transition object) {
+ return object.getTarget();
+ }
+
+ @Override
+ public Object caseActivityEdge(ActivityEdge object) {
+ return object.getTarget();
+ }
+
+ @Override
+ public Object caseMessage(Message object) {
+ return object.getReceiveEvent();
+ }
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommonDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommonDiagramDragDropEditPolicy.java
index cb745cd9cef..64d23fab1a7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommonDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommonDiagramDragDropEditPolicy.java
@@ -14,6 +14,7 @@
* Christian W. Damus (CEA) - bug 430726
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - bug 450341
* Christian W. Damus - bug 450944
+ * Christian W. Damus - bug 477384
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
@@ -70,9 +71,11 @@ import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.CommonDeferredCreateConnectionViewCommand;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.CreateViewCommand;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.AbstractDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.visualtype.VisualTypeService;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ViewServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.dnd.policy.CustomizableDropEditPolicy;
+import org.eclipse.papyrus.infra.tools.util.TypeUtils;
import org.eclipse.papyrus.uml.diagram.common.commands.DeferredCreateCommand;
import org.eclipse.papyrus.uml.diagram.common.helper.Element2IAdaptableRegistryHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.ILinkMappingHelper;
@@ -123,13 +126,41 @@ public abstract class CommonDiagramDragDropEditPolicy extends AbstractDiagramDra
*
* @return the uML element type
*/
- public abstract IElementType getUMLElementType(int elementID);
+ public IElementType getUMLElementType(int elementID) {
+ return VisualTypeService.getInstance().getElementType(getContextDiagram(), Integer.toString(elementID));
+ }
- public abstract int getNodeVisualID(View containerView, EObject domainElement);
+ public int getNodeVisualID(View containerView, EObject domainElement) {
+ String result = VisualTypeService.getInstance().getNodeType(containerView, domainElement);
- public abstract int getLinkWithClassVisualID(EObject domainElement);
+ try {
+ return (result == null) ? -1 : Integer.parseInt(result);
+ } catch (NumberFormatException e) {
+ // Not supported by this diagram
+ return -1;
+ }
+ }
+ public int getLinkWithClassVisualID(EObject domainElement) {
+ String result = VisualTypeService.getInstance().getLinkType(getContextDiagram(), domainElement);
+
+ try {
+ return (result == null) ? -1 : Integer.parseInt(result);
+ } catch (NumberFormatException e) {
+ // Not supported by this diagram
+ return -1;
+ }
+ }
+ /**
+ * Gets the notational diagram in which my host edit part is rendering a view.
+ *
+ * @return the contextual diagram
+ */
+ protected Diagram getContextDiagram() {
+ View view = TypeUtils.as(getHost().getModel(), View.class);
+ return (view == null) ? null : view.getDiagram();
+ }
/**
* Gets composite command adapters

Back to the top