diff options
| author | Florian Barbin | 2015-08-05 15:11:25 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-08-14 07:15:37 +0000 |
| commit | 8e2f39d01c8dc08b4c986a795a969c739e370951 (patch) | |
| tree | 7242e823cc4c367c884011807a6c1c3ad7499d4e | |
| parent | b072e3d4be8077b2934fd74ee1fb0932d4501b88 (diff) | |
| download | org.eclipse.sirius-8e2f39d01c8dc08b4c986a795a969c739e370951.tar.gz org.eclipse.sirius-8e2f39d01c8dc08b4c986a795a969c739e370951.tar.xz org.eclipse.sirius-8e2f39d01c8dc08b4c986a795a969c739e370951.zip | |
[460610] Fixes DDiagramEditorImpl abusive selection changes
* The DDiagramEditorImpl reacted to all selection changes. That caused
to change the diagram selection when selecting its own DSemanticDiagram
in the Model Explorer view.
Bug: 460610
Change-Id: I89369efff273d0ac442b31a2902f45e9f4efb77a
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
2 files changed, 28 insertions, 2 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java index 5b9ef9c0fe..c0abc4a248 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java @@ -206,6 +206,8 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.Saveable; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.part.IPage; +import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import com.google.common.collect.Iterables; @@ -959,7 +961,9 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE return; } - if (selection instanceof IStructuredSelection) { + // We want to change the diagram selection only on Outline page + // selection changes. + if (isDiagramOutlinePage(part) && selection instanceof IStructuredSelection) { final List<?> selected = ((IStructuredSelection) selection).toList(); final List<IGraphicalEditPart> result = new ArrayList<IGraphicalEditPart>(selected.size()); @@ -1012,6 +1016,20 @@ public class DDiagramEditorImpl extends SiriusDiagramEditor implements DDiagramE } } + private boolean isDiagramOutlinePage(IWorkbenchPart part) { + if (part instanceof ContentOutline) { + IPage page = ((ContentOutline) part).getCurrentPage(); + if (page instanceof DiagramOutlinePage) { + GraphicalViewer graphicalViewer = getGraphicalViewer(); + if (graphicalViewer != null) { + Control control = ((DiagramOutlinePage) page).getEditor(); + return control == graphicalViewer.getControl(); + } + } + } + return false; + } + @Override public boolean isSaveOnCloseNeeded() { /* diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java index e0f25d16df..07663af2e1 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DiagramOutlinePage.java @@ -300,6 +300,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { final MenuManager menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(final IMenuManager mgr) { menuManager.removeAll(); for (IObjectActionDelegateWrapper menuContribution : menuContributions) { @@ -488,6 +489,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { lws.setContents(thumbnail); disposeListener = new DisposeListener() { + @Override public void widgetDisposed(final DisposeEvent e) { if (thumbnail != null) { thumbnail.deactivate(); @@ -595,7 +597,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @return <code>Control</code> */ - protected Control getEditor() { + public Control getEditor() { return graphicalViewer.getControl(); } @@ -667,6 +669,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @see org.eclipse.jface.viewers.ISelection#isEmpty() */ + @Override public boolean isEmpty() { return selection.isEmpty(); } @@ -676,6 +679,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement() */ + @Override public Object getFirstElement() { return selection.getFirstElement(); } @@ -685,6 +689,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @see org.eclipse.jface.viewers.IStructuredSelection#iterator() */ + @Override public Iterator<?> iterator() { return selection.iterator(); } @@ -694,6 +699,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @see org.eclipse.jface.viewers.IStructuredSelection#size() */ + @Override public int size() { return selection.size(); } @@ -703,6 +709,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @see org.eclipse.jface.viewers.IStructuredSelection#toArray() */ + @Override public Object[] toArray() { return selection.toArray(); } @@ -712,6 +719,7 @@ public class DiagramOutlinePage extends AbstractExtendedContentOutlinePage { * * @see org.eclipse.jface.viewers.IStructuredSelection#toList() */ + @Override public List<?> toList() { return selection.toList(); } |
