summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2014-07-30 07:14:08 (EDT)
committerQuentin Le Menez2014-07-30 07:14:08 (EDT)
commita54d6be620edede8dc4d0f7f174fb4b6c840b6e2 (patch)
treeb545849d4b9ef4de11ec700ab8056eb4c7a033bb
parent3b5be2995a18bf80f38dfbffd4a880b039ba65f3 (diff)
downloadorg.eclipse.papyrus-a54d6be620edede8dc4d0f7f174fb4b6c840b6e2.zip
org.eclipse.papyrus-a54d6be620edede8dc4d0f7f174fb4b6c840b6e2.tar.gz
org.eclipse.papyrus-a54d6be620edede8dc4d0f7f174fb4b6c840b6e2.tar.bz2
440545: Switch from IrevealSemanticElement to NavigationTargetrefs/changes/82/30682/2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=440545 - changed from IRevealSemanticElement's revealSemanticElement methods to NavigationTarget's revealElement for the table selections - amended the existing classes LinkHelper, SynchronizableGmfDiagramEditor and ModelExplorerView Change-Id: I90ad7103812fd27c3ca729375bf1aa89f6a16c09 Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java81
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java30
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java74
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/LinkHelper.java25
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java16
5 files changed, 184 insertions, 42 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
index 42aa9c6..9418f5e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -14,6 +14,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -44,6 +45,8 @@ import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.commands.CheckedDiagramCommandStack;
import org.eclipse.papyrus.infra.core.editor.reload.IReloadContextProvider;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
@@ -72,8 +75,7 @@ import com.google.common.collect.Lists;
*
* This GMF editor contains a methods in order to reveal visual element from a list of semantic element.
* <p/>
- * It also provides subclasses with common capability to automatically migrate (reconcile) input
- * diagrams between papurus versions.
+ * It also provides subclasses with common capability to automatically migrate (reconcile) input diagrams between papurus versions.
*/
@SuppressWarnings("restriction")
@@ -81,7 +83,7 @@ import com.google.common.collect.Lists;
public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implements IRevealSemanticElement, NavigationTarget {
private Collection<PalettePageWrapper> palettePages;
-
+
private Object palettePageState;
public SynchronizableGmfDiagramEditor(boolean hasFlyoutPalette) {
@@ -122,35 +124,45 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
GraphicalViewer graphicalViewer = getGraphicalViewer();
if(graphicalViewer != null) {
- //look for among all edit part if the semantic is contained in the list
+ //look amidst all edit part if the semantic is contained in the list
Iterator<?> iter = graphicalViewer.getEditPartRegistry().values().iterator();
IGraphicalEditPart researchedEditPart = null;
+ List<?> clonedList = new ArrayList<Object>(elementList);
+ List<IGraphicalEditPart> partSelection = new ArrayList<IGraphicalEditPart>();
- while(iter.hasNext() && researchedEditPart == null) {
+ while(iter.hasNext() && !clonedList.isEmpty()) {
Object currentEditPart = iter.next();
- //look for only among IPrimary editpart to avoid compartment and labels of links
+ //look only amidst IPrimary editpart to avoid compartment and labels of links
if(currentEditPart instanceof IPrimaryEditPart) {
- if(elementList.contains(semanticFromGMFElement.getSemanticElement(currentEditPart))) {
+ Object currentElement = semanticFromGMFElement.getSemanticElement(currentEditPart);
+ if(clonedList.contains(currentElement)) {
+ clonedList.remove(currentElement);
researchedEditPart = ((IGraphicalEditPart)currentEditPart);
- break;
+ partSelection.add(researchedEditPart);
+
}
}
}
//We may also search for a GMF View (Instead of a semantic model Element)
- if(researchedEditPart == null) {
- for(Object element : elementList) {
- if(graphicalViewer.getEditPartRegistry().containsKey(element)) {
+ if(!clonedList.isEmpty()) {
+ for(Object element : clonedList) {
+ if(graphicalViewer.getEditPartRegistry().containsKey(element) && !clonedList.isEmpty()) {
+ clonedList.remove(element);
researchedEditPart = (IGraphicalEditPart)graphicalViewer.getEditPartRegistry().get(element);
- break;
+ partSelection.add(researchedEditPart);
+
}
}
}
- //an editpart has been found so put selection on it.
- if(researchedEditPart != null) {
- graphicalViewer.select(researchedEditPart); //Set selection
- graphicalViewer.reveal(researchedEditPart); //If needed, scroll to make the edit part visible
+ // the second test, as the model element is not a PrimaryEditPart, is to allow the selection even if the user selected it with other elements
+ // and reset the selection if only the model is selected
+ if(clonedList.isEmpty() || (clonedList.size() == 1 && clonedList.get(0) == getDiagram().getElement())) {
+ //all parts have been found
+ IStructuredSelection sSelection = new StructuredSelection(partSelection);
+ // this is used instead of graphicalViewer.select(IGraphicalEditPart) as the later only allows the selection of a single element
+ graphicalViewer.setSelection(sSelection);
return true;
}
}
@@ -198,11 +210,11 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
return Collections.unmodifiableCollection(palettePages);
}
}
-
+
void setDeferredPalettePageReloadContext(Object reloadContext) {
palettePageState = reloadContext;
}
-
+
private void cleanUpPalettePages() {
for(Iterator<PalettePageWrapper> iter = palettePages.iterator(); iter.hasNext();) {
if(iter.next().isDisposed()) {
@@ -210,7 +222,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
}
}
}
-
+
/**
* Configures my diagram edit domain with its command stack.
* This method has been completely overridden in order to use a proxy stack.
@@ -299,29 +311,30 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
localStore.setValue(PreferencesConstantsHelper.SNAP_TO_GEOMETRY_CONSTANT, snapToGeometry);
localStore.setValue(PreferencesConstantsHelper.GRID_LINE_COLOR_CONSTANT, gridLineColor);
localStore.setValue(PreferencesConstantsHelper.GRID_SPACING_CONSTANT, gridSpacing);
-
+
//to force refresh
localStore.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, !gridOrder);
localStore.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, gridOrder);
-
+
localStore.setValue(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT, gridLineStyle);
}
-
+
/**
* Encapsulates the reconciling, that is diagram migration between version of Papyrus.
*/
protected static class ReconcileHelper {
+
private final TransactionalEditingDomain domain;
-
+
/**
* Instantiates helper that will work with given {@link TransactionalEditingDomain}.
- * Note that reconcile operations are performed outside the diagram command stack using {@link GMFUnsafe}.
+ * Note that reconcile operations are performed outside the diagram command stack using {@link GMFUnsafe}.
*/
public ReconcileHelper(TransactionalEditingDomain domain) {
this.domain = domain;
}
-
+
/**
* Process diagram reconcilers to migrate models. Does nothing if the diagram is already of the current Papyrus version based on
* {@link DiagramVersioningUtils#isOfCurrentPapyrusVersion(Diagram)} check.
@@ -337,7 +350,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
*/
public void reconcileDiagram(Diagram diagram) throws CoreException {
CompositeCommand migration = buildReconcileCommand(diagram);
- if (migration == null) {
+ if(migration == null) {
return;
}
migration.add(DiagramVersioningUtils.createStampCurrentVersionCommand(diagram));
@@ -410,14 +423,14 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
* This is to allow subclass to decide whether it is worth opening the problem diagram.
*/
protected void handleReconcileException(Diagram diagram, Exception e) throws CoreException {
- Activator.getInstance().logError("Reconciling the diagram: " + diagram, e);
+ Activator.getInstance().logError("Reconciling the diagram: " + diagram, e);
}
}
-
+
protected class PalettePageWrapper implements PalettePage, IAdaptable {
private final CustomPalettePage delegate;
-
+
private boolean disposed;
protected PalettePageWrapper(CustomPalettePage delegate) {
@@ -430,7 +443,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
// Attempting to creating the page controls again? Bail
return;
}
-
+
delegate.createControl(parent);
delegate.getControl().addDisposeListener(new DisposeListener() {
@@ -438,7 +451,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
@Override
public void widgetDisposed(DisposeEvent e) {
disposed = true;
-
+
SynchronizableGmfDiagramEditor.this.palettePages.remove(PalettePageWrapper.this);
}
});
@@ -457,11 +470,11 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
saveState();
delegate.dispose();
}
-
+
public boolean isDisposed() {
return disposed;
}
-
+
void saveState() {
PaletteViewer palette = getPaletteViewer();
if(palette != null) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
index f3d56f2..3f95940 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
@@ -20,6 +20,7 @@ package org.eclipse.papyrus.infra.nattable.common.editor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -43,6 +44,7 @@ import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationPackage;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
@@ -57,7 +59,7 @@ import org.eclipse.ui.part.EditorPart;
*
*
*/
-public abstract class AbstractEMFNattableEditor extends EditorPart {
+public abstract class AbstractEMFNattableEditor extends EditorPart implements NavigationTarget {
/** the service registry */
protected ServicesRegistry servicesRegistry;
@@ -319,7 +321,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
papyrusTable.eAdapters().add(this.tableNameListener);
}
}
-
+
private static class EMFNattableModelManager extends NattableModelManager {
EMFNattableModelManager(Table rawModel) {
@@ -329,6 +331,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
@Override
protected NatTableDropListener createDropListener() {
return new NatTableDropListener(this) {
+
@Override
protected Collection<?> extractSelectedObjects(IStructuredSelection structuredSelection) {
List<EObject> result = new ArrayList<EObject>(structuredSelection.size());
@@ -345,4 +348,27 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
};
}
}
+
+ /**
+ *
+ * used to link the selection between the model explorer and the table
+ *
+ * @param element
+ */
+ public boolean revealElement(Object element) {
+ return revealElement(Collections.singleton(element));
+ }
+
+ /**
+ *
+ * used to link the selection between the model explorer and the table
+ *
+ * @param elements
+ */
+ public boolean revealElement(Collection<?> elements) {
+ if(tableManager instanceof NavigationTarget) {
+ return ((NavigationTarget)tableManager).revealElement(elements);
+ }
+ return false;
+ }
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index 8dc465a..44c8019 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -15,6 +15,9 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
@@ -50,7 +53,10 @@ import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand;
import org.eclipse.nebula.widgets.nattable.print.config.DefaultPrintBindings;
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
import org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand;
+import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand;
+import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -76,10 +82,12 @@ import org.eclipse.papyrus.infra.nattable.provider.PapyrusNatTableToolTipProvide
import org.eclipse.papyrus.infra.nattable.provider.TableSelectionProvider;
import org.eclipse.papyrus.infra.nattable.sort.ColumnSortModel;
import org.eclipse.papyrus.infra.nattable.sort.IPapyrusSortModel;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.nattable.utils.LocationValue;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.nattable.utils.TableGridRegion;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.Transfer;
@@ -94,7 +102,7 @@ import org.eclipse.ui.IWorkbenchPartSite;
* This class allows to create, configure and manipulate the NatTable Widget
*
*/
-public abstract class AbstractNattableWidgetManager implements INattableModelManager {
+public abstract class AbstractNattableWidgetManager implements INattableModelManager, NavigationTarget {
/**
* the managed table
@@ -281,7 +289,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
final NatTableDropListener dropListener = createDropListener();
target.addDropListener(dropListener);
}
-
+
protected NatTableDropListener createDropListener() {
return new NatTableDropListener(this);
}
@@ -491,4 +499,66 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, null, DisplayMode.EDIT, ""); //$NON-NLS-1$
}
}
+
+ /**
+ *
+ * handles the selections from the model explorer to the table when the link is activated
+ *
+ * @see org.eclipse.papyrus.infra.nattable.utils.AxisUtils
+ * @see org.eclipse.nebula.widgets.nattable.selection.SelectionLayer
+ *
+ * @param elementList
+ */
+ @Override
+ public boolean revealElement(Object element) {
+
+ return revealElement(Collections.singleton(element));
+ }
+
+ @Override
+ public boolean revealElement(Collection<?> elements) {
+
+ boolean selectObject = false;
+ SelectionLayer selectionLayer = bodyLayerStack.getSelectionLayer();
+ List<Object> rowObjects = getRowElementsList();
+ List<Object> columnObjects = getColumnElementsList();
+
+ // clear the selectionLayer to avoid the previous selections to mess with the current
+ selectionLayer.clear();
+
+ for(int rowIndex = 0; rowIndex < rowObjects.size(); rowIndex++) {
+ List<?> toFind = new ArrayList<Object>(elements);
+ Object currentAxisObject = rowObjects.get(rowIndex);
+ Object currentRealObject = AxisUtils.getRepresentedElement(currentAxisObject);
+ if(toFind.contains(currentRealObject)) {
+ selectionLayer.doCommand(new SelectRowsCommand(selectionLayer, 0, rowIndex, false, true));
+ //we remove the found object from the cloned elementList as they are already selected
+ toFind.remove(currentRealObject);
+ selectObject = true;
+ }
+ if(toFind.isEmpty()) {
+ // all objects are selected
+ return selectObject;
+ }
+ }
+
+ for(int columnIndex = 0; columnIndex < columnObjects.size(); columnIndex++) {
+ List<?> toFind = new ArrayList<Object>(elements);
+ Object currentAxisObject = columnObjects.get(columnIndex);
+ Object currentRealObject = AxisUtils.getRepresentedElement(currentAxisObject);
+ if(toFind.contains(currentRealObject)) {
+ selectionLayer.doCommand(new SelectColumnCommand(selectionLayer, columnIndex, 0, false, true));
+ //we remove the found object from the cloned elementList as they are already selected
+ toFind.remove(currentRealObject);
+ selectObject = true;
+ }
+ if(toFind.isEmpty()) {
+ // all objects are selected
+ return selectObject;
+ }
+ }
+
+ return selectObject;
+ }
+
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/LinkHelper.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/LinkHelper.java
index b8575e3..5d08aa4 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/LinkHelper.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/LinkHelper.java
@@ -24,6 +24,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForWorkbenchPage;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionService;
@@ -76,15 +77,31 @@ public class LinkHelper implements ILinkHelper {
ArrayList<Object> semanticElementList = new ArrayList<Object>();
while(selectionIterator.hasNext()) {
Object currentSelection = selectionIterator.next();
- Object semanticElement = EMFHelper.getEObject(currentSelection);
- if(semanticElement != null) {
- semanticElementList.add(semanticElement);
- }
+ Object semanticElement = EMFHelper.getEObject(currentSelection);
+ if(semanticElement != null) {
+ semanticElementList.add(semanticElement);
+ }
}
((IRevealSemanticElement)diagramEditor).revealSemanticElement(semanticElementList);
}
}
+
+ if(diagramEditor instanceof NavigationTarget) {
+ if(aSelection instanceof IStructuredSelection) {
+ Iterator<?> selectionIterator = aSelection.iterator();
+ ArrayList<Object> semanticElementList = new ArrayList<Object>();
+ while(selectionIterator.hasNext()) {
+ Object currentSelection = selectionIterator.next();
+ Object semanticElement = EMFHelper.getEObject(currentSelection);
+ if(semanticElement != null) {
+ semanticElementList.add(semanticElement);
+ }
+ }
+
+ ((NavigationTarget)diagramEditor).revealElement(semanticElementList);
+ }
+ }
}
} catch (ServiceException ex) {
//We cannot access the service registry. The PapyrusEditor is probably closed.
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
index b7f7104..2fc9fd2 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
@@ -115,6 +115,8 @@ import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.CommonViewerSorter;
import org.eclipse.ui.navigator.IExtensionActivationListener;
+import org.eclipse.ui.navigator.ILinkHelper;
+import org.eclipse.ui.navigator.LinkHelperService;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
@@ -284,6 +286,20 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
}
}
+
+ // Selections from the Model Explorer result in a part from the ModelExplorerPageBookView instance which is not an IEditorPart
+ if(part instanceof ModelExplorerPageBookView && !selection.isEmpty()) {
+ if(selection instanceof IStructuredSelection) {
+ // Extracted from org.eclipse.ui.internal.navigator.actions.LinkEditorAction activateEditorJob
+ // the problem was that multi-element selections were disabled as only selections of 1 could clear the condition size()==1
+ IStructuredSelection sSelection = (IStructuredSelection)selection;
+ LinkHelperService linkService = getLinkHelperService();
+ ILinkHelper[] helpers = linkService.getLinkHelpersFor(sSelection.getFirstElement()); // LinkHelper in org.eclipse.papyrus.views.modelexplorer
+ if(helpers.length > 0) {
+ helpers[0].activateEditor(part.getSite().getPage(), sSelection);
+ }
+ }
+ }
}
}