diff options
author | Quentin Le Menez | 2019-01-24 10:17:27 +0000 |
---|---|---|
committer | Quentin Le Menez | 2019-02-13 08:26:39 +0000 |
commit | 6f2d2ead61b68bd66df104ba5ba2730d36308415 (patch) | |
tree | fbf88f2f33a0679789cb45c963fc0cc7e980d113 | |
parent | e333a662866c6cd8388c28e86b0f5caef68e5858 (diff) | |
download | org.eclipse.papyrus-6f2d2ead61b68bd66df104ba5ba2730d36308415.tar.gz org.eclipse.papyrus-6f2d2ead61b68bd66df104ba5ba2730d36308415.tar.xz org.eclipse.papyrus-6f2d2ead61b68bd66df104ba5ba2730d36308415.zip |
Bug 542518 - [Diagram] Creation of a diagram inside an element and dropping associations inside
- Cleaning the conditions
Change-Id: I238b4d3da42b6c6e36b3cae562040a77b39fd37c
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rw-r--r-- | plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/CommonDeferredCreateConnectionViewCommand.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/CommonDeferredCreateConnectionViewCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/CommonDeferredCreateConnectionViewCommand.java index f5ee600a1b7..a450d1bf523 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/CommonDeferredCreateConnectionViewCommand.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/CommonDeferredCreateConnectionViewCommand.java @@ -143,16 +143,27 @@ public class CommonDeferredCreateConnectionViewCommand extends DeferredCreateCon */ protected IGraphicalEditPart findEditPartForCreation(View view) { Iterator<?> editPartIterator = viewer.getEditPartRegistry().values().iterator(); - EObject semanticElement = view.getElement(); while (editPartIterator.hasNext()) { EditPart currentEditPart = (EditPart) editPartIterator.next(); - if ((!(currentEditPart instanceof CompartmentEditPart)) && currentEditPart instanceof IGraphicalEditPart && semanticElement == (((IGraphicalEditPart) currentEditPart).resolveSemanticElement())) { - // In the case of a diagram created inside an element and this element being dropped inside, there is a possibility (the order does not seem to be kept between creations) - // that the editPart matching the semantic element is the diagram itself as it is contained by the element. - // We cannot link a diagram Edit Part, it will return a null command, preventing the link creation. - if (!(currentEditPart instanceof LabelEditPart || currentEditPart.getModel() instanceof Diagram)) { - return (IGraphicalEditPart) currentEditPart; - } + if ((currentEditPart instanceof CompartmentEditPart)) { + continue; + } + + if (!(currentEditPart instanceof IGraphicalEditPart)) { + continue; + } + + EObject semanticElement = view.getElement(); + EObject resolvedElement = ((IGraphicalEditPart) currentEditPart).resolveSemanticElement(); + if (null == resolvedElement || !(semanticElement == resolvedElement)) { + continue; + } + + // In the case of a diagram created inside an element and this element being dropped inside, there is a possibility (the order does not seem to be kept between creations) + // that the editPart matching the semantic element is the diagram itself as it is contained by the element. + // We cannot link a diagram Edit Part, it will return a null command, preventing the link creation. + if (!(currentEditPart instanceof LabelEditPart || currentEditPart.getModel() instanceof Diagram)) { + return (IGraphicalEditPart) currentEditPart; } } return null; |