summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2014-07-17 10:09:42 (EDT)
committerQuentin Le Menez2014-07-17 11:23:28 (EDT)
commit07140b1fa25fcf22c03968190fd854725b247efe (patch)
tree52ebdd74e464884d5a651f0b55fcea1aae1c35c3
parent12eb0b13deb344ffdb08cd376a119bea9fa92919 (diff)
downloadorg.eclipse.papyrus-07140b1fa25fcf22c03968190fd854725b247efe.zip
org.eclipse.papyrus-07140b1fa25fcf22c03968190fd854725b247efe.tar.gz
org.eclipse.papyrus-07140b1fa25fcf22c03968190fd854725b247efe.tar.bz2
439039: problem with model explorer / table synchronizationrefs/changes/55/30055/1
https://bugs.eclipse.org/bugs/show_bug.cgi?id=439039 added multi-selection for RevealSemantic fixed the bug with IAdaptable in EMFHelper Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java56
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java170
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java42
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java37
5 files changed, 209 insertions, 99 deletions
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
index c616470..1ed101a 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.infra.nattable.common.editor;
import java.io.IOException;
+import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.notify.Adapter;
@@ -27,10 +28,12 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.nattable.Activator;
import org.eclipse.papyrus.infra.nattable.common.utils.TableEditorInput;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
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.IRevealSemanticElement;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
@@ -45,7 +48,7 @@ import org.eclipse.ui.part.EditorPart;
*
*
*/
-public abstract class AbstractEMFNattableEditor extends EditorPart {
+public abstract class AbstractEMFNattableEditor extends EditorPart implements IRevealSemanticElement {
/** the service registry */
protected ServicesRegistry servicesRegistry;
@@ -74,9 +77,9 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
*/
public AbstractEMFNattableEditor(final ServicesRegistry servicesRegistry, final Table rawModel) {
this.servicesRegistry = servicesRegistry;
- this.tableManager = new NattableModelManager(rawModel);
- this.synchronizer = new PartNameSynchronizer(rawModel);
- this.workspacePreferenceStore = getWorkspaceViewerPreferenceStore();
+ tableManager = new NattableModelManager(rawModel);
+ synchronizer = new PartNameSynchronizer(rawModel);
+ workspacePreferenceStore = getWorkspaceViewerPreferenceStore();
}
/**
@@ -150,10 +153,10 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
*/
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
- final TableEditorInput tableEditorInput = new TableEditorInput(this.tableManager.getTable(), getEditingDomain());
+ final TableEditorInput tableEditorInput = new TableEditorInput(tableManager.getTable(), getEditingDomain());
setSite(site);
setInput(tableEditorInput);
- setPartName(this.tableManager.getTable().getName());
+ setPartName(tableManager.getTable().getName());
}
/**
@@ -164,7 +167,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
*/
public TransactionalEditingDomain getEditingDomain() {
try {
- return ServiceUtils.getInstance().getTransactionalEditingDomain(this.servicesRegistry);
+ return ServiceUtils.getInstance().getTransactionalEditingDomain(servicesRegistry);
} catch (final ServiceException e) {
Activator.log.error(e);
}
@@ -201,13 +204,13 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
@Override
public void createPartControl(final Composite parent) {
- this.tableManager.createNattable(parent, SWT.NONE, getSite());
+ tableManager.createNattable(parent, SWT.NONE, getSite());
}
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
if(adapter == INattableModelManager.class) {
- return this.tableManager;
+ return tableManager;
}
//Give direct access to the Table model element
@@ -215,7 +218,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
//Be careful when using directly the Table element.
if(adapter == Table.class) {
if(tableManager != null) {
- return this.tableManager.getTable();
+ return tableManager.getTable();
}
}
@@ -225,16 +228,17 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
@Override
public void dispose() {
saveLocalPreferenceStoreValues();
- this.tableManager.dispose();
- this.synchronizer.dispose();
+ tableManager.dispose();
+ synchronizer.dispose();
super.dispose();
}
protected void saveLocalPreferenceStoreValues() {
// Write the settings, if necessary
try {
- if(getWorkspaceViewerPreferenceStore() != null && getWorkspaceViewerPreferenceStore().needsSaving())
+ if(getWorkspaceViewerPreferenceStore() != null && getWorkspaceViewerPreferenceStore().needsSaving()) {
getWorkspaceViewerPreferenceStore().save();
+ }
} catch (IOException ioe) {
Activator.log.warn("Preferences can' be saved"); //$NON-NLS-1$
}
@@ -265,7 +269,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
@Override
public void notifyChanged(final Notification notification) {
if(notification.getFeature() == NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name()) {
- setPartName(PartNameSynchronizer.this.papyrusTable.getName());
+ setPartName(papyrusTable.getName());
}
}
};
@@ -281,8 +285,8 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
}
public void dispose() {
- this.papyrusTable.eAdapters().remove(this.tableNameListener);
- this.papyrusTable = null;
+ papyrusTable.eAdapters().remove(tableNameListener);
+ papyrusTable = null;
}
/**
@@ -293,14 +297,30 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
public void setTable(final Table papyrusTable) {
// Remove from old table, if any
if(this.papyrusTable != null) {
- papyrusTable.eAdapters().remove(this.tableNameListener);
+ papyrusTable.eAdapters().remove(tableNameListener);
}
// Set new table
this.papyrusTable = papyrusTable;
// Set editor name
setPartName(papyrusTable.getName());
// Listen to name change
- papyrusTable.eAdapters().add(this.tableNameListener);
+ papyrusTable.eAdapters().add(tableNameListener);
}
}
+
+ /**
+ *
+ * used to link the selection between the model explorer and the table
+ *
+ * @see org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement#revealSemanticElement(java.util.List)
+ *
+ * @param elementList
+ */
+ @Override
+ public void revealSemanticElement(List<?> elementList) {
+ if(tableManager instanceof IRevealSemanticElement) {
+ ((AbstractNattableWidgetManager)tableManager).revealSemanticElement(elementList);
+ }
+ }
+
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index b4bf438..50b1762 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
@@ -46,7 +47,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;
@@ -72,10 +76,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.IRevealSemanticElement;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.Transfer;
@@ -90,7 +96,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, IRevealSemanticElement {
/**
* the managed table
@@ -152,7 +158,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
public AbstractNattableWidgetManager(final Table table) {
this.table = table;
- this.tableContext = table.getContext();
+ tableContext = table.getContext();
}
/**
@@ -167,69 +173,69 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
@Override
public NatTable createNattable(final Composite parent, final int style, final IWorkbenchPartSite site) {
- this.bodyDataProvider = new BodyDataProvider(this);
- this.bodyLayerStack = new BodyLayerStack(this.bodyDataProvider, this);
+ bodyDataProvider = new BodyDataProvider(this);
+ bodyLayerStack = new BodyLayerStack(bodyDataProvider, this);
- this.columnHeaderDataProvider = new ColumnHeaderDataProvider(this);
- this.columnHeaderLayerStack = new ColumnHeaderLayerStack(this.columnHeaderDataProvider, this.bodyLayerStack, this.bodyDataProvider, getRowSortModel());
+ columnHeaderDataProvider = new ColumnHeaderDataProvider(this);
+ columnHeaderLayerStack = new ColumnHeaderLayerStack(columnHeaderDataProvider, bodyLayerStack, bodyDataProvider, getRowSortModel());
- this.rowHeaderDataProvider = new RowHeaderDataProvider(this);
+ rowHeaderDataProvider = new RowHeaderDataProvider(this);
- this.rowHeaderLayerStack = new RowHeaderLayerStack(this.rowHeaderDataProvider, this.bodyLayerStack);
+ rowHeaderLayerStack = new RowHeaderLayerStack(rowHeaderDataProvider, bodyLayerStack);
- final IDataProvider cornerDataProvider = new DefaultCornerDataProvider(this.columnHeaderDataProvider, this.rowHeaderDataProvider);
- final CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), this.rowHeaderLayerStack, this.columnHeaderLayerStack);
+ final IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
+ final CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), rowHeaderLayerStack, columnHeaderLayerStack);
cornerLayer.addConfiguration(new CornerConfiguration(this));
- this.gridLayer = new PapyrusGridLayer(this.bodyLayerStack, this.columnHeaderLayerStack, this.rowHeaderLayerStack, cornerLayer);
- this.gridLayer.addConfiguration(new DefaultPrintBindings());
+ gridLayer = new PapyrusGridLayer(bodyLayerStack, columnHeaderLayerStack, rowHeaderLayerStack, cornerLayer);
+ gridLayer.addConfiguration(new DefaultPrintBindings());
- this.natTable = new NatTable(parent, this.gridLayer, false);
+ natTable = new NatTable(parent, gridLayer, false);
- this.natTable.addConfiguration(new PapyrusHeaderMenuConfiguration());
+ natTable.addConfiguration(new PapyrusHeaderMenuConfiguration());
- this.natTable.addConfiguration(new CellEditionConfiguration());
- this.natTable.addConfiguration(new PapyrusClickSortConfiguration());
+ natTable.addConfiguration(new CellEditionConfiguration());
+ natTable.addConfiguration(new PapyrusClickSortConfiguration());
configureNatTable();
- addColumnReorderListener(this.bodyLayerStack.getColumnReorderLayer());
- addDragAndDropSupport(this.natTable);
+ addColumnReorderListener(bodyLayerStack.getColumnReorderLayer());
+ addDragAndDropSupport(natTable);
if(site != null) {
- final MenuManager menuMgr = createMenuManager(this.natTable);
- final Menu menu = menuMgr.createContextMenu(this.natTable);
- this.natTable.setMenu(menu);
+ final MenuManager menuMgr = createMenuManager(natTable);
+ final Menu menu = menuMgr.createContextMenu(natTable);
+ natTable.setMenu(menu);
- this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer());
- site.registerContextMenu(menuMgr, this.selectionProvider);
- site.setSelectionProvider(this.selectionProvider);
+ selectionProvider = new TableSelectionProvider(this, bodyLayerStack.getSelectionLayer());
+ site.registerContextMenu(menuMgr, selectionProvider);
+ site.setSelectionProvider(selectionProvider);
}
- new PapyrusNatTableToolTipProvider(this.natTable, GridRegion.BODY, GridRegion.COLUMN_HEADER, GridRegion.ROW_HEADER);
- return this.natTable;
+ new PapyrusNatTableToolTipProvider(natTable, GridRegion.BODY, GridRegion.COLUMN_HEADER, GridRegion.ROW_HEADER);
+ return natTable;
}
protected void configureNatTable() {
- if(this.natTable != null && !this.natTable.isDisposed()) {
+ if(natTable != null && !natTable.isDisposed()) {
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, AbstractNattableWidgetManager.this, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
configRegistry.registerConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, getLabelProviderService(), DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
//commented because seems generate several bugs with edition
//newRegistry.registerConfigAttribute( CellConfigAttributes.DISPLAY_CONVERTER, new GenericDisplayConverter(), DisplayMode.NORMAL, GridRegion.BODY);
- this.natTable.setConfigRegistry(configRegistry);
- this.natTable.setUiBindingRegistry(new UiBindingRegistry(this.natTable));
- this.natTable.configure();
+ natTable.setConfigRegistry(configRegistry);
+ natTable.setUiBindingRegistry(new UiBindingRegistry(natTable));
+ natTable.configure();
}
}
private LabelProviderService getLabelProviderService() {
try {
- ServicesRegistry serviceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(this.table.getContext());//get context and NOT get table for the usecase where the table is not in a resource
+ ServicesRegistry serviceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(table.getContext());//get context and NOT get table for the usecase where the table is not in a resource
return serviceRegistry.getService(LabelProviderService.class);
} catch (ServiceException e) {
Activator.log.error(e);
@@ -331,13 +337,13 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
@Override
public LocationValue getLocationInTheTable(final Point absolutePoint) {
- final Point widgetPoint = this.natTable.toControl(absolutePoint.x, absolutePoint.y);
+ final Point widgetPoint = natTable.toControl(absolutePoint.x, absolutePoint.y);
TableGridRegion kind = TableGridRegion.UNKNOWN;
- int columnPosition = this.natTable.getColumnPositionByX(widgetPoint.x);
- int columnIndex = this.natTable.getColumnIndexByPosition(columnPosition);
- int rowPosition = this.natTable.getRowPositionByY(widgetPoint.y);
- int rowIndex = this.natTable.getRowIndexByPosition(rowPosition);
- final ILayerCell cell = this.natTable.getCellByPosition(columnPosition, rowPosition);
+ int columnPosition = natTable.getColumnPositionByX(widgetPoint.x);
+ int columnIndex = natTable.getColumnIndexByPosition(columnPosition);
+ int rowPosition = natTable.getRowPositionByY(widgetPoint.y);
+ int rowIndex = natTable.getRowIndexByPosition(rowPosition);
+ final ILayerCell cell = natTable.getCellByPosition(columnPosition, rowPosition);
Object columnObject = null;
Object rowObject = null;
if(rowIndex == -1 && columnIndex == -1) {
@@ -369,7 +375,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
public GridLayer getGridLayer() {
- return this.gridLayer;
+ return gridLayer;
}
/**
@@ -379,9 +385,9 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
@Override
public void print() {
- this.natTable.doCommand(new TurnViewportOffCommand());
- this.natTable.doCommand(new PrintCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
- this.natTable.doCommand(new TurnViewportOnCommand());
+ natTable.doCommand(new TurnViewportOffCommand());
+ natTable.doCommand(new PrintCommand(natTable.getConfigRegistry(), natTable.getShell()));
+ natTable.doCommand(new TurnViewportOnCommand());
}
/**
@@ -391,7 +397,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
@Override
public void selectAll() {
- this.natTable.doCommand(new SelectAllCommand());
+ natTable.doCommand(new SelectAllCommand());
}
/**
@@ -401,11 +407,11 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
@Override
public void exportToXLS() {
- this.natTable.doCommand(new ExportCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
+ natTable.doCommand(new ExportCommand(natTable.getConfigRegistry(), natTable.getShell()));
}
public void copyToClipboard() {
- this.natTable.doCommand(new CopyDataToClipboardCommand("\t", "\n", this.natTable.getConfigRegistry()));
+ natTable.doCommand(new CopyDataToClipboardCommand("\t", "\n", natTable.getConfigRegistry()));
}
/**
@@ -416,30 +422,30 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*/
@Override
public BodyLayerStack getBodyLayerStack() {
- return this.bodyLayerStack;
+ return bodyLayerStack;
}
@Override
public void dispose() {
- if(this.bodyDataProvider != null) {
- this.bodyDataProvider.dispose();
+ if(bodyDataProvider != null) {
+ bodyDataProvider.dispose();
}
- if(this.rowHeaderDataProvider != null) {
- this.rowHeaderDataProvider.dispose();
+ if(rowHeaderDataProvider != null) {
+ rowHeaderDataProvider.dispose();
}
- if(this.columnHeaderDataProvider != null) {
- this.columnHeaderDataProvider.dispose();
+ if(columnHeaderDataProvider != null) {
+ columnHeaderDataProvider.dispose();
}
- this.tableContext = null;
+ tableContext = null;
}
public EObject getTableContext() {
- return this.tableContext;
+ return tableContext;
}
@Override
public Table getTable() {
- return this.table;
+ return table;
}
/**
@@ -448,10 +454,10 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
* the created sort model to use for
*/
protected IPapyrusSortModel getRowSortModel() {
- if(this.rowSortModel == null) {
- this.rowSortModel = new ColumnSortModel(this);
+ if(rowSortModel == null) {
+ rowSortModel = new ColumnSortModel(this);
}
- return this.rowSortModel;
+ return rowSortModel;
}
/**
@@ -482,4 +488,54 @@ 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.manager.table.INattableModelManager#revealSemanticElement(java.util.List)
+ * @see org.eclipse.papyrus.infra.nattable.utils.AxisUtils
+ * @see org.eclipse.nebula.widgets.nattable.selection.SelectionLayer
+ *
+ * @param elementList
+ */
+ @Override
+ public void revealSemanticElement(List<?> elementList) {
+ 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>(elementList);
+ 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);
+ }
+ if(toFind.isEmpty()) {
+ // all objects are selected
+ return;
+ }
+ }
+
+ for(int columnIndex = 0; columnIndex < columnObjects.size(); columnIndex++) {
+ List<?> toFind = new ArrayList<Object>(elementList);
+ 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);
+ }
+ if(toFind.isEmpty()) {
+ // all objects are selected
+ return;
+ }
+ }
+ }
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
index 7bb978e..b9d4225 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
@@ -34,8 +34,10 @@ import org.eclipse.ui.services.IDisposable;
public interface INattableModelManager extends ITableAxisElementProvider, IDisposable, IDataProvider {
+ @Override
public int getColumnCount();
+ @Override
public int getRowCount();
public void addRows(final Collection<Object> objectsToAdd);
@@ -193,4 +195,5 @@ public interface INattableModelManager extends ITableAxisElementProvider, IDispo
* the table preference store
*/
public void setWorkspacePreferenceStore(final PreferenceStore store);
+
}
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 b2933dd..faee3d5 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
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -32,6 +33,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.gmfdiag.common.preferences.PreferencesConstantsHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.CommandIds;
@@ -59,6 +62,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
* @see org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement#revealSemanticElement(java.util.List)
*
*/
+ @Override
public void revealSemanticElement(List<?> elementList) {
revealElement(elementList);
}
@@ -66,6 +70,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
/**
* {@inheritDoc}
*/
+ @Override
public boolean revealElement(Object element) {
return revealElement(Collections.singleton(element));
}
@@ -79,6 +84,7 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
* @see org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement#revealSemanticElement(java.util.List)
*
*/
+ @Override
public boolean revealElement(Collection<?> elementList) {
//create an instance that can get semantic element from gmf
SemanticFromGMFElement semanticFromGMFElement = new SemanticFromGMFElement();
@@ -87,35 +93,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) instanceof org.eclipse.uml2.uml.internal.impl.ModelImpl)) {
+ //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;
}
}
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 967d415..b66dc57 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
@@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.emf.providers.SemanticFromModelExplorer;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
@@ -99,6 +100,8 @@ import org.eclipse.ui.internal.navigator.NavigatorContentService;
import org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor;
import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.CommonViewer;
+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;
@@ -228,6 +231,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
*/
private void handleSelectionChangedFromDiagramEditor(IWorkbenchPart part, ISelection selection) {
// Handle selection from diagram editor
+
if(isLinkingEnabled()) {
if(part instanceof IEditorPart) {
if(selection instanceof IStructuredSelection) {
@@ -235,18 +239,29 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
ArrayList<Object> semanticElementList = new ArrayList<Object>();
while(selectionIterator.hasNext()) {
Object currentSelection = selectionIterator.next();
- if(currentSelection instanceof IAdaptable) {
- Object semanticElement = ((IAdaptable)currentSelection).getAdapter(EObject.class);
- if(semanticElement != null) {
- semanticElementList.add(semanticElement);
- }
+ // getEObject already check if it is IAdaptable
+ EObject result = EMFHelper.getEObject(currentSelection);
+ if(result != null) {
+ semanticElementList.add(result);
}
-
}
- revealSemanticElement(semanticElementList);
+ revealSemanticElement(semanticElementList);
}
+ }
+ // 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);
+ }
+ }
}
}
}
@@ -708,7 +723,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
try {
- this.editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
+ editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
// Set Viewer input if it already exist
if(getCommonViewer() != null) {
@@ -722,7 +737,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
// Listen to isDirty flag
saveAndDirtyService.addInputChangedListener(editorInputChangedListener);
- if(this.getCommonViewer() != null) {
+ if(getCommonViewer() != null) {
refresh();
}
}
@@ -777,7 +792,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
editingDomain = null;
lastTrans = null;
- for(IPropertySheetPage propertySheetPage : this.propertySheetPages) {
+ for(IPropertySheetPage propertySheetPage : propertySheetPages) {
propertySheetPage.dispose();
}
@@ -814,7 +829,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
if(multiDiagramEditor instanceof ITabbedPropertySheetPageContributor) {
ITabbedPropertySheetPageContributor contributor = (ITabbedPropertySheetPageContributor)multiDiagramEditor;
IPropertySheetPage propertySheetPage = new TabbedPropertySheetPage(contributor);
- this.propertySheetPages.add(propertySheetPage);
+ propertySheetPages.add(propertySheetPage);
return propertySheetPage;
}
}