Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2016-02-22 12:52:00 +0000
committerGerrit Code Review @ Eclipse.org2016-02-23 08:49:00 +0000
commit493c486be6044c250fda32ec782103cf3a9e7bdc (patch)
tree863cc938cc65e464ad71b4b0cb023bc48665a88a
parent22c69dd32293c88628fc86a0082a61429f440960 (diff)
downloadorg.eclipse.papyrus-493c486be6044c250fda32ec782103cf3a9e7bdc.tar.gz
org.eclipse.papyrus-493c486be6044c250fda32ec782103cf3a9e7bdc.tar.xz
org.eclipse.papyrus-493c486be6044c250fda32ec782103cf3a9e7bdc.zip
475569: [Composite Diagram] DnD strategy mechanism should be used to
create PropertyPart https://bugs.eclipse.org/bugs/show_bug.cgi?id=475569 Change-Id: I9e8ca9f0ae9f97d445939fcc6eda52f7d12d6512 Signed-off-by: Camille Letavernier <camille.letavernier@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/classifier/ClassifierAsPropertyToStructuredCompartmentDropStrategy.java39
1 files changed, 27 insertions, 12 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/classifier/ClassifierAsPropertyToStructuredCompartmentDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/classifier/ClassifierAsPropertyToStructuredCompartmentDropStrategy.java
index 6542c52eb2a..664faf92418 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/classifier/ClassifierAsPropertyToStructuredCompartmentDropStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/classifier/ClassifierAsPropertyToStructuredCompartmentDropStrategy.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2015 CEA LIST 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
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.dnd.strategy.classifier;
@@ -23,9 +23,12 @@ import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy;
import org.eclipse.papyrus.uml.diagram.composite.custom.helper.TypeHelper;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
import org.eclipse.papyrus.uml.diagram.dnd.Activator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Association;
@@ -35,10 +38,10 @@ import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.StructuredClassifier;
/**
- *
+ *
* Class provide ability of drop a {@link Classifier} on a {@link Classifier} as a {@link Property}
- *
- * In a parent {@link Classifier} will be created a {@link Property} and shown in it
+ *
+ * In a parent {@link Classifier} will be created a {@link Property} and shown in it
* when user drop a child {@link Classifier} on the parent {@link Classifier}.
* The child {@link Classifier} not will be shown in the parent container in this case.
*/
@@ -71,28 +74,35 @@ public class ClassifierAsPropertyToStructuredCompartmentDropStrategy extends Tra
if (false == targetSemantic instanceof StructuredClassifier) {
return false;
}
- return true;
+
+ // Bug 475569: This strategy is specific to the composite diagram (Relying on TypeHelper and Composite-specific VisualIDs).
+ // Return false if the current diagram is not a Composite. This behavior might be improved by making this implementation more generic (ViewService?)
+ View notationView = ((IGraphicalEditPart) ep).getNotationView();
+ if (notationView == null || notationView.getDiagram() == null) {
+ return false;
+ }
+ return CompositeStructureDiagramEditPart.MODEL_ID.equals(notationView.getDiagram().getType());
}
@Override
public Command doGetCommand(Request request, EditPart targetEditPart) {
if (understandRequest(request) && isStructuredClassifierEP(targetEditPart)) {
-
+
GraphicalEditPart gtEditPart = (GraphicalEditPart) targetEditPart;
TypeHelper helper = new TypeHelper((TransactionalEditingDomain) getEditingDomain(targetEditPart));
Point location = getLocation((DropObjectsRequest) request, gtEditPart);
-
+
CompoundCommand cc = new CompoundCommand();
-
+
for (EObject dropElement : getSourceEObjects(request)) {
if (dropElement instanceof Collaboration) {
continue;
}
if (dropElement instanceof Classifier && (false == dropElement instanceof Association)) {
Classifier classifier = (Classifier) dropElement;
-
- cc.add(helper.dropTypeAsTypedProperty((GraphicalEditPart)gtEditPart, classifier, location));
-
+
+ cc.add(helper.dropTypeAsTypedProperty(gtEditPart, classifier, location));
+
}
}
return cc.canExecute() ? cc : null;
@@ -100,14 +110,17 @@ public class ClassifierAsPropertyToStructuredCompartmentDropStrategy extends Tra
return null;
}
+ @Override
public String getLabel() {
return "Drop type as typed property"; //$NON-NLS-1$
}
+ @Override
public String getID() {
return Activator.PLUGIN_ID + ".ClassifierToStructureCompAsPropertyDrop"; //$NON-NLS-1$
}
+ @Override
public String getDescription() {
return "Drops a classifier into the structure compartment of a structured classifier as a property."; //$NON-NLS-1$
}
@@ -120,10 +133,12 @@ public class ClassifierAsPropertyToStructuredCompartmentDropStrategy extends Tra
return "Drop a classifier into the structure compartment of a structured classifier as property"; //$NON-NLS-1$
}
+ @Override
public Image getImage() {
return null;
}
+ @Override
public int getPriority() {
return 0;
}

Back to the top