Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-11-15 10:21:07 +0000
committerCamille Letavernier2013-11-15 10:21:07 +0000
commit95932905599124d94e54f5ebb01c8794b7e2eed8 (patch)
tree64d0c9e15f71f2e6c74af78e8dd752c9d22209b6
parenta5f3e0da48f4ebc19d66a64adf039c971b8510ca (diff)
downloadorg.eclipse.papyrus-95932905599124d94e54f5ebb01c8794b7e2eed8.tar.gz
org.eclipse.papyrus-95932905599124d94e54f5ebb01c8794b7e2eed8.tar.xz
org.eclipse.papyrus-95932905599124d94e54f5ebb01c8794b7e2eed8.zip
355510: [sequence diagram] DnD of a class or property on lifeline for
"represents" https://bugs.eclipse.org/bugs/show_bug.cgi?id=355510
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/lifeline/ClassifierToLifelineDropStrategy.java115
3 files changed, 120 insertions, 1 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties
index e3693a3b66e..4ec4ed9fddd 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties
@@ -3,5 +3,6 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
- plugin.xml
+ plugin.xml,\
+ schema/
src.includes = about.html
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
index a74f5c993ec..1a4008a46d2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
@@ -9,5 +9,8 @@
<strategy
strategy="org.eclipse.papyrus.uml.diagram.dnd.strategy.classifier.ClassifierAsClassifierToStructureCompartmentDropStrategy">
</strategy>
+ <strategy
+ strategy="org.eclipse.papyrus.uml.diagram.dnd.lifeline.ClassifierToLifelineDropStrategy">
+ </strategy>
</extension>
</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/lifeline/ClassifierToLifelineDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/lifeline/ClassifierToLifelineDropStrategy.java
new file mode 100644
index 00000000000..ade78347b4e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/lifeline/ClassifierToLifelineDropStrategy.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.dnd.lifeline;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy;
+import org.eclipse.papyrus.uml.diagram.dnd.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * A DropStrategy to "Type" a Lifeline.
+ * Drop a classifier on a Lifeline to type it.
+ * This will create a new Property in the interaction, typed by the dropped classifier.
+ * The Lifeline will represent this property.
+ *
+ * It is also possible to drop directly an already existing Property to the Lifeline.
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class ClassifierToLifelineDropStrategy extends TransactionalDropStrategy {
+
+ public String getLabel() {
+ return "Type a Lifeline";
+ }
+
+ public String getDescription() {
+ return "Drop a classifier on a Lifeline to type it. This will create a new Property in the interaction, typed by the dropped classifier. The Lifeline will represent this property." + "It is also possible to drop directly an already existing Property to the lifeline.";
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+ public String getID() {
+ return Activator.PLUGIN_ID + ".lifeline.represents";
+ }
+
+ @Deprecated
+ public int getPriority() {
+ return 0;
+ }
+
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+ EObject targetElement = getTargetSemanticElement(targetEditPart);
+
+ if(!(targetElement instanceof Lifeline)) {
+ return null;
+ }
+
+
+ final Lifeline targetLifeline = (Lifeline)targetElement;
+
+ final Interaction interaction = targetLifeline.getInteraction();
+ if(interaction == null) {
+ return null;
+ }
+
+ List<EObject> sourceElements = getSourceEObjects(request);
+
+ //The only supported case is "Drop a single Type on a single Lifeline"
+ if(sourceElements.size() != 1) {
+ return null;
+ }
+
+ EObject sourceElement = sourceElements.get(0);
+ if(sourceElement instanceof Type) {
+ final Type sourceType = (Type)sourceElement;
+
+ Command resultCommand = new Command(getLabel()) {
+
+ @Override
+ public void execute() {
+ Property property = interaction.createOwnedAttribute("", sourceType);
+ targetLifeline.setRepresents(property);
+ }
+ };
+
+ return resultCommand;
+ } else if(sourceElement instanceof Property) {
+ final Property property = (Property)sourceElement;
+ Command resultCommand = new Command(getLabel()) {
+
+ @Override
+ public void execute() {
+ targetLifeline.setRepresents(property);
+ }
+ };
+
+ return resultCommand;
+ }
+
+ return null;
+ }
+
+}

Back to the top