diff options
author | Maxime Porhel | 2020-10-21 14:43:42 +0000 |
---|---|---|
committer | Maxime Porhel | 2020-10-23 13:59:45 +0000 |
commit | 90189ba9383e5b76e9a510c1c99312c6d0e35893 (patch) | |
tree | 7dcf9cc0949e6dac1250d8174445807993505673 | |
parent | e17a3820d7ebc8dadf604e1d183fb8c077ad90f1 (diff) | |
download | org.eclipse.sirius-90189ba9383e5b76e9a510c1c99312c6d0e35893.tar.gz org.eclipse.sirius-90189ba9383e5b76e9a510c1c99312c6d0e35893.tar.xz org.eclipse.sirius-90189ba9383e5b76e9a510c1c99312c6d0e35893.zip |
[567517] Activate layout optimizations during arrange all
- Modify RefreshLayoutCommand to be able to launch a packing layout
- Modify the SequenceLayoutProvider to use a packing
RefreshLayoutCommand which enable the cache and optimize the computation
of the eventEnds used by the refresh oredring operations.
Bug: 567517
Change-Id: Ied36ac947b8bd837dc8f668c5a12768efac84084
Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
2 files changed, 29 insertions, 22 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/layout/SequenceLayoutProvider.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/layout/SequenceLayoutProvider.java index 5579af10d3..1f986276ca 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/layout/SequenceLayoutProvider.java +++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/layout/SequenceLayoutProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2009, 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 @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.sequence.ui.tool.internal.layout; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; import org.eclipse.core.runtime.IAdaptable; @@ -22,18 +20,13 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.commands.Command; import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.sirius.diagram.sequence.SequenceDDiagram; -import org.eclipse.sirius.diagram.sequence.business.internal.elements.SequenceDiagram; -import org.eclipse.sirius.diagram.sequence.business.internal.operation.RefreshGraphicalOrderingOperation; -import org.eclipse.sirius.diagram.sequence.business.internal.operation.RefreshSemanticOrderingsOperation; -import org.eclipse.sirius.diagram.sequence.business.internal.operation.SynchronizeGraphicalOrderingOperation; +import org.eclipse.sirius.diagram.sequence.business.internal.refresh.RefreshLayoutCommand; import org.eclipse.sirius.diagram.sequence.ui.Messages; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.SequenceDiagramEditPart; -import org.eclipse.sirius.diagram.ui.business.internal.operation.AbstractModelChangeOperation; import org.eclipse.sirius.diagram.ui.tools.api.command.DoNothingCommand; +import org.eclipse.sirius.diagram.ui.tools.api.command.GMFCommandWrapper; import org.eclipse.sirius.diagram.ui.tools.api.layout.provider.AbstractLayoutProvider; import org.eclipse.sirius.diagram.ui.tools.api.util.EditPartTools; -import org.eclipse.sirius.diagram.ui.tools.internal.edit.command.CommandFactory; /** * The layout provider for sequence diagrams. @@ -62,17 +55,8 @@ public class SequenceLayoutProvider extends AbstractLayoutProvider { private Command createArrangeAllCommand(SequenceDiagramEditPart sdep) { TransactionalEditingDomain transactionalEditingDomain = sdep.getEditingDomain(); - SequenceDiagram sequenceDiagram = sdep.getSequenceDiagram(); - SequenceDDiagram sequenceDDiagram = (SequenceDDiagram) sdep.resolveSemanticElement(); - Collection<AbstractModelChangeOperation<Boolean>> operations = new ArrayList<AbstractModelChangeOperation<Boolean>>(); - - operations.add(new RefreshGraphicalOrderingOperation(sequenceDiagram)); - operations.add(new RefreshSemanticOrderingsOperation(sequenceDDiagram)); - operations.add(new SynchronizeGraphicalOrderingOperation(sdep.getDiagramView(), true)); - - ICommand cmd = CommandFactory.createICommand(transactionalEditingDomain, operations); + ICommand cmd = new GMFCommandWrapper(transactionalEditingDomain, new RefreshLayoutCommand(transactionalEditingDomain, sdep.getDiagramView(), true, true)); cmd.setLabel(Messages.SequenceLayoutProvider_arrangeAllCommand); - return new ICommandProxy(cmd); } diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/refresh/RefreshLayoutCommand.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/refresh/RefreshLayoutCommand.java index 26179a39ac..7fdf5f8ac3 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/refresh/RefreshLayoutCommand.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/refresh/RefreshLayoutCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2011, 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 @@ -46,6 +46,8 @@ public class RefreshLayoutCommand extends RecordingCommand { private boolean refreshDiagram; + private boolean packingLayout; + /** * Default constructor. * @@ -59,9 +61,30 @@ public class RefreshLayoutCommand extends RecordingCommand { * {@inheritDoc} */ public RefreshLayoutCommand(TransactionalEditingDomain domain, Diagram diagram, boolean refreshDiagram) { + this(domain, diagram, refreshDiagram, false); + } + + /** + * Default constructor. + * + * @param diagram + * {@link Diagram} to refresh, used also to access {@link SequenceDDiagram} & {@link SequenceDiagram} to + * refresh + * + * @param refreshDiagram + * <code>true</code> if we should actually update the GMF model + * + * @param packingLayout + * <code>true</code> if the GMF model update must be done with a packing layout (arrange all for + * example). + * + * {@inheritDoc} + */ + public RefreshLayoutCommand(TransactionalEditingDomain domain, Diagram diagram, boolean refreshDiagram, boolean packingLayout) { super(domain, Messages.RefreshLayoutCommand_commandName); this.diagram = diagram; this.refreshDiagram = refreshDiagram; + this.packingLayout = packingLayout; } /** @@ -112,7 +135,7 @@ public class RefreshLayoutCommand extends RecordingCommand { /* * Launch a non-packing layout */ - AbstractModelChangeOperation<Boolean> synchronizeGraphicalOrderingOperation = new SynchronizeGraphicalOrderingOperation(diagram, false); + AbstractModelChangeOperation<Boolean> synchronizeGraphicalOrderingOperation = new SynchronizeGraphicalOrderingOperation(diagram, packingLayout); synchronizeGraphicalOrderingOperation.execute(); /* * The layout has probably changed graphical positions: re-compute the ordering to make sure it is |