diff options
| author | Pierre Guilet | 2018-07-06 14:23:55 +0000 |
|---|---|---|
| committer | Pierre Guilet | 2018-08-09 13:34:26 +0000 |
| commit | 3c77de0e6e1dd01a9887e6b8a6867e4857d49967 (patch) | |
| tree | c6f5643474ff04f16e7dbb48a530e493f8291d87 | |
| parent | 0e972c80a789f47fc33de935122e9c56dec12aac (diff) | |
| download | org.eclipse.sirius-3c77de0e6e1dd01a9887e6b8a6867e4857d49967.tar.gz org.eclipse.sirius-3c77de0e6e1dd01a9887e6b8a6867e4857d49967.tar.xz org.eclipse.sirius-3c77de0e6e1dd01a9887e6b8a6867e4857d49967.zip | |
[527109] Restrain some semantic modification in show/hide mode
When the show/hide mode is enabled, the following operations are
changed:
·direct edit is disabled on all elements;
·moving elements by dragging them can be used to change their position,
but will never trigger a drag and drop operation;
·moving the extremity of an edge to adjust its connection point (to the
source or target element) is possible, but will never trigger a
reconnection operation.
Bug: 527109
Change-Id: Ib6cd82d3630096882e9f39661e5a6bbcaf17ceba
Signed-off-by: Pierre Guilet <pierre.guilet@obeo.fr>
4 files changed, 88 insertions, 104 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/internal/policies/validators/DragAndDropValidator.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/internal/policies/validators/DragAndDropValidator.java index 7a24af38f4..36832fac6c 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/internal/policies/validators/DragAndDropValidator.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/internal/policies/validators/DragAndDropValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES. + * Copyright (c) 2011, 2018 THALES GLOBAL SERVICES. * 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 @@ -60,9 +60,8 @@ public class DragAndDropValidator { private DragAndDropTargetDescription dragAndDropDescription; /** - * True if all elements drop from a view will be "transformed" in border - * nodes after the drop, false otherwise. This variable is set after a call - * to method {@link #isValid(ChangeBoundsRequest, GraphicalEditPart)}. + * True if all elements drop from a view will be "transformed" in border nodes after the drop, false otherwise. This + * variable is set after a call to method {@link #isValid(ChangeBoundsRequest, GraphicalEditPart)}. */ private boolean isConcerningOnlyBorderNodeFromView; @@ -103,25 +102,24 @@ public class DragAndDropValidator { } /** - * Initializes the set containing {@link DDiagramElement} associated to - * dragged elements. + * Initializes the set containing {@link DDiagramElement} associated to dragged elements. * - * Returns false if an element to drop is a BorderedNode and if the layout - * mode is activated in the diagram of the host part drag and drop is - * forbidden in this case (returning false will invalidate the drop and - * re-enable the move). + * Returns false if an element to drop is a BorderedNode and if the layout mode is activated in the diagram of the + * host part drag and drop is forbidden in this case (returning false will invalidate the drop and re-enable the + * move). * * @param request * the request from which the initialization is done. * @param hostGraphicalEditPart * the part target of the drop. - * @return false if an element to drop is a bordered node and if the layout - * mode is activated in the diagram of the host part. True - * otherwise. + * @return false if an element to drop is a bordered node and if the layout mode is activated in the diagram of the + * host part. True otherwise. */ private boolean init(ChangeBoundsRequest request, GraphicalEditPart hostGraphicalEditPart) { List<?> editParts = request.getEditParts(); - boolean isInLayoutingMode = new EditPartQuery(hostGraphicalEditPart).isInLayoutingMode(); + EditPartQuery editPartQuery = new EditPartQuery(hostGraphicalEditPart); + boolean isInLayoutingMode = editPartQuery.isInLayoutingMode(); + boolean isInShowingMode = editPartQuery.isInShowingMode(); for (Object editPart : editParts) { if (editPart instanceof DragAndDropWrapper) { DragAndDropWrapper dragAndDropWrapperToDrop = (DragAndDropWrapper) editPart; @@ -130,10 +128,8 @@ public class DragAndDropValidator { IGraphicalEditPart graphicalEditPartToDrop = (IGraphicalEditPart) editPart; /* - * Impossible to move a border node in a subfunction if there is - * a drag and drop tool associated to the node drag'n'drop - * should not be enabled on the same container to avoid to block - * the move of an element + * Impossible to move a border node in a subfunction if there is a drag and drop tool associated to the + * node drag'n'drop should not be enabled on the same container to avoid to block the move of an element */ if (!(graphicalEditPartToDrop.getParent() == hostGraphicalEditPart || hostGraphicalEditPart instanceof CompartmentEditPart && graphicalEditPartToDrop.getParent() == hostGraphicalEditPart.getParent()) @@ -143,7 +139,7 @@ public class DragAndDropValidator { elementsFromDiagramToDrop.add(dDiagramElementTopDrop); editPartsFromDiagramToDrop.add(graphicalEditPartToDrop); - if (isInLayoutingMode && graphicalEditPartToDrop instanceof IAbstractDiagramNodeEditPart) { + if ((isInLayoutingMode || isInShowingMode) && graphicalEditPartToDrop instanceof IAbstractDiagramNodeEditPart) { return false; } @@ -187,16 +183,13 @@ public class DragAndDropValidator { } /** - * The drop location is different for nodes and for border nodes. So it is - * useful to know if the current drop concerned only border nodes to adapt - * the drop location.<BR> - * WARNING: This method must be called after - * {@link #isValid(ChangeBoundsRequest, GraphicalEditPart)}, because the - * calculating of <code>isConcerningOnlyBorderNode</code> is made during - * this last one. + * The drop location is different for nodes and for border nodes. So it is useful to know if the current drop + * concerned only border nodes to adapt the drop location.<BR> + * WARNING: This method must be called after {@link #isValid(ChangeBoundsRequest, GraphicalEditPart)}, because the + * calculating of <code>isConcerningOnlyBorderNode</code> is made during this last one. * - * @return true if all elements drop from a view will be "transformed" in - * border nodes after the drop, false otherwise. + * @return true if all elements drop from a view will be "transformed" in border nodes after the drop, false + * otherwise. */ public boolean isConcerningOnlyBorderNodeFromView() { return isConcerningOnlyBorderNodeFromView; @@ -231,8 +224,7 @@ public class DragAndDropValidator { } /** - * Set the target {@link targetDragAndDropTarget} of this drag'n drop - * request. + * Set the target {@link targetDragAndDropTarget} of this drag'n drop request. * * @param targetDragAndDropTarget * the target @@ -242,22 +234,18 @@ public class DragAndDropValidator { } /** - * Get the description of the target {@link DDiagramElement} of the drag'n - * drop request. + * Get the description of the target {@link DDiagramElement} of the drag'n drop request. * - * @return the description of the target {@link DDiagramElement} of the - * drag'n drop request + * @return the description of the target {@link DDiagramElement} of the drag'n drop request */ public DragAndDropTargetDescription getDragDragAndDropDescription() { return dragAndDropDescription; } /** - * Get the semantic of the target {@link DDiagramElement} of the drag'n drop - * request. + * Get the semantic of the target {@link DDiagramElement} of the drag'n drop request. * - * @return the semantic of the target {@link DDiagramElement} of the drag'n - * drop request + * @return the semantic of the target {@link DDiagramElement} of the drag'n drop request */ public EObject getTargetAbstractDNodeSemanticTarget() { return targetAbstractDNodeSemanticTarget; diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java index ad9271bd69..c6cc4e0db0 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java @@ -79,9 +79,7 @@ import com.google.common.base.Predicates; import com.google.common.collect.Iterables; /** - * The specific - * {@link org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy} - * . + * The specific {@link org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy} . * * @author ymortier * @author jdupont @@ -89,34 +87,29 @@ import com.google.common.collect.Iterables; public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx { /** - * Key for extended data of request. This key corresponds to a map that for - * each DDiagramElement (border nodes) stores the absolute screen location - * computed for the feedback figures.<BR> - * This map is set during drawing of border node feedback. This map is used - * later in the {@link SiriusContainerDropPolicy} to have the realLocation, - * and so the real delta for each border nodes, instead of the location - * corresponding to the move makes with the mouse. This allows to compute - * correctly the new linked edges bendpoints to only move the last segment. + * Key for extended data of request. This key corresponds to a map that for each DDiagramElement (border nodes) + * stores the absolute screen location computed for the feedback figures.<BR> + * This map is set during drawing of border node feedback. This map is used later in the + * {@link SiriusContainerDropPolicy} to have the realLocation, and so the real delta for each border nodes, instead + * of the location corresponding to the move makes with the mouse. This allows to compute correctly the new linked + * edges bendpoints to only move the last segment. */ public static final String BORDER_NODE_REAL_LOCATION_KEY = "borderNodesRealLocation"; //$NON-NLS-1$ /** - * Key for extended data of request. This key corresponds to feedback - * figures. This figures are added during drawing of feedback when several - * border nodes are move simultaneously. The last moved figure is not added - * to this list (because there will be no further feedback after this one). + * Key for extended data of request. This key corresponds to feedback figures. This figures are added during drawing + * of feedback when several border nodes are move simultaneously. The last moved figure is not added to this list + * (because there will be no further feedback after this one). */ private static final String BORDER_NODE_FEEDBACKS_KEY = "borderNodeFeedbacks"; //$NON-NLS-1$ /** - * We keep all created feedbacks to delete them at the end of the drag - * action. + * We keep all created feedbacks to delete them at the end of the drag action. */ private List<IFigure> feedbacks = new ArrayList<IFigure>(); /** - * For each collapsed figure, we keep all computed expanded coordinates - * until the drag action is over. + * For each collapsed figure, we keep all computed expanded coordinates until the drag action is over. */ private Map<IFigure, Rectangle> correspondingExpandedCoordinate = new HashMap<IFigure, Rectangle>(); @@ -126,14 +119,11 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx private EditPart feedbacksActivated; /** - * Status of the feedback figure. True if the feedback figure is displayed - * (created by the showChangeBoundsFeedback(ChangeBoundsRequest) method), - * false if not already created or deleted (with method + * Status of the feedback figure. True if the feedback figure is displayed (created by the + * showChangeBoundsFeedback(ChangeBoundsRequest) method), false if not already created or deleted (with method * eraseChangeBoundsFeedback(ChangeBoundsRequest)).<BR> - * This avoids to create this feedback figure in method - * getFiguresToIgnore(ChangeBoundsRequest). <BR> - * This was done because, there is no way to know if the feedback figure is - * null or not (private field). + * This avoids to create this feedback figure in method getFiguresToIgnore(ChangeBoundsRequest). <BR> + * This was done because, there is no way to know if the feedback figure is null or not (private field). */ private boolean feedbackFigureDisplayed; @@ -169,9 +159,8 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Return the list of existing feedback figures containing in the request. - * If the request does not contains feedback figures, an empty list is - * returned. + * Return the list of existing feedback figures containing in the request. If the request does not contains feedback + * figures, an empty list is returned. * * @param request * The request containing the extended data. @@ -188,9 +177,8 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Return a map with for each DDiagramElement the location of its feedback - * computed during the showSourceFeedback. If the request does not contains - * this map, an empty one is returned. + * Return a map with for each DDiagramElement the location of its feedback computed during the showSourceFeedback. + * If the request does not contains this map, an empty one is returned. * * @param request * The request containing the extended data. @@ -272,8 +260,9 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx Rectangle realLocation = null; // Only necessary in the case of bordered node dropping + EditPartQuery editPartQuery = new EditPartQuery((IGraphicalEditPart) hostEditPart); if (isFeedbackForBorderedNodeDropping(request, targetAbstractGraphicalEditPart) && hostEditPart instanceof IGraphicalEditPart - && !new EditPartQuery((IGraphicalEditPart) hostEditPart).isInLayoutingMode()) { + && (!editPartQuery.isInShowingMode() || !editPartQuery.isInLayoutingMode())) { activateProhibitedFeedbacks(targetAbstractGraphicalEditPart, request); DBorderItemLocator borderItemLocator = new FeedbackDBorderItemLocator(targetFigure); @@ -352,8 +341,8 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * The feedback is stored only if the request corresponds to several - * elements and that the current element is not the last. + * The feedback is stored only if the request corresponds to several elements and that the current element is not + * the last. * * @param feedback * The figure to store. @@ -376,15 +365,13 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Activates feedbacks for all collapsed node to avoid to place an other - * node in their forbidden area. + * Activates feedbacks for all collapsed node to avoid to place an other node in their forbidden area. * * @param hostEditPart * the edit part hosting the figure we are moving. * @param targetEditPart - * the container target edit part where the node is moving (can - * be the drop target edit part or the current node container - * edit part) + * the container target edit part where the node is moving (can be the drop target edit part or the + * current node container edit part) * @param request * the change bounds request. */ @@ -407,12 +394,10 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Returns whether the prohibited feedbacks are activated for the given - * target edit part. + * Returns whether the prohibited feedbacks are activated for the given target edit part. * * @param targetEditPart - * the edit part we want to know if the prohibited feedbacks are - * activated. + * the edit part we want to know if the prohibited feedbacks are activated. * @return true if activated otherwise false */ private boolean isFeedbacksActivatedForEditPart(EditPart targetEditPart) { @@ -429,15 +414,13 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * configure the prohibited feedback and area for the given border node edit - * part. + * configure the prohibited feedback and area for the given border node edit part. * * @param borderNodeEditPart * the edit part hosting the collapsed node figure. * @param otherFeedbackFigures - * In case of simultaneous moves, this list corresponds to the - * already known border nodes after move (generally the feedback - * figure) + * In case of simultaneous moves, this list corresponds to the already known border nodes after move + * (generally the feedback figure) */ private void configureFeedback(AbstractBorderItemEditPart borderNodeEditPart, List<IFigure> otherFeedbackFigures) { @@ -499,9 +482,8 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx * @param borderItemLocator * the figure edit part border item locator. * @param otherFeedbackFigures - * In case of simultaneous moves, this list corresponds to the - * already known border nodes after move (generally the feedback - * figure) + * In case of simultaneous moves, this list corresponds to the already known border nodes after move + * (generally the feedback figure) * @return the real location from the border item locator. */ private Rectangle getRealExpandedBounds(IFigure figure, Rectangle candidateNewBounds, final IBorderItemLocator borderItemLocator, List<IFigure> otherFeedbackFigures) { @@ -527,13 +509,11 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Tell if according to the <code>request</code>'s location we must provide - * a feedback for a drop of borderedNode to another parent or a feedback for - * a simple move of borderedNode without changing visually the parent. + * Tell if according to the <code>request</code>'s location we must provide a feedback for a drop of borderedNode to + * another parent or a feedback for a simple move of borderedNode without changing visually the parent. * * @param request - * the {@link ChangeBoundsRequest} providing the location of the - * mouse + * the {@link ChangeBoundsRequest} providing the location of the mouse * * @param targetAbstractGraphicalEditPart * the target EditPart on which to provide the feedback @@ -634,8 +614,7 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx * * @param request * the change bounds request. - * @return the new bounds according to the request and the border item - * locator. + * @return the new bounds according to the request and the border item locator. */ private Rectangle getNewBounds(final ChangeBoundsRequest request) { IBorderItemEditPart borderItemEP = (IBorderItemEditPart) getHost(); @@ -687,8 +666,7 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Return a list of all figure that will be moved by this - * ChangeBoundsRequest (the figure of the editParts). + * Return a list of all figure that will be moved by this ChangeBoundsRequest (the figure of the editParts). * * @param request * The request created by the edit part that have been moved. @@ -736,8 +714,8 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx } /** - * Check if the host corresponds to a borederdNode that is collapsed. In - * this case, the move cursor must be disabled. + * Check if the host corresponds to a borederdNode that is collapsed. In this case, the move cursor must be + * disabled. * * @return true if the move cursor must be disabled, false otherwise. */ diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java index 6ab0140258..9e2bcc6d2f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/NoCopyDragEditPartsTrackerEx.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 THALES GLOBAL SERVICES. + * Copyright (c) 2011, 2018 THALES GLOBAL SERVICES. * 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 @@ -93,7 +93,8 @@ public class NoCopyDragEditPartsTrackerEx extends SnapToAllDragEditPartsTracker private boolean isAuthorized() { boolean isAuthorized = true; EditPart movedEditPart = getSourceEditPart(); - if (movedEditPart instanceof AbstractBorderedDiagramElementEditPart && new EditPartQuery((AbstractBorderedDiagramElementEditPart) movedEditPart).isInLayoutingMode()) { + EditPartQuery editPartQuery = new EditPartQuery((AbstractBorderedDiagramElementEditPart) movedEditPart); + if (movedEditPart instanceof AbstractBorderedDiagramElementEditPart && (editPartQuery.isInShowingMode() || editPartQuery.isInLayoutingMode())) { // We are in layouting mode EditPart targetEditPart = getTargetEditPart(); // Check if the target container is not the same as before move diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java index 9e8290e249..ef32351533 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES and others. + * Copyright (c) 2010, 2018 THALES GLOBAL SERVICES and others. * 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 @@ -640,6 +640,23 @@ public class EditPartQuery { } /** + * Check if the given part is used in a diagram in show/hide mode. + * + * @return true if the given part is used in a diagram in show/hide mode, false otherwise. + */ + public boolean isInShowingMode() { + View notationView = part.getNotationView(); + if (notationView != null) { + Diagram diagram = notationView.getDiagram(); + if (diagram != null) { + EObject element = diagram.getElement(); + return element instanceof DDiagram && ((DDiagram) element).isIsInShowingMode(); + } + } + return false; + } + + /** * Provides the corrected location according to the snap. * * @param request |
