Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2016-06-13 11:14:47 +0000
committerLaurent Redor2016-07-06 16:27:03 +0000
commit67a8af4dbbe4217098ce083293b8fe5e0be5e39a (patch)
tree95e3125b560f9aa9ea26d1320148492946abd259
parentd624200ad8b832cb4ddfcc2195e941f3de7e4c7a (diff)
downloadorg.eclipse.sirius-67a8af4dbbe4217098ce083293b8fe5e0be5e39a.tar.gz
org.eclipse.sirius-67a8af4dbbe4217098ce083293b8fe5e0be5e39a.tar.xz
org.eclipse.sirius-67a8af4dbbe4217098ce083293b8fe5e0be5e39a.zip
[497398] Authorize MOVE request for regions in some circumstances
The Move request is now handled for regions when the request comes from the PinnedElementsLayoutProvider. This allows to correctly reset the location AND the size of the regions. Bug: 497398 Cherry-picked-from: 495707 Change-Id: Ida1359bb17bb0d36d23f2f2cf7fc2853babe5ee6 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java23
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java22
2 files changed, 42 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java
index c887b09589..fb20e773fe 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/RegionResizableEditPolicy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2013, 2016 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
@@ -46,6 +46,7 @@ import org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramElementEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractDNodeContainerCompartmentEditPart;
import org.eclipse.sirius.diagram.ui.provider.Messages;
import org.eclipse.sirius.diagram.ui.tools.api.graphical.edit.styles.IContainerLabelOffsets;
+import org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.PinnedElementsLayoutProvider;
import org.eclipse.sirius.diagram.ui.tools.internal.util.EditPartQuery;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.base.Options;
@@ -139,14 +140,32 @@ public class RegionResizableEditPolicy extends AirResizableEditPolicy {
}
@Override
+ public Command getCommand(Request request) {
+ Object type = request.getType();
+ if (REQ_MOVE.equals(type) && (isDragAllowed() || isAuthorizedMoveRequest(request))) {
+ return getMoveCommand((ChangeBoundsRequest) request);
+ } else {
+ return super.getCommand(request);
+ }
+ }
+
+ @Override
protected Command getMoveCommand(final ChangeBoundsRequest request) {
- if (concernRegion()) {
+ if (concernRegion() && !isAuthorizedMoveRequest(request)) {
return UnexecutableCommand.INSTANCE;
}
return super.getMoveCommand(request);
}
+ private boolean isAuthorizedMoveRequest(Request request) {
+ Object isAuthorizedMoveRequest = request.getExtendedData().get(PinnedElementsLayoutProvider.PINNED_ELEMENTS_MOVE);
+ if (isAuthorizedMoveRequest instanceof Boolean) {
+ return (Boolean) isAuthorizedMoveRequest;
+ }
+ return false;
+ }
+
@Override
protected Command getAlignCommand(AlignmentRequest request) {
if (concernRegion()) {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java
index c77a897653..88ad168d35 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/provider/PinnedElementsLayoutProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2016 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
@@ -54,6 +54,23 @@ import com.google.common.collect.Maps;
* @author pcdavid
*/
public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
+
+ /**
+ * Key to store that the move request is sent from this specific layout
+ * provider to reset bounds of edit part to its origin location and size.
+ * <BR>
+ * The move request sets only the location but has, as side effect, to also
+ * use the same {@link org.eclipse.gmf.runtime.notation.Size} as the origin.
+ * <BR>
+ * For example, the move of a region is forbidden (see
+ * {@link org.eclipse.sirius.diagram.ui.graphical.edit.policies.RegionResizableEditPolicy#getMoveCommand(ChangeBoundsRequest)}
+ * ). The user has not the authorization to move a region of a container.
+ * But if this flag exists in the extended data of the request, the move is
+ * "forced".
+ *
+ */
+ public static final String PINNED_ELEMENTS_MOVE = "sirius.pinned.elements.move.request"; //$NON-NLS-1$
+
/**
* The layout provider which was executed before us. Needed to obtain the
* new
@@ -62,6 +79,7 @@ public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
private Predicate<Object> validateAllElementInArrayListAreIDiagramElementEditPart = new Predicate<Object>() {
+ @Override
public boolean apply(Object input) {
return input instanceof IDiagramElementEditPart;
}
@@ -135,6 +153,7 @@ public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
* Base case: handle pinned elements at this particular level.
*/
final Map<IGraphicalEditPart, Rectangle> initialBoundsForThisLevel = Maps.filterEntries(initialBounds, new Predicate<Map.Entry<IGraphicalEditPart, Rectangle>>() {
+ @Override
public boolean apply(final Entry<IGraphicalEditPart, Rectangle> input) {
return editParts.contains(input.getKey());
}
@@ -208,6 +227,7 @@ public class PinnedElementsLayoutProvider extends DefaultLayoutProvider {
request.setMoveDelta(new Point(delta.width, delta.height));
request.setLocation(newPosition);
request.setType(org.eclipse.gef.RequestConstants.REQ_MOVE);
+ request.getExtendedData().put(PinnedElementsLayoutProvider.PINNED_ELEMENTS_MOVE, Boolean.TRUE);
} else {
// no move, return null.
return null;

Back to the top