Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2020-10-19 16:30:54 +0000
committerLaurent Redor2020-11-05 16:55:48 +0000
commiteb17055c5bf38d3084c5e08d9bcfdac7dd662c52 (patch)
treeca9dcbc5aef50df2cd74f0adf08ac4d3298cad23
parentfa93312c74e550c40a6b64ebe91242437335a802 (diff)
downloadorg.eclipse.sirius-eb17055c5bf38d3084c5e08d9bcfdac7dd662c52.tar.gz
org.eclipse.sirius-eb17055c5bf38d3084c5e08d9bcfdac7dd662c52.tar.xz
org.eclipse.sirius-eb17055c5bf38d3084c5e08d9bcfdac7dd662c52.zip
[568037] Arrange selection with ELK layout
* A new field has been added in CustomLayoutAlgorithm to allow to use or not the standard ArrangeSelection mechanism (see javadoc of ArrangeSelectionLayoutProvider). It was always used by default but for ELK we want a different behavior. This field is associated with corresponding methods in CustomLayoutAlgorithmBuilder. * In GenericLayoutProvider, we consider this new field to launch ELK layout without the standard ArrangeSelection mechanism. * In case of ArrangeSelection, in org.eclipse.sirius.diagram.elk.GmfLayoutEditPolicy.getCommand(Request), the root element was not retrieved (because the first element was the root). * ELKLayoutNodeProvider no longer implements ExtendableLayoutProvider. This was added for bug 540987 [1] (commit 066b0d28 [2]). But this bugzilla has been reopened because of problem. * ElkDiagramLayoutConnector did not handle the case where the root is no a diagram since this commit 35201b83 [3] for bug 538373 [4]. This commit partially reverts this modification to set back this ability. * Only TopGraphicEditPart are now considered for method ElkDiagramLayoutConnector.commonParent. This avoids to have intermediate AbstractDNode*CompartmentEditPart as parent. * During an arrange all, the origin location is now the same as "Reset origin" action. [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=540987 [2] http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=066b0d28cc05a6a53814e8691521181859682777 [3] https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=35201b83f616bce91b378aa0dd23f14c97dc7080 [4] https://bugs.eclipse.org/bugs/show_bug.cgi?id=538373 Bug: 568037 Change-Id: I6ff9f4d3010ad4c0475cb6a0de55ab743a989f07 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.elk.debug/src/org/eclipse/sirius/diagram/elk/debug/ExportToElkGraphHandler.java20
-rw-r--r--plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKAlgorithmProvider.java1
-rw-r--r--plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKLayoutNodeProvider.java47
-rw-r--r--plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ElkDiagramLayoutConnector.java124
-rw-r--r--plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/GmfLayoutEditPolicy.java9
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerEditPolicy.java27
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/api/layout/CustomLayoutAlgorithm.java35
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/internal/layout/GenericLayoutProvider.java129
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html6
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile1
10 files changed, 287 insertions, 112 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.elk.debug/src/org/eclipse/sirius/diagram/elk/debug/ExportToElkGraphHandler.java b/plugins/org.eclipse.sirius.diagram.elk.debug/src/org/eclipse/sirius/diagram/elk/debug/ExportToElkGraphHandler.java
index eb436f89fa..eefb49a178 100644
--- a/plugins/org.eclipse.sirius.diagram.elk.debug/src/org/eclipse/sirius/diagram/elk/debug/ExportToElkGraphHandler.java
+++ b/plugins/org.eclipse.sirius.diagram.elk.debug/src/org/eclipse/sirius/diagram/elk/debug/ExportToElkGraphHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Obeo
+ * Copyright (c) 2019, 2020 Obeo
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ package org.eclipse.sirius.diagram.elk.debug;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -52,7 +53,6 @@ import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.AbstractLayoutPro
import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.LayoutProvider;
import org.eclipse.sirius.diagram.ui.tools.api.requests.RequestConstants;
import org.eclipse.sirius.ext.base.Option;
-import org.eclipse.sirius.ext.base.Options;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -76,8 +76,8 @@ public class ExportToElkGraphHandler extends AbstractHandler {
if (structuredSelection.getFirstElement() instanceof DiagramEditPart) {
DiagramEditPart diagramEditPart = (DiagramEditPart) structuredSelection.getFirstElement();
CustomLayoutConfiguration customLayoutConfiguration;
- Option<CustomLayoutConfiguration> optionnalCustomLayoutConfiguration = getAssociatedElkLayoutConfiguration(diagramEditPart);
- if (optionnalCustomLayoutConfiguration.some()) {
+ Optional<CustomLayoutConfiguration> optionnalCustomLayoutConfiguration = getAssociatedElkLayoutConfiguration(diagramEditPart);
+ if (optionnalCustomLayoutConfiguration.isPresent()) {
customLayoutConfiguration = optionnalCustomLayoutConfiguration.get();
} else {
MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.ExportToElkGraphHandler_elkExportDialogTitle,
@@ -106,7 +106,7 @@ public class ExportToElkGraphHandler extends AbstractHandler {
ElkDiagramLayoutConnector connector = injector.getInstance(ElkDiagramLayoutConnector.class);
connector.setLayoutConfiguration(customLayoutConfiguration);
- LayoutMapping layoutMapping = connector.buildLayoutGraph(diagramEditPart, diagramEditPart.getChildren());
+ LayoutMapping layoutMapping = connector.buildLayoutGraph(diagramEditPart, diagramEditPart.getChildren(), true);
ElkDiagramLayoutConnector.storeResult(layoutMapping.getLayoutGraph(),
((org.eclipse.sirius.viewpoint.DRepresentation) ((org.eclipse.gmf.runtime.notation.Diagram) diagramEditPart.getModel()).getElement()).getName(), "", true);
@@ -119,8 +119,8 @@ public class ExportToElkGraphHandler extends AbstractHandler {
return null;
}
- public Option<CustomLayoutConfiguration> getAssociatedElkLayoutConfiguration(DiagramEditPart diagramEditPart) {
- Option<CustomLayoutConfiguration> result = Options.newNone();
+ public Optional<CustomLayoutConfiguration> getAssociatedElkLayoutConfiguration(DiagramEditPart diagramEditPart) {
+ Optional<CustomLayoutConfiguration> result = Optional.empty();
org.eclipse.sirius.diagram.elk.debug.gmf.layout.LayoutService layoutService = org.eclipse.sirius.diagram.elk.debug.gmf.layout.LayoutService.getInstance();
List<Object> hints = new ArrayList<>(2);
hints.add(LayoutType.DEFAULT);
@@ -142,11 +142,7 @@ public class ExportToElkGraphHandler extends AbstractHandler {
if (optionalProvider.get() instanceof AbstractLayoutProvider) {
LayoutProvider layoutProvider = ((AbstractLayoutProvider) optionalProvider.get()).getDiagramLayoutProvider(diagramEditPart, layoutHint);
if (layoutProvider instanceof GenericLayoutProvider) {
- CustomLayoutConfiguration customLayoutConfiguration = ((GenericLayoutProvider) layoutProvider).getLayoutConfiguration(diagramEditPart);
- if (customLayoutConfiguration != null) {
- result = Options.newSome(customLayoutConfiguration);
- }
-
+ result = ((GenericLayoutProvider) layoutProvider).getLayoutConfiguration(diagramEditPart);
}
}
}
diff --git a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKAlgorithmProvider.java b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKAlgorithmProvider.java
index 5e0397c45d..fda116a9b5 100644
--- a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKAlgorithmProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKAlgorithmProvider.java
@@ -64,6 +64,7 @@ public class ELKAlgorithmProvider implements CustomLayoutAlgorithmProvider {
.setLayoutSupplier(() -> new ELKLayoutNodeProvider())
.setLayoutOptions(layoutOptions)
.setLaunchSnapAfter(false)
+ .setStandardArrangeSelectionMechanism(false)
.build();
//@formatter:on
layoutAlgorithms.add(customLayoutAlgorithm);
diff --git a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKLayoutNodeProvider.java b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKLayoutNodeProvider.java
index eeb095e1fe..2790d446e5 100644
--- a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKLayoutNodeProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ELKLayoutNodeProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Obeo
+ * Copyright (c) 2018, 2020 Obeo
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -19,17 +19,17 @@ import java.util.Optional;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.draw2d.graph.Node;
import org.eclipse.elk.core.service.LayoutConnectorsService;
import org.eclipse.elk.core.service.LayoutMapping;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.sirius.common.tools.api.util.EclipseUtil;
-import org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutExtender;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.DDiagramEditPart;
import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.DefaultLayoutProvider;
-import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.ExtendableLayoutProvider;
+import org.eclipse.sirius.diagram.ui.tools.internal.util.EditPartQuery;
import com.google.inject.Injector;
@@ -39,19 +39,33 @@ import com.google.inject.Injector;
* @author <a href=mailto:pierre.guilet@obeo.fr>Pierre Guilet</a>
*
*/
-public class ELKLayoutNodeProvider extends DefaultLayoutProvider implements ExtendableLayoutProvider {
- private final LayoutExtender extender = new LayoutExtender(this);
+@SuppressWarnings("restriction")
+public class ELKLayoutNodeProvider extends DefaultLayoutProvider {
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes" })
@Override
public Command layoutEditParts(final List selectedObjects, final IAdaptable layoutHint) {
+ return layoutEditParts(selectedObjects, layoutHint, false);
+ }
+
+ @SuppressWarnings({ "rawtypes" })
+ @Override
+ public Command layoutEditParts(final List selectedObjects, final IAdaptable layoutHint, final boolean isArrangeAll) {
List<IELKLayoutExtension> elkLayoutExtensions = getLayoutExtensions();
DiagramEditPart diagramEditPart = layoutHint.getAdapter(DiagramEditPart.class);
+
+ if (diagramEditPart == null) {
+ IGraphicalEditPart editPart = layoutHint.getAdapter(IGraphicalEditPart.class);
+ diagramEditPart = Optional.ofNullable(editPart).map(graphicalEditPart -> new EditPartQuery(graphicalEditPart).getFirstAncestorOfType(DDiagramEditPart.class)).get();
+ }
+ if (diagramEditPart == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
Injector injector = LayoutConnectorsService.getInstance().getInjector(null, selectedObjects);
ElkDiagramLayoutConnector connector = injector.getInstance(ElkDiagramLayoutConnector.class);
connector.setLayoutConfiguration(layoutConfiguration);
- LayoutMapping layoutMapping = connector.buildLayoutGraph(diagramEditPart, selectedObjects);
+ LayoutMapping layoutMapping = connector.buildLayoutGraph(diagramEditPart, selectedObjects, isArrangeAll);
if (DiagramElkPlugin.getDefault().isDebugging()) {
ElkDiagramLayoutConnector.storeResult(layoutMapping.getLayoutGraph(),
@@ -112,19 +126,4 @@ public class ELKLayoutNodeProvider extends DefaultLayoutProvider implements Exte
}
return layoutExtensions;
}
-
- @Override
- public boolean handleConnectableListItems() {
- return true;
- }
-
- @Override
- public Rectangle provideNodeMetrics(Node node) {
- return null;
- }
-
- @Override
- public LayoutExtender getExtender() {
- return extender;
- }
}
diff --git a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ElkDiagramLayoutConnector.java b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ElkDiagramLayoutConnector.java
index cc6c6f237c..502211c5d7 100644
--- a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ElkDiagramLayoutConnector.java
+++ b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/ElkDiagramLayoutConnector.java
@@ -86,6 +86,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.TopGraphicEditPart;
import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
@@ -128,6 +129,7 @@ import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListElementEditPar
import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusDescriptionCompartmentEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusNoteEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusTextEditPart;
+import org.eclipse.sirius.diagram.ui.internal.operation.ResetOriginChangeModelOperation;
import org.eclipse.sirius.diagram.ui.internal.refresh.GMFHelper;
import org.eclipse.sirius.diagram.ui.tools.api.graphical.edit.styles.IBorderItemOffsets;
import org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.AlphaDropShadowBorder;
@@ -162,6 +164,7 @@ import com.google.inject.Singleton;
* @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a>
*
*/
+@SuppressWarnings("restriction")
@Singleton
public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
@@ -184,6 +187,12 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
public static final String PREF_EXEC_TIME_MEASUREMENT = "elk.exectime.measure";
+ /**
+ * By default, the layout provider will enlarge a container until it is large enough to contain its children. If
+ * this option is set, it won't do so (during the application of the layout: {@link #transferLayout(LayoutMapping)}.
+ */
+ public static final IProperty<Boolean> NODE_SIZE_FIXED_SIZE = new Property<Boolean>("org.eclipse.sirius.diagram.elk.fixedNodeSize", false, null, null);
+
@Inject
private IEditPartFilter editPartFilter;
@@ -331,9 +340,11 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
* the diagram edit part for which layout is performed
* @param layoutedPart
* the part(s) for which layout is performed, or {@code null} if the whole diagram shall be layouted
+ * @param isArrangeAll
+ * true if the layout concerns an arrange of all elements of the diagram, false otherwise.
* @return a layout graph mapping, or {@code null} if the given workbench part or diagram part is not supported
*/
- public LayoutMapping buildLayoutGraph(final DiagramEditPart diagramEditPart, final Object layoutedPart) {
+ public LayoutMapping buildLayoutGraph(final DiagramEditPart diagramEditPart, final Object layoutedPart, final boolean isArrangeAll) {
// choose the layout root edit part
IGraphicalEditPart layoutRootPart = null;
@@ -351,7 +362,7 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
for (Object object : selection) {
if (object instanceof IGraphicalEditPart) {
if (layoutRootPart != null) {
- EditPart parent = commonParent(layoutRootPart, (EditPart) object);
+ EditPart parent = commonParent(layoutRootPart, (IGraphicalEditPart) object);
if (parent != null && !(parent instanceof RootEditPart)) {
layoutRootPart = (IGraphicalEditPart) parent;
}
@@ -365,9 +376,9 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
selectedParts = new ArrayList<ShapeNodeEditPart>(selection.size());
for (Object object : selection) {
if (object instanceof IGraphicalEditPart) {
- EditPart editPart = (EditPart) object;
- while (editPart != null && editPart.getParent() != layoutRootPart) {
- editPart = editPart.getParent();
+ IGraphicalEditPart editPart = (IGraphicalEditPart) object;
+ while (editPart != null && getTopGraphicParentEditPartIfPresent(editPart) != layoutRootPart) {
+ editPart = getTopGraphicParentEditPartIfPresent(editPart);
}
if (editPart instanceof ShapeNodeEditPart && editPartFilter.filter(editPart) && !selectedParts.contains(editPart)) {
if (editPart instanceof SiriusNoteEditPart) {
@@ -383,8 +394,12 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
}
}
+ if (layoutRootPart == null) {
+ layoutRootPart = diagramEditPart;
+ }
+
// create the mapping
- LayoutMapping mapping = buildLayoutGraph(selectedParts, diagramEditPart);
+ LayoutMapping mapping = buildLayoutGraph(layoutRootPart, selectedParts, diagramEditPart, isArrangeAll);
return mapping;
}
@@ -398,9 +413,9 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
* the second edit part
* @return the common parent, or {@code null} if there is none
*/
- protected static EditPart commonParent(final EditPart editPart1, final EditPart editPart2) {
- EditPart ep1 = editPart1;
- EditPart ep2 = editPart2;
+ protected static EditPart commonParent(final IGraphicalEditPart editPart1, final IGraphicalEditPart editPart2) {
+ IGraphicalEditPart ep1 = editPart1;
+ IGraphicalEditPart ep2 = editPart2;
do {
if (isParent(ep1, ep2)) {
return ep1;
@@ -408,13 +423,29 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
if (isParent(ep2, ep1)) {
return ep2;
}
- ep1 = ep1.getParent();
- ep2 = ep2.getParent();
+ ep1 = getTopGraphicParentEditPartIfPresent(ep1);
+ ep2 = getTopGraphicParentEditPartIfPresent(ep2);
} while (ep1 != null && ep2 != null);
return null;
}
/**
+ * Return the {@link TopGraphicEditPart} of the parent, if it has one, or the parent itself. This avoids to consider
+ * potential intermediate AbstractDNode*CompartmentEditPart as parent.
+ *
+ * @return The {@link TopGraphicEditPart} of the parent, if it has one, or the parent itself.
+ */
+ private static IGraphicalEditPart getTopGraphicParentEditPartIfPresent(IGraphicalEditPart node) {
+ EditPart parentEditPart = node.getParent();
+ if (parentEditPart instanceof IGraphicalEditPart) {
+ IGraphicalEditPart graphicalParentEditPart = (IGraphicalEditPart) parentEditPart;
+ TopGraphicEditPart topGraphicEditPart = graphicalParentEditPart.getTopGraphicEditPart();
+ return topGraphicEditPart != null ? topGraphicEditPart : graphicalParentEditPart;
+ }
+ return null;
+ }
+
+ /**
* Determine whether the first edit part is a parent of or equals the second one.
*
* @param parent
@@ -449,32 +480,64 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
* processed
* @param diagramEditPart
* the diagram edit part, or {@code null}
+ * @param isArrangeAll
+ * true if the layout concerns an arrange of all elements of the diagram, false otherwise.
* @return a layout graph mapping
*/
- protected LayoutMapping buildLayoutGraph(final List<ShapeNodeEditPart> selection, final DiagramEditPart diagramEditPart) {
+ protected LayoutMapping buildLayoutGraph(final IGraphicalEditPart layoutRootPart, final List<ShapeNodeEditPart> selection, final DiagramEditPart diagramEditPart, final boolean isArrangeAll) {
LayoutMapping mapping = new LayoutMapping(null);
mapping.setProperty(CONNECTIONS, new LinkedList<ConnectionEditPart>());
- mapping.setParentElement(diagramEditPart);
+ mapping.setParentElement(layoutRootPart);
// find the diagram edit part
mapping.setProperty(DIAGRAM_EDIT_PART, diagramEditPart);
Map<LayoutOptionTarget, Set<LayoutOption>> elkTargetToOptionsOevrrideMap = constructElkOptionTargetToOptionsMap();
- // start with the whole diagram as root for layout. We cannot start from a diagram element even with a selection
- // layouting because if it has ports it is not supported. The top node is there only to support some meta data.
ElkNode topNode = ElkGraphUtil.createGraph();
applyOptionsRelatedToElementTarget(topNode, elkTargetToOptionsOevrrideMap);
- Rectangle rootBounds = diagramEditPart.getFigure().getBounds();
- String labelText = diagramEditPart.getDiagramView().getName();
- if (labelText.length() > 0) {
- ElkLabel label = ElkGraphUtil.createLabel(topNode);
- label.setText(labelText);
+ if (layoutRootPart instanceof ShapeNodeEditPart && selection.isEmpty()) {
+ // If the root part is a ShapeNodeEditPart and the selection is empty, this implies an arrange selection on
+ // only one element (ie one parent). So we want to keep it at a fixed location. For that we use the bounds
+ // of the node to determine the size of the graph. We also set its identifier according to its only child.
+ // We can not use directly the node as the graph root (in case of it has bordered node) .
+ if (((View) layoutRootPart.getModel()).getElement() instanceof DDiagramElement) {
+ topNode.setIdentifier(((DDiagramElement) ((View) layoutRootPart.getModel()).getElement()).getName() + "_graph");
+ }
+
+ IFigure nodeFigure = layoutRootPart.getFigure();
+ Rectangle childAbsoluteBounds = getAbsoluteBounds(nodeFigure);
+
+ topNode.setLocation(0, 0);
+ topNode.setDimensions(childAbsoluteBounds.preciseX() + childAbsoluteBounds.preciseWidth(), childAbsoluteBounds.preciseY() + childAbsoluteBounds.preciseHeight());
+
+ // We add the node to layout to the selection (that is empty)
+ selection.add((ShapeNodeEditPart) layoutRootPart);
+ } else {
+ // Arrange all elements of the diagram, or arrange selection (sub-part of the diagram or a container)
+ // Start with the container (ie container or diagram) as root for layout. This top node is there to support
+ // some meta data.
+ Rectangle rootBounds = layoutRootPart.getFigure().getBounds();
+ if (layoutRootPart == diagramEditPart) {
+ String labelText = diagramEditPart.getDiagramView().getName();
+ if (labelText.length() > 0) {
+ ElkLabel label = ElkGraphUtil.createLabel(topNode);
+ label.setText(labelText);
+ }
+ } else {
+ topNode.setLocation(rootBounds.x, rootBounds.y);
+ }
+ topNode.setDimensions(rootBounds.width, rootBounds.height);
+ if (layoutRootPart instanceof ShapeNodeEditPart) {
+ // Fix the size of the container. Even if this option is ignored by ELK, we use it to store this
+ // information. It is used later to ignore the layout of this container as we want to keep the same size
+ // and location.
+ topNode.setProperty(ElkDiagramLayoutConnector.NODE_SIZE_FIXED_SIZE, true);
+ }
+ mapping.getGraphMap().put(topNode, layoutRootPart);
}
- topNode.setDimensions(rootBounds.width, rootBounds.height);
- mapping.getGraphMap().put(topNode, diagramEditPart);
- // we set the ELK algorithm to use from viewpoint id defined.
+ // Set the ELK algorithm to use from viewpoint id defined.
topNode.setProperty(CoreOptions.ALGORITHM, layoutConfiguration.getId().trim());
mapping.setLayoutGraph(topNode);
@@ -494,10 +557,16 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
}
}
- mapping.setProperty(COORDINATE_OFFSET, new KVector(minx, miny));
+ // Use ResetOriginChangeModelOperation.MARGIN instead of minx or miny when arranging all elements of the
+ // diagram
+ if (isArrangeAll) {
+ mapping.setProperty(COORDINATE_OFFSET, new KVector(ResetOriginChangeModelOperation.MARGIN, ResetOriginChangeModelOperation.MARGIN));
+ } else {
+ mapping.setProperty(COORDINATE_OFFSET, new KVector(minx, miny));
+ }
} else {
// traverse all children of the layout root part
- buildLayoutGraphRecursively(mapping, topNode, diagramEditPart, elkTargetToOptionsOevrrideMap);
+ buildLayoutGraphRecursively(mapping, topNode, layoutRootPart, elkTargetToOptionsOevrrideMap);
}
// transform all connections in the selected area
@@ -635,7 +704,10 @@ public class ElkDiagramLayoutConnector implements IDiagramLayoutConnector {
IGraphicalEditPart part = (IGraphicalEditPart) entry.getValue();
if (!(part instanceof AbstractDNodeListCompartmentEditPart || part instanceof AbstractDNodeContainerCompartmentEditPart)) {
// We ignore compartment edit part that are created into ELK side just to have good layout results
- applyLayoutRequest.addElement(graphElement, part);
+ if (!graphElement.getProperty(ElkDiagramLayoutConnector.NODE_SIZE_FIXED_SIZE)) {
+ // We do not modify layout of node/graph if the option "Fixed Graph Size" has been set before.
+ applyLayoutRequest.addElement(graphElement, part);
+ }
}
}
}
diff --git a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/GmfLayoutEditPolicy.java b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/GmfLayoutEditPolicy.java
index 512155616b..72e5872a5e 100644
--- a/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/GmfLayoutEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.elk/src/org/eclipse/sirius/diagram/elk/GmfLayoutEditPolicy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 Kiel University and others.
+ * Copyright (c) 2009, 2020 Kiel University and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -130,7 +130,12 @@ public class GmfLayoutEditPolicy extends AbstractEditPolicy {
// edges... For the time being, we set the routing style according to the property value of the root
// element.
if (layoutRequest.getElements().size() > 0) {
- ElkNode rootElement = ElkGraphUtil.containingGraph(layoutRequest.getElements().get(0).getFirst());
+ ElkGraphElement graphElement = layoutRequest.getElements().get(0).getFirst();
+ ElkNode rootElement = ElkGraphUtil.containingGraph(graphElement);
+ if (rootElement == null && graphElement instanceof ElkNode) {
+ // The first item of the list elements to layout is the root.
+ rootElement = (ElkNode) graphElement;
+ }
if (rootElement != null) {
EdgeRouting edgeRouting = rootElement.getProperty(CoreOptions.EDGE_ROUTING);
if (edgeRouting.equals(EdgeRouting.ORTHOGONAL)) {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerEditPolicy.java
index 4f7d8aa368..f205623f9c 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusContainerEditPolicy.java
@@ -42,13 +42,11 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
import org.eclipse.gmf.runtime.diagram.ui.services.layout.LayoutType;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.sirius.diagram.description.CustomLayoutConfiguration;
-import org.eclipse.sirius.diagram.ui.api.layout.CustomLayoutAlgorithm;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramElementContainerEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.commands.CenterEdgeLayoutCommand;
import org.eclipse.sirius.diagram.ui.internal.edit.commands.DistributeCommand;
import org.eclipse.sirius.diagram.ui.internal.layout.GenericLayoutProvider;
-import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin;
+import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.LayoutProvider;
import org.eclipse.sirius.diagram.ui.tools.api.requests.DistributeRequest;
import org.eclipse.sirius.diagram.ui.tools.internal.commands.SnapCommand;
import org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.LayoutService;
@@ -197,31 +195,14 @@ public class SiriusContainerEditPolicy extends ContainerEditPolicy {
private boolean shouldLaunchSnapTo(List<? extends IGraphicalEditPart> editparts) {
Optional<? extends IGraphicalEditPart> optionalFirstEditPart = editparts.stream().findFirst();
if (optionalFirstEditPart.isPresent()) {
- Optional<CustomLayoutAlgorithm> optionalLayoutAlgorithm = getCustomLayoutAlgorithm(optionalFirstEditPart.get());
- // If a CustomLayoutAlgorithm has been provided, we check that it allows to perform the Snap to command
- // after.
- if (optionalLayoutAlgorithm.isPresent()) {
- return optionalLayoutAlgorithm.get().isLaunchSnapAfter();
+ LayoutProvider layoutProvider = LayoutService.getProvider(optionalFirstEditPart.get());
+ if (layoutProvider instanceof GenericLayoutProvider) {
+ return ((GenericLayoutProvider) layoutProvider).shouldLaunchSnapTo(optionalFirstEditPart.get());
}
}
return true;
}
- private Optional<CustomLayoutAlgorithm> getCustomLayoutAlgorithm(IGraphicalEditPart iGraphicalEditPart) {
- //@formatter:off
- return Optional.of(iGraphicalEditPart)
- .map(LayoutService::getProvider)
- .filter(GenericLayoutProvider.class::isInstance)
- .map(GenericLayoutProvider.class::cast)
- .map(layoutProvider -> layoutProvider.getLayoutConfiguration(iGraphicalEditPart))
- .flatMap(this::getCustomLayoutAlgorithm);
- //@formatter:on
- }
-
- private Optional<CustomLayoutAlgorithm> getCustomLayoutAlgorithm(CustomLayoutConfiguration configuration) {
- return Optional.ofNullable(DiagramUIPlugin.getPlugin().getLayoutAlgorithms().get(configuration.getId()));
- }
-
// CHECKSTYLE:ON
/**
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/api/layout/CustomLayoutAlgorithm.java b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/api/layout/CustomLayoutAlgorithm.java
index cec3cd0888..df029c524e 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/api/layout/CustomLayoutAlgorithm.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/api/layout/CustomLayoutAlgorithm.java
@@ -18,6 +18,7 @@ import java.util.function.Supplier;
import org.eclipse.sirius.diagram.description.LayoutOption;
import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.DefaultLayoutProvider;
+import org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.ArrangeSelectionLayoutProvider;
/**
* A component providing all needed information to provide a custom layout algorithm that can be used to layout Sirius
@@ -61,6 +62,14 @@ public final class CustomLayoutAlgorithm {
*/
private boolean launchSnapAfter = true;
+ /**
+ * In Sirius, the arrange selection is handled by using the arrange all and specific "pinned" elements. This is the
+ * scope of {@link ArrangeSelectionLayoutProvider}. For some layout algorithms, it can be useful to disable this
+ * specific behavior. This is the case for ELK, for example.
+ *
+ */
+ private boolean useStandardArrangeSelectionMechanism = true;
+
private CustomLayoutAlgorithm() {
}
@@ -119,6 +128,16 @@ public final class CustomLayoutAlgorithm {
return launchSnapAfter;
}
+ /**
+ * Whether the current algorithm relies on the standard ArrangeSelection mechanism see
+ * {@link ArrangeSelectionLayoutProvider} for more details.
+ *
+ * @return true if it relies on the standard ArrangeSelection, false otherwise.
+ */
+ public boolean useStandardArrangeSelectionMechanism() {
+ return useStandardArrangeSelectionMechanism;
+ }
+
@Override
public String toString() {
return this.id;
@@ -155,6 +174,8 @@ public final class CustomLayoutAlgorithm {
private boolean launchSnapAfter;
+ private boolean useStandardArrangeSelectionMechanism;
+
CustomLayoutAlgorithmBuilder(String id) {
this.id = Objects.requireNonNull(id);
}
@@ -222,6 +243,19 @@ public final class CustomLayoutAlgorithm {
}
/**
+ * Set whether the algorithm relies on the standard ArrangeSelection mechanism see
+ * {@link ArrangeSelectionLayoutProvider} for more details.
+ *
+ * @param useStandardArrangeSelectionMechanism
+ * true if the standard ArrangeSelection mechanism should be used with this algorithm, false otherwise.
+ * @return the current builder for convenience.
+ */
+ public CustomLayoutAlgorithmBuilder setStandardArrangeSelectionMechanism(boolean useStandardArrangeSelectionMechanism) {
+ this.useStandardArrangeSelectionMechanism = useStandardArrangeSelectionMechanism;
+ return this;
+ }
+
+ /**
* Build the new CustomLayoutAlgorithm according to the builder parameters.
*
* @return the new CustomLayoutAlgorithm.
@@ -234,6 +268,7 @@ public final class CustomLayoutAlgorithm {
customLayoutAlgorithm.layoutSupplier = Objects.requireNonNull(this.layoutSupplier);
customLayoutAlgorithm.layoutOptions = Objects.requireNonNull(this.layoutOptions);
customLayoutAlgorithm.launchSnapAfter = this.launchSnapAfter;
+ customLayoutAlgorithm.useStandardArrangeSelectionMechanism = this.useStandardArrangeSelectionMechanism;
return customLayoutAlgorithm;
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/internal/layout/GenericLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/internal/layout/GenericLayoutProvider.java
index b73211aa41..c4c157a209 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/internal/layout/GenericLayoutProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/internal/layout/GenericLayoutProvider.java
@@ -38,22 +38,47 @@ import org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.PinnedElemen
*/
public class GenericLayoutProvider implements LayoutProvider {
- private WeakHashMap<IGraphicalEditPart, DefaultLayoutProvider> editPartToLayoutProviderCache = new WeakHashMap<>();
+ /**
+ * An internal class to store the {@link DefaultLayoutProvider} and some associated data.
+ *
+ * @author lredor
+ */
+ private class LayoutProviderData {
+ DefaultLayoutProvider defaultLayoutProvider;
+
+ @SuppressWarnings("unused")
+ boolean shouldLaunchSnapTo;
+
+ @SuppressWarnings("unused")
+ boolean useStandardArrangeSelectionMechanism;
+
+ public LayoutProviderData(DefaultLayoutProvider defaultLayoutProvider, boolean shouldLaunchSnapTo, boolean useStandardArrangeSelectionMechanism) {
+ this.defaultLayoutProvider = defaultLayoutProvider;
+ this.shouldLaunchSnapTo = shouldLaunchSnapTo;
+ this.useStandardArrangeSelectionMechanism = useStandardArrangeSelectionMechanism;
+ }
+ }
+
+ private WeakHashMap<IGraphicalEditPart, LayoutProviderData> editPartToLayoutProviderCache = new WeakHashMap<>();
@Override
public AbstractLayoutEditPartProvider getLayoutNodeProvider(final IGraphicalEditPart partToLayout) {
- DefaultLayoutProvider defaultLayoutProvider = Optional.ofNullable(editPartToLayoutProviderCache.get(partToLayout)).orElseGet(() -> getGenericLayoutProvider(partToLayout));
- if (defaultLayoutProvider != null) {
+ AbstractLayoutEditPartProvider result = null;
+ LayoutProviderData layoutProviderData = Optional.ofNullable(editPartToLayoutProviderCache.get(partToLayout)).orElseGet(() -> getLayoutProviderData(partToLayout).orElseGet(null));
+ if (layoutProviderData != null) {
final CompoundLayoutProvider clp = new CompoundLayoutProvider();
- clp.addProvider(defaultLayoutProvider);
- if (defaultLayoutProvider instanceof ExtendableLayoutProvider) {
- ExtendableLayoutProvider layoutProvider = (ExtendableLayoutProvider) defaultLayoutProvider;
+ clp.addProvider(layoutProviderData.defaultLayoutProvider);
+ if (layoutProviderData.defaultLayoutProvider instanceof ExtendableLayoutProvider) {
+ ExtendableLayoutProvider layoutProvider = (ExtendableLayoutProvider) layoutProviderData.defaultLayoutProvider;
clp.addProvider(new PinnedElementsLayoutProvider(layoutProvider));
}
-
- return new ArrangeSelectionLayoutProvider(clp);
+ if (layoutProviderData.useStandardArrangeSelectionMechanism) {
+ result = new ArrangeSelectionLayoutProvider(clp);
+ } else {
+ result = clp;
+ }
}
- return null;
+ return result;
}
/**
@@ -61,9 +86,10 @@ public class GenericLayoutProvider implements LayoutProvider {
*
* @param partToLayout
* the part that will be layouted.
- * @return the layout configuration that should be used by the layout algorithm. Null if no such element exist.
+ * @return the layout configuration that should be used by the layout algorithm. Empty {@link Optional} if no such
+ * element exist.
*/
- public CustomLayoutConfiguration getLayoutConfiguration(final IGraphicalEditPart partToLayout) {
+ public Optional<CustomLayoutConfiguration> getLayoutConfiguration(final IGraphicalEditPart partToLayout) {
// we retrieve the layout configuration from the VSM.
EditPartQuery editPartQuery = new EditPartQuery(partToLayout);
DiagramDescription diagramDescription = editPartQuery.getDiagramDescription();
@@ -71,7 +97,30 @@ public class GenericLayoutProvider implements LayoutProvider {
if (diagramDescription != null && diagramDescription.getLayout() instanceof CustomLayoutConfiguration) {
layoutConfiguration = (CustomLayoutConfiguration) diagramDescription.getLayout();
}
- return layoutConfiguration;
+ return Optional.ofNullable(layoutConfiguration);
+ }
+
+ /**
+ * Whether the current layout provider authorize the "Snap to" features (snap to grid and snap to shape).
+ *
+ * @param partToLayout
+ * A part to layout (to find associated configuration)
+ *
+ * @return true if it authorizes, false otherwise.
+ */
+ public boolean shouldLaunchSnapTo(final IGraphicalEditPart partToLayout) {
+ Optional<CustomLayoutConfiguration> customLayoutConfiguration = getLayoutConfiguration(partToLayout);
+ if (customLayoutConfiguration.isPresent()) {
+ Optional<CustomLayoutAlgorithm> customLayoutAlgorithm = getCustomLayoutAlgorithm(customLayoutConfiguration.get());
+ if (customLayoutAlgorithm.isPresent()) {
+ return customLayoutAlgorithm.get().isLaunchSnapAfter();
+ }
+ }
+ return false;
+ }
+
+ private Optional<CustomLayoutAlgorithm> getCustomLayoutAlgorithm(CustomLayoutConfiguration configuration) {
+ return Optional.ofNullable(DiagramUIPlugin.getPlugin().getLayoutAlgorithms().get(configuration.getId()));
}
@Override
@@ -79,9 +128,9 @@ public class GenericLayoutProvider implements LayoutProvider {
// To avoid to compute the getGenericLayoutProvider twice (at the time we are testing that this provider
// provides a layout for the given edit part and the second time when calling getLayoutNodeProvider), we keep in
// cache the result.
- Optional<DefaultLayoutProvider> optionalLayoutProvider = Optional.ofNullable(getGenericLayoutProvider(container));
- if (optionalLayoutProvider.isPresent()) {
- editPartToLayoutProviderCache.put(container, optionalLayoutProvider.get());
+ Optional<LayoutProviderData> layoutProviderData = getLayoutProviderData(container);
+ if (layoutProviderData.isPresent()) {
+ editPartToLayoutProviderCache.put(container, layoutProviderData.get());
return true;
}
// In case of a provider was available but it could be not the case anymore.
@@ -89,6 +138,20 @@ public class GenericLayoutProvider implements LayoutProvider {
return false;
}
+ private Optional<LayoutProviderData> getLayoutProviderData(IGraphicalEditPart container) {
+ LayoutProviderData layoutProviderData = null;
+ Optional<CustomLayoutConfiguration> customLayoutConfiguration = getLayoutConfiguration(container);
+ if (customLayoutConfiguration.isPresent()) {
+ Optional<CustomLayoutAlgorithm> customLayoutAlgorithm = getCustomLayoutAlgorithm(customLayoutConfiguration.get());
+ if (customLayoutAlgorithm.isPresent()) {
+ DefaultLayoutProvider defaultLayoutProvider = getGenericLayoutProvider(customLayoutConfiguration.get(), customLayoutAlgorithm.get());
+ layoutProviderData = new LayoutProviderData(defaultLayoutProvider, customLayoutAlgorithm.get().isLaunchSnapAfter(), customLayoutAlgorithm.get().useStandardArrangeSelectionMechanism());
+ }
+ }
+
+ return Optional.ofNullable(layoutProviderData);
+ }
+
@Override
public boolean isDiagramLayoutProvider() {
return true;
@@ -103,17 +166,33 @@ public class GenericLayoutProvider implements LayoutProvider {
* @return the generic layout provider associated to the description of the {@link DDiagram} related to the given
* part. Null if no such element exists.
*/
- private DefaultLayoutProvider getGenericLayoutProvider(final IGraphicalEditPart partToLayout) {
- CustomLayoutConfiguration customLayoutConfiguration = getLayoutConfiguration(partToLayout);
- if (customLayoutConfiguration != null) {
- CustomLayoutAlgorithm customLayoutAlgorithm = DiagramUIPlugin.getPlugin().getLayoutAlgorithms().get(customLayoutConfiguration.getId());
- if (customLayoutAlgorithm != null) {
- DefaultLayoutProvider layoutAlgorithmInstance = customLayoutAlgorithm.getLayoutAlgorithmInstance();
- layoutAlgorithmInstance.setLayoutConfiguration(customLayoutConfiguration);
- return layoutAlgorithmInstance;
- }
+ private Optional<DefaultLayoutProvider> getGenericLayoutProvider(final IGraphicalEditPart partToLayout) {
+ Optional<CustomLayoutConfiguration> customLayoutConfiguration = getLayoutConfiguration(partToLayout);
+ if (customLayoutConfiguration.isPresent()) {
+ return getGenericLayoutProvider(customLayoutConfiguration.get());
}
- return null;
+ return Optional.empty();
}
+ /**
+ * Returns the generic layout provider associated to the given layout configuration.
+ *
+ * @param customLayoutConfiguration
+ * the layout configuration to get the generic layout provider.
+ * @return the generic layout provider associated to the given layout configuration..
+ */
+ private Optional<DefaultLayoutProvider> getGenericLayoutProvider(final CustomLayoutConfiguration customLayoutConfiguration) {
+ DefaultLayoutProvider defaultLayoutProvider = null;
+ Optional<CustomLayoutAlgorithm> customLayoutAlgorithm = getCustomLayoutAlgorithm(customLayoutConfiguration);
+ if (customLayoutAlgorithm.isPresent()) {
+ defaultLayoutProvider = getGenericLayoutProvider(customLayoutConfiguration, customLayoutAlgorithm.get());
+ }
+ return Optional.ofNullable(defaultLayoutProvider);
+ }
+
+ private DefaultLayoutProvider getGenericLayoutProvider(final CustomLayoutConfiguration customLayoutConfiguration, final CustomLayoutAlgorithm customLayoutAlgorithm) {
+ DefaultLayoutProvider layoutAlgorithmInstance = customLayoutAlgorithm.getLayoutAlgorithmInstance();
+ layoutAlgorithmInstance.setLayoutConfiguration(customLayoutConfiguration);
+ return layoutAlgorithmInstance;
+ }
}
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 38905e1cfa..11672011c0 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -191,6 +191,12 @@
<code>org.eclipse.sirius.diagram.ui.tools.api.layout.provider.AbstractLayoutProvider</code>. It allows for implementations to do specific code according to the arrangeAll or arrangeSelection aspect when layoutEditParts is called. By default, the code called is the same than the
<code>org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractLayoutEditPartProvider.layoutEditParts(List, IAdaptable)</code> implementation.
</li>
+ <li><span class="label label-success">Added</span> A new method,
+ <code>useStandardArrangeSelectionMechanism()</code> has been added in
+ <code>org.eclipse.sirius.diagram.ui.api.layout.CustomLayoutAlgorithm</code> to know if a specific layout algorithm relies on the behavior of
+ <code>org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.ArrangeSelectionLayoutProvider</code>. Previously, this was the case for all layout algorithm but it can be useful to disable it (for ELK layout for example). This method is associated with
+ <code>org.eclipse.sirius.diagram.ui.api.layout.CustomLayoutAlgorithm.CustomLayoutAlgorithmBuilder.setStandardArrangeSelectionMechanism(boolean)</code>
+ </li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.ui">Changes in
<code>org.eclipse.sirius.ui</code>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 948a7a038f..b55c4cef5f 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -33,6 +33,7 @@ h4. Changes in @org.eclipse.sirius.diagram.ui@
* <span class="label label-success">Added</span> A new method, @getDefaultDimension()@ has been added in @org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramElementContainerEditPart()@. This method was already used previously in Sirius but was private. It is now public and is used for example for having information during ELK layout.
* <span class="label label-success">Added</span> A new method, @layoutEditParts(List, IAdaptable, boolean)@ has been added in @org.eclipse.sirius.diagram.ui.tools.api.layout.provider.AbstractLayoutProvider@. It allows for implementations to do specific code according to the arrangeAll or arrangeSelection aspect when layoutEditParts is called. By default, the code called is the same than the @org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractLayoutEditPartProvider.layoutEditParts(List, IAdaptable)@ implementation.
+* <span class="label label-success">Added</span> A new method, @useStandardArrangeSelectionMechanism()@ has been added in @org.eclipse.sirius.diagram.ui.api.layout.CustomLayoutAlgorithm@ to know if a specific layout algorithm relies on the behavior of @org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.ArrangeSelectionLayoutProvider@. Previously, this was the case for all layout algorithm but it can be useful to disable it (for ELK layout for example). This method is associated with @org.eclipse.sirius.diagram.ui.api.layout.CustomLayoutAlgorithm.CustomLayoutAlgorithmBuilder.setStandardArrangeSelectionMechanism(boolean)@
h4. Changes in @org.eclipse.sirius.ui@

Back to the top