Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/ClassNestedClassifierCompartmentItemSemanticEditPolicy.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/ClassNestedClassifierCompartmentItemSemanticEditPolicy.java106
1 files changed, 106 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/ClassNestedClassifierCompartmentItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/ClassNestedClassifierCompartmentItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..da95a77e798
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/ClassNestedClassifierCompartmentItemSemanticEditPolicy.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.clazz.edit.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedClassForClassCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedDataTypeForClassCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedEnumerationForClassCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedInterfaceForClassCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedPrimitiveTypeForClassCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedSignalForClassCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class ClassNestedClassifierCompartmentItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ClassNestedClassifierCompartmentItemSemanticEditPolicy() {
+ super(UMLElementTypes.Class_2008);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ IElementType requestElementType = req.getElementType();
+ if (requestElementType == null) {
+ return super.getCreateCommand(req);
+ }
+ IElementType baseElementType = requestElementType;
+ boolean isExtendedType = false;
+ if (requestElementType instanceof IExtendedHintedElementType) {
+ baseElementType = ElementTypeUtils.getClosestDiagramType(requestElementType);
+ if (baseElementType != null) {
+ isExtendedType = true;
+ } else {
+ // no reference element type ID. using the closest super element type to give more opportunities, but can lead to bugs.
+ baseElementType = ElementTypeUtils.findClosestNonExtendedElementType((IExtendedHintedElementType) requestElementType);
+ isExtendedType = true;
+ }
+ }
+
+ if (UMLElementTypes.Class_3014 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedClassForClassCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.Interface_3036 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedInterfaceForClassCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.Enumeration_3052 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedEnumerationForClassCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.PrimitiveType_3047 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedPrimitiveTypeForClassCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.DataType_3044 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedDataTypeForClassCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.Signal_3050 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedSignalForClassCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ return super.getCreateCommand(req);
+ }
+
+}

Back to the top