Commit 1857c260 authored by Simon Barner's avatar Simon Barner
Browse files

Synchronize selection of model navigator and active (model) editor

Issue-Ref: 3084
Issue-Url: https://af3-developer.fortiss.org/issues/3084

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 2340c41e
AdvancedTreeViewerEditorBase.java 34e37880adc67c3ee45bcb74ed7572d3360bcc0f GREEN
AllocationDiagramEditorBase.java fa544546f73eea1150d90b7257b0e6bce82c288c GREEN
CommonDiagramEditorBase.java f0a243caa6fc7c66434ffb4028628c6d6aa657fd GREEN
CommonDiagramEditorBase.java 284c1fa70771c0f4a9393f6911f44561ea0c3a44 YELLOW
ConstraintBasedProcessEditor.java 06891ab7f5c5eb7549e8aee0d3760ea5a534d99d GREEN
ConstraintBasedProcessEditorHelper.java 651e909b90fe1b777206c35ca91a36630365435e GREEN
DiagramEditorBase.java 09663ce095074d1a8eef086284eea0a7776e0431 GREEN
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor;
import static org.conqat.ide.commons.ui.selection.SelectionUtils.checkAndPickFirstSafe;
import static org.eclipse.gef.SnapToGrid.PROPERTY_GRID_ENABLED;
import static org.eclipse.gef.SnapToGrid.PROPERTY_GRID_ORIGIN;
import static org.eclipse.gef.SnapToGrid.PROPERTY_GRID_SPACING;
......@@ -38,7 +39,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.conqat.ide.commons.ui.selection.SelectionUtils;
import org.eclipse.core.runtime.Platform;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.IFigure;
......@@ -107,6 +107,7 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.ui.service.IActionService;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
import org.fortiss.tooling.kernel.ui.util.SelectionUtils;
/**
* <p>
......@@ -201,10 +202,22 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
/** Selection listener used to update selection actions. */
private final ISelectionListener selectionListener = new ISelectionListener() {
/** Flag to avoid infinite recursion. */
private boolean inSelectionListener = false;
/** {@inheritDoc} */
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
EditPart ep = SelectionUtils.checkAndPickFirstSafe(selection, EditPart.class);
if(inSelectionListener) {
return;
}
inSelectionListener = true;
List<EObject> eObjects = getEObjectElements(selection);
// Synchronize selection of model element navigator
SelectionUtils.setSelection(eObjects, true, false);
EditPart ep = checkAndPickFirstSafe(selection, EditPart.class);
if(ep != null) {
Control control = ep.getViewer().getControl();
Object model = ep.getModel();
......@@ -224,6 +237,7 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
control.setToolTipText(hint);
}
updateActions(selectionActions);
inSelectionListener = false;
}
};
......
......@@ -9,4 +9,4 @@ MarkerViewPart.java cbb650271b6877af205421b7cb11f930440a7ef9 GREEN
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentProvider.java 1bdefa28c5e2c2619cabbcd1946269a52db34e6c GREEN
NavigatorTreeContentSorter.java 76fc94e441ac1a8f2c5ae573f0e2b1e6fa73c31a GREEN
NavigatorViewPart.java 76a5f5c0a8c891dfcd4aa98d9d3459e4b7af9b17 GREEN
NavigatorViewPart.java 1fd73a2d717304556bd86fbbb0f98aad4e7d354f YELLOW
......@@ -70,6 +70,7 @@ import org.fortiss.tooling.kernel.ui.service.IActionService;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.INavigatorService;
import org.fortiss.tooling.kernel.ui.util.PropertiesConstantUtils;
import org.fortiss.tooling.kernel.ui.util.SelectionUtils;
/**
* {@link ViewPart} of the model navigator provided by the tooling kernel.
......@@ -300,6 +301,9 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
@Override
public void selectionChanged(SelectionChangedEvent event) {
IActionService.getInstance().refresh();
// Set selection of active editor
SelectionUtils.setSelection(getSelectedModelElementList(), false, true);
// fire upon viewer selection change
firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY);
}
......
......@@ -7,7 +7,7 @@ EObjectSelectionUtils.java 928280b5dd3bb634debc1ac3be9f15b4e45f2683 GREEN
KernelUIUtils.java b038a28a44e17e5bca4d71f5dee70ee92e5324b9 GREEN
ObservableUtils.java 2ffced494a86bd7e8f8eb8882aec38b06f0f2818 GREEN
PropertiesConstantUtils.java 59b1a1e4d594bb98db3aa396f2ff6474ba405920 GREEN
SelectionUtils.java 3d6a80c9c9c62db53515a1f885c70f6fc3296f54 YELLOW
SelectionUtils.java 136096917a2357678c54339543a14fc3a63edf6d YELLOW
TutorialUIServiceUtils.java 416970bb9bd305acee064e2ac199df39cc98b475 GREEN
UndoRedoImpl.java f218500875bda0ef52f4cc2ccdf452825e6751f7 GREEN
WidgetsFactory.java e92285bee3189ecf1a3fbaede3c4ffb237fc81ed GREEN
......@@ -123,10 +123,32 @@ public class SelectionUtils {
* {@link EObject}s to be selected.
*/
public static void setSelection(List<EObject> eObjects) {
setSelection(eObjects, true, true);
}
/**
* Programmatically sets the objects to be selected in the currently active editor (NOP if there
* is none) and the model navigator.
*
* @param eObjects
* {@link EObject}s to be selected.
* @param updateNavigator
* Flag whether to update the model navigator
* @param updateActiveEditor
* Flag whether to update the currently active editor.
*/
public static void setSelection(List<EObject> eObjects, boolean updateNavigator,
boolean updateActiveEditor) {
ISelection selection = new StructuredSelection(eObjects);
INavigatorService ns = INavigatorService.getInstance();
ns.setCurrentSelection(selection);
if(updateNavigator) {
INavigatorService ns = INavigatorService.getInstance();
ns.setCurrentSelection(selection);
}
if(!updateActiveEditor) {
return;
}
IEditorPart activeEditor = getActiveEditor();
if(activeEditor == null) {
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment