diff options
| author | Laurent Redor | 2020-10-26 12:51:17 +0000 |
|---|---|---|
| committer | Laurent Redor | 2020-11-05 16:55:45 +0000 |
| commit | fa93312c74e550c40a6b64ebe91242437335a802 (patch) | |
| tree | b8cf9c84214f9c7fc0a3dcca27056282eccd6bb4 | |
| parent | e91363a303ee66dc18df06b7bc546df507e74b5a (diff) | |
| download | org.eclipse.sirius-fa93312c74e550c40a6b64ebe91242437335a802.tar.gz org.eclipse.sirius-fa93312c74e550c40a6b64ebe91242437335a802.tar.xz org.eclipse.sirius-fa93312c74e550c40a6b64ebe91242437335a802.zip | |
[568037] Update AbstractLayoutProvider capability
A new method has been added in AbstractLayoutProvider. It allows for
implementations to do specific code according to the arrangeAll or
arrangeSelection aspect when layoutEditParts is called.
This commit does not change anything else.
Bug: 568037
Change-Id: I1c829138be239acd7d3fa9727cf4ab2457895744
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
4 files changed, 46 insertions, 10 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/AbstractLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/AbstractLayoutProvider.java index ba10c9bfd7..9bc7bab7b3 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/AbstractLayoutProvider.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/AbstractLayoutProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2019 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2020 THALES GLOBAL SERVICES 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 @@ -132,6 +132,28 @@ public abstract class AbstractLayoutProvider extends AbstractLayoutEditPartProvi } /** + * Layout this list of selected objects, using the specified layout hint. The selected objects all reside within the + * same parent container. Other elements that are part of the container but not specified in the list of objects, + * are ignored.<BR/> + * This method is similar to {@link #layoutEditParts(List, IAdaptable)} but with additional information concerning + * <code>isArrangeAll</code>. Indeed, sometimes in caller we have this information and this avoids to recompute it + * later. The default implementation does nothing specific but implementation can do specific behavior. + * + * + * @param selectedObjects + * <code>List</code> of <code>EditPart</code> objects that are to be layed out. + * @param layoutHint + * <code>IAdaptable</code> hint to the provider to determine the layout kind. + * @param isArrangeAll + * true if the layout concerns an arrange of all elements of the diagram (ie the + * <code>selectedObjects</code> represent all the children of the diagram), false otherwise. + * @return <code>Command</code> that when executed will layout the edit parts in the container + */ + public Command layoutEditParts(List selectedObjects, IAdaptable layoutHint, boolean isArrangeAll) { + return layoutEditParts(selectedObjects, layoutHint); + } + + /** * Get the the diagram layout provider if there is one. * * @param diagramEditPart @@ -167,7 +189,11 @@ public abstract class AbstractLayoutProvider extends AbstractLayoutEditPartProvi } if (command == null) { final List<?> children = diagramEditPart.getChildren(); - command = layoutProvider.layoutEditParts(children, layoutHint); + if (layoutProvider instanceof AbstractLayoutProvider) { + command = ((AbstractLayoutProvider) layoutProvider).layoutEditParts(children, layoutHint, true); + } else { + command = layoutProvider.layoutEditParts(children, layoutHint); + } } return command; } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/CompoundLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/CompoundLayoutProvider.java index 6e10d0a424..8bad4d981d 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/CompoundLayoutProvider.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/provider/CompoundLayoutProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 THALES GLOBAL SERVICES. + * Copyright (c) 2007, 2020 THALES GLOBAL SERVICES. * 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 @@ -47,14 +47,13 @@ public class CompoundLayoutProvider extends AbstractLayoutProvider { this.realDelegatedProviders.add(provider); } - /** - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractLayoutEditPartProvider#layoutEditParts(java.util.List, - * org.eclipse.core.runtime.IAdaptable) - */ @Override public Command layoutEditParts(final List selectedObjects, final IAdaptable layoutHint) { + return layoutEditParts(selectedObjects, layoutHint, false); + } + + @Override + public Command layoutEditParts(final List selectedObjects, final IAdaptable layoutHint, final boolean isArrangeAll) { final CompoundCommand cc = new CompoundCommand(); final ArrayList<AbstractLayoutEditPartProvider> inverse = new ArrayList<AbstractLayoutEditPartProvider>(this.realDelegatedProviders); final Iterator<AbstractLayoutEditPartProvider> iterRealDelegatedProviders = inverse.listIterator(); @@ -63,7 +62,12 @@ public class CompoundLayoutProvider extends AbstractLayoutProvider { if (provider instanceof AbstractLayoutProvider) { ((AbstractLayoutProvider) provider).setViewsToChangeBoundsRequest(this.getViewsToChangeBoundsRequest()); } - final Command command = provider.layoutEditParts(new ArrayList<>(selectedObjects), layoutHint); + Command command; + if (provider instanceof AbstractLayoutProvider) { + command = ((AbstractLayoutProvider) provider).layoutEditParts(new ArrayList<>(selectedObjects), layoutHint, isArrangeAll); + } else { + command = provider.layoutEditParts(new ArrayList<>(selectedObjects), layoutHint); + } if (command != null && command.canExecute()) { cc.add(command); } diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 46ca66571e..38905e1cfa 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -186,6 +186,11 @@ <code>getDefaultDimension()</code> has been added in <code>org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramElementContainerEditPart()</code>. 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. </li> + <li><span class="label label-success">Added</span> A new method, + <code>layoutEditParts(List, IAdaptable, boolean)</code> has been added in + <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> </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 5aa283bb9f..948a7a038f 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -32,6 +32,7 @@ try { 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. h4. Changes in @org.eclipse.sirius.ui@ |
