diff options
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.java | 135 |
1 files changed, 62 insertions, 73 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 index 7f7d75f0020..995bf48180b 100644 --- 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 @@ -1,73 +1,62 @@ -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;
- }
- }
-
-}
+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.commands.core.commands.DuplicateEObjectsCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest; +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(); + return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req)); + } + + /** + * @generated + */ + private static class DuplicateAnythingCommand extends + DuplicateEObjectsCommand { + + /** + * @generated + */ + public DuplicateAnythingCommand( + TransactionalEditingDomain editingDomain, + DuplicateElementsRequest req) { + super(editingDomain, req.getLabel(), req + .getElementsToBeDuplicated(), req + .getAllDuplicatedElementsMap()); + } + + } + +} |