diff options
author | pguilet | 2017-06-13 09:54:28 +0000 |
---|---|---|
committer | pguilet | 2017-06-21 16:07:38 +0000 |
commit | 2926569faffd8d836c4442c4dacd07c356655fa3 (patch) | |
tree | 76ed4794cd8230f61738561261e09bc5e3eba971 | |
parent | b2117126f051d78ef337c309807a61e08ba78dbe (diff) | |
download | org.eclipse.sirius-2926569faffd8d836c4442c4dacd07c356655fa3.tar.gz org.eclipse.sirius-2926569faffd8d836c4442c4dacd07c356655fa3.tar.xz org.eclipse.sirius-2926569faffd8d836c4442c4dacd07c356655fa3.zip |
[517503] Fix command stack not working in some contexts
Doing a command in aird editor's models block that does not provide an
affected object now update the command stack correctly.
Bug: 517503
Change-Id: I250c08f0f2763e99c72c9f5497d4c17fea917f39
Signed-off-by: pguilet <pierre.guilet@obeo.fr>
-rw-r--r-- | plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java b/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java index 739a084c81..9adb3bfd92 100644 --- a/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java +++ b/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java @@ -105,6 +105,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.IActionBars; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchSite; @@ -479,7 +480,15 @@ public class GraphicalSemanticModelsHandler implements SessionListener, SessionM // Try to select the last affected objects. Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand(); if (mostRecentCommand != null) { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); + Collection<?> affectedObjects = mostRecentCommand.getAffectedObjects(); + if (!affectedObjects.isEmpty()) { + setSelectionToViewer(affectedObjects); + } else { + Tree tree = treeViewer.getTree(); + if (!tree.isDisposed() && tree.getItems().length > 0 && !tree.getItem(0).isDisposed()) { + setSelectionToViewer(Lists.newArrayList(tree.getItem(0).getData())); + } + } actionBars.updateActionBars(); } } |