Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java')
-rw-r--r--examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..7f7d75f0020
--- /dev/null
+++ b/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/src/org/eclipse/papyrus/example/diagram/simplediagram/edit/policies/ModelItemSemanticEditPolicy.java
@@ -0,0 +1,73 @@
+package org.eclipse.papyrus.example.diagram.simplediagram.edit.policies;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.diagram.common.commands.DuplicateNamedElementCommand;
+import org.eclipse.papyrus.example.diagram.simplediagram.edit.commands.ComponentCreateCommand;
+import org.eclipse.papyrus.example.diagram.simplediagram.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ModelItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ModelItemSemanticEditPolicy() {
+ super(UMLElementTypes.Model_1000);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ if (UMLElementTypes.Component_2001 == req.getElementType()) {
+ return getGEFWrapper(new ComponentCreateCommand(req));
+ }
+ return super.getCreateCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDuplicateCommand(DuplicateElementsRequest req) {
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
+ .getEditingDomain();
+ Diagram currentDiagram = null;
+ if (getHost() instanceof IGraphicalEditPart) {
+ currentDiagram = ((IGraphicalEditPart) getHost()).getNotationView()
+ .getDiagram();
+ }
+ return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req,
+ currentDiagram));
+ }
+
+ /**
+ * @generated
+ */
+ private static class DuplicateAnythingCommand extends
+ DuplicateNamedElementCommand {
+ /**
+ * @generated
+ */
+ private Diagram diagram;
+
+ /**
+ * @generated
+ */
+ public DuplicateAnythingCommand(
+ TransactionalEditingDomain editingDomain,
+ DuplicateElementsRequest req, Diagram currentDiagram) {
+ super(editingDomain, req.getLabel(), req
+ .getElementsToBeDuplicated(), req
+ .getAllDuplicatedElementsMap(), currentDiagram);
+ this.diagram = currentDiagram;
+ }
+ }
+
+}

Back to the top