Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2012-12-04 14:02:27 +0000
committerptessier2012-12-04 14:02:27 +0000
commitbccead0e5f82140bc37fc09d3b3fd3cbeca9a71a (patch)
tree87ad578206adf6c8dc4e6c6ca43a115e433f086a /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java
parent617459b0240eaebecb780a8e687a5b52c519c8cc (diff)
downloadorg.eclipse.papyrus-bccead0e5f82140bc37fc09d3b3fd3cbeca9a71a.tar.gz
org.eclipse.papyrus-bccead0e5f82140bc37fc09d3b3fd3cbeca9a71a.tar.xz
org.eclipse.papyrus-bccead0e5f82140bc37fc09d3b3fd3cbeca9a71a.zip
269492: [All Diagrams] Display properties of a applied stereotypes as a " comment"
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269492
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java125
1 files changed, 88 insertions, 37 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java
index c860ec3a745..c7fa26c59f3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/policies/DeviceItemSemanticEditPolicyCN.java
@@ -15,6 +15,7 @@ import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
@@ -26,6 +27,8 @@ import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType;
+import org.eclipse.papyrus.infra.extendedtypes.util.ElementTypeUtils;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.uml.diagram.deployment.edit.commands.CommentAnnotatedElementCreateCommand;
@@ -71,15 +74,13 @@ public class DeviceItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolic
EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
if(annotation == null) {
- // there are indirectly referenced children, need extra commands:
- // false
+ // there are indirectly referenced children, need extra commands: false
addDestroyChildNodesCommand(cmd);
addDestroyShortcutsCommand(cmd, view);
// delete host element
List<EObject> todestroy = new ArrayList<EObject>();
todestroy.add(req.getElementToDestroy());
- // cmd.add(new
- // org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy)));
} else {
cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
@@ -134,13 +135,9 @@ public class DeviceItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolic
break;
}
}
- cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned:
- // true
- // don't need explicit deletion of cnode as parent's
- // view deletion would clean child views as well
- // cmd.add(new
- // org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(),
- // cnode));
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
break;
case DeviceEditPartCN.VISUAL_ID:
@@ -177,13 +174,9 @@ public class DeviceItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolic
break;
}
}
- cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned:
- // true
- // don't need explicit deletion of cnode as parent's
- // view deletion would clean child views as well
- // cmd.add(new
- // org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(),
- // cnode));
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
break;
case NodeEditPartCN.VISUAL_ID:
@@ -220,13 +213,9 @@ public class DeviceItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolic
break;
}
}
- cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned:
- // true
- // don't need explicit deletion of cnode as parent's
- // view deletion would clean child views as well
- // cmd.add(new
- // org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(),
- // cnode));
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
break;
}
}
@@ -247,22 +236,50 @@ public class DeviceItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolic
* @generated
*/
protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
- if(UMLElementTypes.CommentAnnotatedElement_4008 == req.getElementType()) {
+ IElementType requestElementType = req.getElementType();
+ if(requestElementType == null) {
return null;
}
- if(UMLElementTypes.ConstraintConstrainedElement_4009 == req.getElementType()) {
+ 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.CommentAnnotatedElement_4008 == baseElementType) {
return null;
}
- if(UMLElementTypes.Deployment_4001 == req.getElementType()) {
+ if(UMLElementTypes.ConstraintConstrainedElement_4009 == baseElementType) {
+ return null;
+ }
+ if(UMLElementTypes.Deployment_4001 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new DeploymentCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Manifestation_4002 == req.getElementType()) {
+ if(UMLElementTypes.Manifestation_4002 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new ManifestationCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Generalization_4003 == req.getElementType()) {
+ if(UMLElementTypes.Generalization_4003 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Dependency_4004 == req.getElementType()) {
+ if(UMLElementTypes.Dependency_4004 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedStartCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
}
return null;
@@ -272,22 +289,56 @@ public class DeviceItemSemanticEditPolicyCN extends UMLBaseItemSemanticEditPolic
* @generated
*/
protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
- if(UMLElementTypes.CommentAnnotatedElement_4008 == req.getElementType()) {
+ IElementType requestElementType = req.getElementType();
+ if(requestElementType == null) {
+ return null;
+ }
+ 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.CommentAnnotatedElement_4008 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.ConstraintConstrainedElement_4009 == req.getElementType()) {
+ if(UMLElementTypes.ConstraintConstrainedElement_4009 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Deployment_4001 == req.getElementType()) {
+ if(UMLElementTypes.Deployment_4001 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new DeploymentCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Manifestation_4002 == req.getElementType()) {
+ if(UMLElementTypes.Manifestation_4002 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new ManifestationCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Generalization_4003 == req.getElementType()) {
+ if(UMLElementTypes.Generalization_4003 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new GeneralizationCreateCommand(req, req.getSource(), req.getTarget()));
}
- if(UMLElementTypes.Dependency_4004 == req.getElementType()) {
+ if(UMLElementTypes.Dependency_4004 == baseElementType) {
+ if(isExtendedType) {
+ return getExtendedCompleteCreateRelationshipCommand(req, (IExtendedHintedElementType)requestElementType);
+ }
return getGEFWrapper(new DependencyCreateCommand(req, req.getSource(), req.getTarget()));
}
return null;

Back to the top