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/InterfaceNestedClassifierCompartmentItemSemanticEditPolicy.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/InterfaceNestedClassifierCompartmentItemSemanticEditPolicy.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/InterfaceNestedClassifierCompartmentItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/InterfaceNestedClassifierCompartmentItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..1f2675e82e9
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/policies/InterfaceNestedClassifierCompartmentItemSemanticEditPolicy.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.NestedClassForInterfaceCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedDataTypeForInterfaceCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedEnumerationForInterfaceCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedInterfaceForInterfaceCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedPrimitiveTypeForInterfaceCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.commands.NestedSignalForInterfaceCreateCommand;
+import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
+
+/**
+ * @generated
+ */
+public class InterfaceNestedClassifierCompartmentItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public InterfaceNestedClassifierCompartmentItemSemanticEditPolicy() {
+ super(UMLElementTypes.Interface_2004);
+ }
+
+ /**
+ * @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_3008 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedClassForInterfaceCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.Interface_3038 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedInterfaceForInterfaceCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.Enumeration_3054 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedEnumerationForInterfaceCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.PrimitiveType_3048 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedPrimitiveTypeForInterfaceCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.DataType_3043 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedDataTypeForInterfaceCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ if (UMLElementTypes.Signal_3049 == baseElementType) {
+ if (isExtendedType) {
+ return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType) requestElementType);
+ }
+ return getGEFWrapper(new NestedSignalForInterfaceCreateCommand(req, DiagramUtils.getDiagramFrom(getHost())));
+
+ }
+ return super.getCreateCommand(req);
+ }
+
+}

Back to the top