diff options
| author | Florian Barbin | 2017-09-21 08:25:06 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-09-21 13:33:23 +0000 |
| commit | d5ed8025112b9090d44d74010ed0bfc56c60868a (patch) | |
| tree | 5000a11923517972fcfff5db697b7c6437aae0ed | |
| parent | 5dbddc142d6cc2567605ca92b59e70e923f37495 (diff) | |
| download | org.eclipse.sirius-d5ed8025112b9090d44d74010ed0bfc56c60868a.tar.gz org.eclipse.sirius-d5ed8025112b9090d44d74010ed0bfc56c60868a.tar.xz org.eclipse.sirius-d5ed8025112b9090d44d74010ed0bfc56c60868a.zip | |
[520632] Fixes snap to grid bug with two editor with the same id.
If two editors were opened with the same GMF Diagram id, there was a
confusion with the snap and grid preferences.
Bug: 520632
Change-Id: I8a6d256d0c1497043da3ecd42e109a7c9491ec24
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/DDiagramCanonicalSynchronizer.java | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/DDiagramCanonicalSynchronizer.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/DDiagramCanonicalSynchronizer.java index 22b4af7850..97f9c48f68 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/DDiagramCanonicalSynchronizer.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/diagram/DDiagramCanonicalSynchronizer.java @@ -35,7 +35,6 @@ import org.eclipse.emf.transaction.util.TransactionUtil; import org.eclipse.gef.rulers.RulerProvider; import org.eclipse.gmf.runtime.common.ui.services.editor.EditorService; import org.eclipse.gmf.runtime.common.ui.util.DisplayUtils; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer; @@ -76,8 +75,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; /** - * Synchronizer allowing to synchronize a DSemanticDiagram with its - * corresponding GMFDiagram. + * Synchronizer allowing to synchronize a DSemanticDiagram with its corresponding GMFDiagram. * * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a> * @@ -100,30 +98,26 @@ public class DDiagramCanonicalSynchronizer extends AbstractCanonicalSynchronizer * Default constructor. * * @param gmfDiagram - * the {@link Diagram} to update according to "semantic" - * DSemanticDiagram. + * the {@link Diagram} to update according to "semantic" DSemanticDiagram. */ public DDiagramCanonicalSynchronizer(Diagram gmfDiagram) { super(); this.gmfDiagram = gmfDiagram; this.connectionsFactory = new ConnectionsFactory(gmfDiagram, viewpointViewProvider); // Search if it possible to get snapToGrid and gridSpacing values from the store associated to an opened editor. - loadPreferencesFromOpenedDiagram(ViewUtil.getIdStr(gmfDiagram)); + loadPreferencesFromOpenedDiagram(); } /** - * Load the preferences from an opened diagram that has the given guid.<BR> + * Load the preferences from an opened diagram on the same GMF {@link Diagram}.<BR> * Inspired from * {@link org.eclipse.sirius.diagram.ui.tools.internal.print.SiriusDiagramPrintPreviewHelper#loadPreferencesFromOpenDiagram(String)}. - * - * @param id - * guid of the opened diagram to load the preferences for */ - private void loadPreferencesFromOpenedDiagram(String id) { + private void loadPreferencesFromOpenedDiagram() { List<? extends Object> diagramEditors = EditorService.getInstance().getRegisteredEditorParts(); @SuppressWarnings("unchecked") - Optional<DiagramEditor> diagramEditor = (Optional<DiagramEditor>) diagramEditors.stream().filter( - de -> de instanceof DiagramEditor && ((DiagramEditor) de).getDiagramEditPart() != null && id.equals(ViewUtil.getIdStr(((DiagramEditor) de).getDiagramEditPart().getDiagramView()))) + Optional<DiagramEditor> diagramEditor = (Optional<DiagramEditor>) diagramEditors.stream() + .filter(de -> de instanceof DiagramEditor && ((DiagramEditor) de).getDiagramEditPart() != null && gmfDiagram.equals(((DiagramEditor) de).getDiagramEditPart().getDiagramView())) .findFirst(); if (diagramEditor.isPresent()) { IDiagramGraphicalViewer viewer = diagramEditor.get().getDiagramGraphicalViewer(); @@ -266,10 +260,9 @@ public class DDiagramCanonicalSynchronizer extends AbstractCanonicalSynchronizer } /** - * center layout must be only done on the super containers : filter the - * createdViewsWithCenterLayout : only the container(s) of all the new - * created views must have a center layout. the filtered views must have a - * "normal" layout. + * center layout must be only done on the super containers : filter the createdViewsWithCenterLayout : only the + * container(s) of all the new created views must have a center layout. the filtered views must have a "normal" + * layout. * * @param createdViewsWithSpecialLayout * @param createdViewsToLayout |
