Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Fauth2016-02-19 19:31:04 +0000
committerGerrit Code Review @ Eclipse.org2016-02-26 08:48:58 +0000
commit7980958a0870802b3f419dc2ab59dbac2edd25c5 (patch)
treea96a775c81bc03718874437a90092c22509e3c14
parent2825d2d5875f0b13f631f471dbc657581ba04052 (diff)
downloadorg.eclipse.papyrus-7980958a0870802b3f419dc2ab59dbac2edd25c5.tar.gz
org.eclipse.papyrus-7980958a0870802b3f419dc2ab59dbac2edd25c5.tar.xz
org.eclipse.papyrus-7980958a0870802b3f419dc2ab59dbac2edd25c5.zip
Bug 488234: [Table] Table must provide a scrollbar for the tree header part in TreeTable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=488234 Change-Id: Iced4e6a8a043509328eea8c63b593720f274c6f9 Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com> Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java812
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeDragMode.java70
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeMatcher.java42
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderHierarchicalLayerStack.java293
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java19
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java162
6 files changed, 845 insertions, 553 deletions
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 4a4d7c56aad..0217ee34ffc 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
@@ -1,395 +1,417 @@
-/*****************************************************************************
- * Copyright (c) 2009, 2014 CEA LIST, LIFL, and others.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
- * Christian W. Damus (CEA) - bug 430880
- * Christian W. Damus (CEA) - bug 437217
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.common.editor;
-
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.nebula.widgets.nattable.NatTable;
-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.nattable.selection.EObjectSelectionExtractor;
-import org.eclipse.papyrus.infra.nattable.common.Activator;
-import org.eclipse.papyrus.infra.nattable.common.utils.TableEditorInput;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationPackage;
-import org.eclipse.papyrus.infra.nattable.utils.NattableModelManagerFactory;
-import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
-import org.eclipse.papyrus.infra.ui.editor.reload.IReloadContextProvider;
-import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.EditorPart;
-
-
-/**
- * Abstract class for TableEditor
- *
- *
- *
- */
-public abstract class AbstractEMFNattableEditor extends EditorPart implements NavigationTarget {
-
- /** the service registry */
- protected ServicesRegistry servicesRegistry;
-
- /**
- * the table manager
- */
- protected INattableModelManager tableManager;
-
- /**
- * the part name synchronizer
- */
- private PartNameSynchronizer synchronizer;
-
- /**
- * the workspace preference store for this table editor
- */
- @SuppressWarnings("unused")
- // not yet used in the table
- private PreferenceStore workspacePreferenceStore;
-
- /**
- * @param servicesRegistry
- * @param rawModel
- *
- */
- public AbstractEMFNattableEditor(final ServicesRegistry servicesRegistry, final Table rawModel) {
- this.servicesRegistry = servicesRegistry;
- this.tableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(rawModel, new EObjectSelectionExtractor());
- this.synchronizer = new PartNameSynchronizer(rawModel);
- this.workspacePreferenceStore = getWorkspaceViewerPreferenceStore();
- }
-
- /**
- * Returns the workspace viewer <code>PreferenceStore</code>
- *
- * @return the workspace viewer <code>PreferenceStore</code>
- */
- public PreferenceStore getWorkspaceViewerPreferenceStore() {
- // not yet used by tables
- return null;
-
- // if(this.workspacePreferenceStore != null) {
- // return this.workspacePreferenceStore;
- // } else {
- // // Try to load it
- // IPath path = Activator.getDefault().getStateLocation();
- // String id = getIdStr(this.tableManager.getTable());
- //
- // String fileName = path.toString() + "/" + id;//$NON-NLS-1$
- // java.io.File file = new File(fileName);
- // this.workspacePreferenceStore = new PreferenceStore(fileName);
- // if(file.exists()) {
- // // Load it
- // try {
- // this.workspacePreferenceStore.load();
- // } catch (Exception e) {
- // // Create the default
- // addDefaultPreferences();
- // }
- // } else {
- // // Create it
- // addDefaultPreferences();
- // }
- // return this.workspacePreferenceStore;
- // }
- }
-
- // /**
- // * returns the unique GUID of the view
- // *
- // * @param view
- // * the view
- // * @return String the GUID of a view (constant)
- // */
- // private static String getIdStr(Table table) {
- // Resource resource = table.eResource();
- // if(resource instanceof XMLResource) {
- // String id = ((XMLResource)resource).getID(table);
- // if(id != null) {
- // return id;
- // }
- // }
- //
- // // Remain compatible with previous behavior.
- // return StringStatics.BLANK;
- // }
-
- // not used : add a workspace preference to the table
- // private void addDefaultPreferences() {
- // final IPreferenceStore globalPreferenceStore = Activator.getDefault().getPreferenceStore();
- // String tableKind = this.tableManager.getTable().getTableConfiguration().getType();
- // }
-
- /**
- *
- * @see org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
- *
- * @param site
- * @param input
- * @throws PartInitException
- */
- @Override
- public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
- final TableEditorInput tableEditorInput = new TableEditorInput(this.tableManager.getTable(), getEditingDomain());
- setSite(site);
- setInput(tableEditorInput);
- setPartName(this.tableManager.getTable().getName());
- }
-
- /**
- *
- * @see org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor#getEditingDomain()
- *
- * @return
- */
- public TransactionalEditingDomain getEditingDomain() {
- try {
- return ServiceUtils.getInstance().getTransactionalEditingDomain(this.servicesRegistry);
- } catch (final ServiceException e) {
- Activator.log.error(e);
- }
- return null;
- }
-
- @Override
- public void doSave(final IProgressMonitor monitor) {
- // nothing to do
- }
-
- @Override
- public void doSaveAs() {
- // nothing to do
-
- }
-
- @Override
- public boolean isDirty() {
- // nothing to do
- return false;
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- // nothing to do
- return false;
- }
-
- @Override
- public void setFocus() {
- // nothing to do
- }
-
- @Override
- public void createPartControl(final Composite parent) {
- this.tableManager.createNattable(parent, SWT.NONE, getSite());
- }
-
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
- if (adapter == INattableModelManager.class) {
- return this.tableManager;
- }
-
- // Give direct access to the Table model element
- // Most actions should be done through the TableManager.
- // Be careful when using directly the Table element.
- if (adapter == Table.class) {
- if (tableManager != null) {
- return this.tableManager.getTable();
- }
- }
-
- if (adapter == IReloadContextProvider.class) {
- return new NattableReloadContextProvider(this);
- }
-
- return super.getAdapter(adapter);
- }
-
- /**
- * this method is used dispose the existing nattable widget and recreate a new one.
- * It has been created to be able to reload a table when a bug broke the table after a user action.
- *
- * see bug 466447: [TreeTable] Missing method to reload a (hierarchic) table
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=466447
- */
- public void reloadNattableModelManager() {
- Table rawModel = this.tableManager.getTable();
- // we dispose the previous nattable widget
- NatTable nattable = this.tableManager.getAdapter(NatTable.class);
- Composite parent = nattable.getParent();
- this.tableManager.dispose();
- this.tableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(rawModel, new EObjectSelectionExtractor());
- nattable = this.tableManager.createNattable(parent, SWT.NONE, getSite());
- nattable.getParent().layout();
- }
-
- @Override
- public void dispose() {
- saveLocalPreferenceStoreValues();
- this.tableManager.dispose();
- this.synchronizer.dispose();
- this.tableManager= null;
- this.servicesRegistry = null;
- this.synchronizer = null;
- super.dispose();
- }
-
- protected void saveLocalPreferenceStoreValues() {
- // Write the settings, if necessary
- try {
- if (getWorkspaceViewerPreferenceStore() != null && getWorkspaceViewerPreferenceStore().needsSaving()) {
- getWorkspaceViewerPreferenceStore().save();
- }
- } catch (IOException ioe) {
- Activator.log.warn("Preferences can' be saved"); //$NON-NLS-1$
- }
- }
-
- /**
- * A class taking in charge the synchronization of the partName and the table name.
- * When table name change, the other is automatically updated.
- *
- *
- */
- public class PartNameSynchronizer {
-
- /** the papyrus table */
- private Table papyrusTable;
-
- /**
- * Listener on diagram name change.
- */
- private final Adapter tableNameListener = new AdapterImpl() {
-
- /**
- *
- * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
- *
- * @param notification
- */
- @Override
- public void notifyChanged(final Notification notification) {
- if (notification.getFeature() == NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name()) {
- setPartName(PartNameSynchronizer.this.papyrusTable.getName());
- }
- }
- };
-
- /**
- *
- * Constructor.
- *
- * @param diagram
- */
- public PartNameSynchronizer(final Table papyrusTable) {
- setTable(papyrusTable);
- }
-
- public void dispose() {
- this.papyrusTable.eAdapters().remove(this.tableNameListener);
- this.papyrusTable = null;
- }
-
- /**
- * Change the associated diagram.
- *
- * @param papyrusTable
- */
- public void setTable(final Table papyrusTable) {
- // Remove from old table, if any
- if (this.papyrusTable != null) {
- papyrusTable.eAdapters().remove(this.tableNameListener);
- }
- // Set new table
- this.papyrusTable = papyrusTable;
- // Set editor name
- setPartName(papyrusTable.getName());
- // Listen to name change
- papyrusTable.eAdapters().add(this.tableNameListener);
- }
- }
-
-
- /**
- *
- * used to link the selection between the model explorer and the table
- *
- * @param element
- */
- @Override
- public boolean revealElement(Object element) {
- return revealElement(Collections.singleton(element));
- }
-
- /**
- *
- * used to link the selection between the model explorer and the table
- *
- * @param elements
- */
- @Override
- public boolean revealElement(Collection<?> elements) {
- if (tableManager instanceof NavigationTarget) {
- return ((NavigationTarget) tableManager).revealElement(elements);
- }
- return false;
- }
-
- /**
- *
- * @return
- * the table model displayed by the editor
- */
- public Table getTable() {
- return tableManager.getTable();
- }
-
- /**
- *
- * @return
- * the table editing domain
- */
- public TransactionalEditingDomain getTableEditingDomain() {
- return TableEditingDomainUtils.getTableEditingDomain(getTable());
- }
-
- /**
- *
- * @return
- * the table context editing domain
- */
- public TransactionalEditingDomain getTableContextEditingDomain() {
- return TableEditingDomainUtils.getTableContextEditingDomain(getTable());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009, 2014 CEA LIST, LIFL, and others.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
+ * Christian W. Damus (CEA) - bug 430880
+ * Christian W. Damus (CEA) - bug 437217
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.common.editor;
+
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+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.nattable.selection.EObjectSelectionExtractor;
+import org.eclipse.papyrus.infra.nattable.common.Activator;
+import org.eclipse.papyrus.infra.nattable.common.utils.TableEditorInput;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.utils.NattableModelManagerFactory;
+import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
+import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
+import org.eclipse.papyrus.infra.ui.editor.reload.IReloadContextProvider;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+
+
+/**
+ * Abstract class for TableEditor
+ *
+ *
+ *
+ */
+public abstract class AbstractEMFNattableEditor extends EditorPart implements NavigationTarget {
+
+ /** the service registry */
+ protected ServicesRegistry servicesRegistry;
+
+ /**
+ * the table manager
+ */
+ protected INattableModelManager tableManager;
+
+ /**
+ * the part name synchronizer
+ */
+ private PartNameSynchronizer synchronizer;
+
+ /**
+ * the workspace preference store for this table editor
+ */
+ @SuppressWarnings("unused")
+ // not yet used in the table
+ private PreferenceStore workspacePreferenceStore;
+
+ /**
+ * @param servicesRegistry
+ * @param rawModel
+ *
+ */
+ public AbstractEMFNattableEditor(final ServicesRegistry servicesRegistry, final Table rawModel) {
+ this.servicesRegistry = servicesRegistry;
+ this.tableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(rawModel, new EObjectSelectionExtractor());
+ this.synchronizer = new PartNameSynchronizer(rawModel);
+ this.workspacePreferenceStore = getWorkspaceViewerPreferenceStore();
+ }
+
+ /**
+ * Returns the workspace viewer <code>PreferenceStore</code>
+ *
+ * @return the workspace viewer <code>PreferenceStore</code>
+ */
+ public PreferenceStore getWorkspaceViewerPreferenceStore() {
+ // not yet used by tables
+ return null;
+
+ // if(this.workspacePreferenceStore != null) {
+ // return this.workspacePreferenceStore;
+ // } else {
+ // // Try to load it
+ // IPath path = Activator.getDefault().getStateLocation();
+ // String id = getIdStr(this.tableManager.getTable());
+ //
+ // String fileName = path.toString() + "/" + id;//$NON-NLS-1$
+ // java.io.File file = new File(fileName);
+ // this.workspacePreferenceStore = new PreferenceStore(fileName);
+ // if(file.exists()) {
+ // // Load it
+ // try {
+ // this.workspacePreferenceStore.load();
+ // } catch (Exception e) {
+ // // Create the default
+ // addDefaultPreferences();
+ // }
+ // } else {
+ // // Create it
+ // addDefaultPreferences();
+ // }
+ // return this.workspacePreferenceStore;
+ // }
+ }
+
+ // /**
+ // * returns the unique GUID of the view
+ // *
+ // * @param view
+ // * the view
+ // * @return String the GUID of a view (constant)
+ // */
+ // private static String getIdStr(Table table) {
+ // Resource resource = table.eResource();
+ // if(resource instanceof XMLResource) {
+ // String id = ((XMLResource)resource).getID(table);
+ // if(id != null) {
+ // return id;
+ // }
+ // }
+ //
+ // // Remain compatible with previous behavior.
+ // return StringStatics.BLANK;
+ // }
+
+ // not used : add a workspace preference to the table
+ // private void addDefaultPreferences() {
+ // final IPreferenceStore globalPreferenceStore = Activator.getDefault().getPreferenceStore();
+ // String tableKind = this.tableManager.getTable().getTableConfiguration().getType();
+ // }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ *
+ * @param site
+ * @param input
+ * @throws PartInitException
+ */
+ @Override
+ public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
+ final TableEditorInput tableEditorInput = new TableEditorInput(this.tableManager.getTable(), getEditingDomain());
+ setSite(site);
+ setInput(tableEditorInput);
+ setPartName(this.tableManager.getTable().getName());
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor#getEditingDomain()
+ *
+ * @return
+ */
+ public TransactionalEditingDomain getEditingDomain() {
+ try {
+ return ServiceUtils.getInstance().getTransactionalEditingDomain(this.servicesRegistry);
+ } catch (final ServiceException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ @Override
+ public void doSave(final IProgressMonitor monitor) {
+ // nothing to do
+ }
+
+ @Override
+ public void doSaveAs() {
+ // nothing to do
+
+ }
+
+ @Override
+ public boolean isDirty() {
+ // nothing to do
+ return false;
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ // nothing to do
+ return false;
+ }
+
+ @Override
+ public void setFocus() {
+ // nothing to do
+ }
+
+ @Override
+ public void createPartControl(final Composite parent) {
+ this.tableManager.createNattable(parent, SWT.NONE, getSite());
+ }
+
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
+ if (adapter == INattableModelManager.class) {
+ return this.tableManager;
+ }
+
+ // Give direct access to the Table model element
+ // Most actions should be done through the TableManager.
+ // Be careful when using directly the Table element.
+ if (adapter == Table.class) {
+ if (tableManager != null) {
+ return this.tableManager.getTable();
+ }
+ }
+
+ if (adapter == IReloadContextProvider.class) {
+ return new NattableReloadContextProvider(this);
+ }
+
+ return super.getAdapter(adapter);
+ }
+
+ /**
+ * this method is used dispose the existing nattable widget and recreate a new one.
+ * It has been created to be able to reload a table when a bug broke the table after a user action.
+ *
+ * see bug 466447: [TreeTable] Missing method to reload a (hierarchic) table
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=466447
+ */
+ public void reloadNattableModelManager() {
+ if (TableHelper.isTreeTable(tableManager)) {
+ reloadTreeNattableModelManager();
+ } else {
+ Table rawModel = this.tableManager.getTable();
+ // we dispose the previous nattable widget
+ NatTable nattable = this.tableManager.getAdapter(NatTable.class);
+ Composite parent = nattable.getParent();
+ this.tableManager.dispose();
+ this.tableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(rawModel, new EObjectSelectionExtractor());
+ nattable = this.tableManager.createNattable(parent, SWT.NONE, getSite());
+ nattable.getParent().layout();
+ }
+ }
+
+ /**
+ * the reload method for Treetable (due to bug Bug 488234)
+ */
+ protected void reloadTreeNattableModelManager() {
+ Table rawModel = this.tableManager.getTable();
+ // we dispose the previous nattable widget
+ NatTable nattable = this.tableManager.getAdapter(NatTable.class);
+ Composite sliderComposite = nattable.getParent();
+ Composite greatParent = sliderComposite.getParent();
+ this.tableManager.dispose();
+ sliderComposite.dispose();
+
+ this.tableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(rawModel, new EObjectSelectionExtractor());
+ nattable = this.tableManager.createNattable(greatParent, SWT.NONE, getSite());
+ greatParent.layout();
+ }
+
+ @Override
+ public void dispose() {
+ saveLocalPreferenceStoreValues();
+ this.tableManager.dispose();
+ this.synchronizer.dispose();
+ this.tableManager= null;
+ this.servicesRegistry = null;
+ this.synchronizer = null;
+ super.dispose();
+ }
+
+ protected void saveLocalPreferenceStoreValues() {
+ // Write the settings, if necessary
+ try {
+ if (getWorkspaceViewerPreferenceStore() != null && getWorkspaceViewerPreferenceStore().needsSaving()) {
+ getWorkspaceViewerPreferenceStore().save();
+ }
+ } catch (IOException ioe) {
+ Activator.log.warn("Preferences can' be saved"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * A class taking in charge the synchronization of the partName and the table name.
+ * When table name change, the other is automatically updated.
+ *
+ *
+ */
+ public class PartNameSynchronizer {
+
+ /** the papyrus table */
+ private Table papyrusTable;
+
+ /**
+ * Listener on diagram name change.
+ */
+ private final Adapter tableNameListener = new AdapterImpl() {
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ *
+ * @param notification
+ */
+ @Override
+ public void notifyChanged(final Notification notification) {
+ if (notification.getFeature() == NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name()) {
+ setPartName(PartNameSynchronizer.this.papyrusTable.getName());
+ }
+ }
+ };
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ */
+ public PartNameSynchronizer(final Table papyrusTable) {
+ setTable(papyrusTable);
+ }
+
+ public void dispose() {
+ this.papyrusTable.eAdapters().remove(this.tableNameListener);
+ this.papyrusTable = null;
+ }
+
+ /**
+ * Change the associated diagram.
+ *
+ * @param papyrusTable
+ */
+ public void setTable(final Table papyrusTable) {
+ // Remove from old table, if any
+ if (this.papyrusTable != null) {
+ papyrusTable.eAdapters().remove(this.tableNameListener);
+ }
+ // Set new table
+ this.papyrusTable = papyrusTable;
+ // Set editor name
+ setPartName(papyrusTable.getName());
+ // Listen to name change
+ papyrusTable.eAdapters().add(this.tableNameListener);
+ }
+ }
+
+
+ /**
+ *
+ * used to link the selection between the model explorer and the table
+ *
+ * @param element
+ */
+ @Override
+ public boolean revealElement(Object element) {
+ return revealElement(Collections.singleton(element));
+ }
+
+ /**
+ *
+ * used to link the selection between the model explorer and the table
+ *
+ * @param elements
+ */
+ @Override
+ public boolean revealElement(Collection<?> elements) {
+ if (tableManager instanceof NavigationTarget) {
+ return ((NavigationTarget) tableManager).revealElement(elements);
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return
+ * the table model displayed by the editor
+ */
+ public Table getTable() {
+ return tableManager.getTable();
+ }
+
+ /**
+ *
+ * @return
+ * the table editing domain
+ */
+ public TransactionalEditingDomain getTableEditingDomain() {
+ return TableEditingDomainUtils.getTableEditingDomain(getTable());
+ }
+
+ /**
+ *
+ * @return
+ * the table context editing domain
+ */
+ public TransactionalEditingDomain getTableContextEditingDomain() {
+ return TableEditingDomainUtils.getTableContextEditingDomain(getTable());
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeDragMode.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeDragMode.java
new file mode 100644
index 00000000000..1aaf7ae0161
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeDragMode.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.clientarea;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.ui.action.IDragMode;
+import org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter;
+import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
+import org.eclipse.nebula.widgets.nattable.viewport.command.RecalculateScrollBarsCommand;
+import org.eclipse.swt.events.MouseEvent;
+
+/**
+ *
+ */
+public class ClientAreaResizeDragMode implements IDragMode {
+
+ protected ILayer rowHeaderIndexLayer;
+ protected ILayer baseLayer;
+ protected ClientAreaAdapter clientAreaAdapter;
+ protected ViewportLayer[] viewportLayer;
+
+ public ClientAreaResizeDragMode(ILayer rowHeaderIndexLayer, ILayer baseLayer,
+ ClientAreaAdapter clientAreaAdapter, ViewportLayer... viewportLayer) {
+ this.rowHeaderIndexLayer = rowHeaderIndexLayer;
+ this.baseLayer = baseLayer;
+ this.clientAreaAdapter = clientAreaAdapter;
+ this.viewportLayer = viewportLayer;
+ }
+
+ @Override
+ public void mouseDown(NatTable natTable, MouseEvent event) {}
+
+ @Override
+ public void mouseMove(NatTable natTable, MouseEvent event) {
+ }
+
+ @Override
+ public void mouseUp(NatTable natTable, MouseEvent event) {
+ int baseWidth = this.baseLayer.getWidth();
+ int newWidth = event.x - this.rowHeaderIndexLayer.getWidth();
+ if (newWidth < 0) {
+ newWidth = 1;
+ } else if (newWidth > baseWidth) {
+ newWidth = baseWidth;
+ }
+ this.clientAreaAdapter.setWidth(newWidth);
+
+ for (ViewportLayer vp : this.viewportLayer) {
+ vp.invalidateHorizontalStructure();
+
+ vp.doCommand(new RecalculateScrollBarsCommand());
+ }
+
+ natTable.redraw();
+ natTable.getParent().layout(true, true);
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeMatcher.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeMatcher.java
new file mode 100644
index 00000000000..995075f6dc8
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/clientarea/ClientAreaResizeMatcher.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.clientarea;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.swt.events.MouseEvent;
+
+/**
+ *
+ */
+public class ClientAreaResizeMatcher extends MouseEventMatcher {
+
+ protected ILayer rowHeaderLayer;
+
+ public ClientAreaResizeMatcher(ILayer rowHeaderLayer) {
+ this.rowHeaderLayer = rowHeaderLayer;
+ }
+
+ @Override
+ public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
+ if (regionLabels != null && regionLabels.hasLabel(GridRegion.COLUMN_HEADER) && (event.x >= this.rowHeaderLayer.getWidth() && event.x <= this.rowHeaderLayer.getWidth() + 4)) {
+ // it is +4 because it should react on a 4 pixed wide range to the right and not only on the exact pixel position. The row resize has +5 to both directions
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderHierarchicalLayerStack.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderHierarchicalLayerStack.java
index f3a3ba61a00..226da0bdcb3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderHierarchicalLayerStack.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderHierarchicalLayerStack.java
@@ -1,141 +1,152 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.layerstack;
-
-import java.util.List;
-
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
-import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
-import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
-import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
-import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
-import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
-import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
-import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
-import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
-import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
-import org.eclipse.papyrus.infra.nattable.dataprovider.HierarchicalRowLabelHeaderDataProvider;
-import org.eclipse.papyrus.infra.nattable.layer.PapyrusTreeLayer;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.ITreeNattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
-import org.eclipse.papyrus.infra.nattable.painter.PapyrusIndentedTreeImagePainter;
-
-import ca.odell.glazedlists.TreeList;
-
-/**
- *
- * @author VL222926
- * Layer stack used for row header
- */
-public class RowHeaderHierarchicalLayerStack extends RowHeaderLayerStack {
-
-
- private Object rowSortModel;// TODO
-
- private ColumnHideShowLayer columnHideShowLayer;
-
- private TreeLayer treeLayer;
-
- /**
- *
- * Constructor.
- *
- * @param indexDataProvider
- * the index data provider
- * @param labelDataProvider
- * the label data provider
- * @param bodyLayer
- * the body layer
- */
- public RowHeaderHierarchicalLayerStack(final BodyLayerStack bodyLayer, final INattableModelManager tableManager) { // 1. create the index row layer
- super(bodyLayer, tableManager);
- }
-
- /**
- * @see org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack#createLabelDataProvider()
- *
- * @return
- */
- @Override
- protected IDataProvider createLabelDataProvider() {
- return new HierarchicalRowLabelHeaderDataProvider(this.tableManager);
- }
-
-
- /**
- * @see org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack#createLabelRowHeaderLayer(org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack, org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager)
- *
- * @param bodyLayerStack
- * @param tableManager
- * @return
- */
- @Override
- protected AbstractLayer createLabelRowHeaderLayer(BodyLayerStack bodyLayerStack, INattableModelManager tableManager) {
- List<?> managedAxis = ((ITreeNattableModelManager) tableManager).getTreeList();
- if (managedAxis instanceof TreeList<?>) {
- @SuppressWarnings("unchecked")
- GlazedListTreeData<ITreeItemAxis> glazedListTreeData = new GlazedListTreeData<ITreeItemAxis>((TreeList<ITreeItemAxis>) managedAxis);
- this.columnHideShowLayer = new ColumnHideShowLayer(getLabelDataLayer());
- this.treeLayer = new PapyrusTreeLayer(this.columnHideShowLayer, new GlazedListTreeRowModel<ITreeItemAxis>(glazedListTreeData), new PapyrusIndentedTreeImagePainter(), true);
-
-
- SelectionLayer selectionLayer = bodyLayerStack.getSelectionLayer();
- return new RowHeaderLayer(treeLayer, bodyLayerStack, selectionLayer, false) {
- /**
- * @see org.eclipse.nebula.widgets.nattable.layer.AbstractLayer#getCellPainter(int, int, org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
- *
- * @param columnPosition
- * @param rowPosition
- * @param cell
- * @param configRegistry
- * @return
- */
- @Override
- public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) {
- rowPosition = this.underlyingToLocalRowPosition(treeLayer, rowPosition);
- columnPosition = this.underlyingToLocalColumnPosition(treeLayer, columnPosition);
- return treeLayer.getCellPainter(columnPosition, rowPosition, cell, configRegistry);
- }
- };
- }
-
- return super.createLabelRowHeaderLayer(bodyLayerStack, tableManager);
- }
-
- public ColumnHideShowLayer getRowHeaderColumnHideShowLayer() {
- return this.columnHideShowLayer;
- }
-
- /**
- *
- * @return
- * the tree layer;
- */
- public TreeLayer getTreeLayer() {
- return this.treeLayer;
- }
-
- /**
- * @see org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform#dispose()
- *
- */
- @Override
- public void dispose() {
- super.dispose();
- this.columnHideShowLayer = null;
- this.treeLayer = null;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2016 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 488234
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.layerstack;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
+import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
+import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
+import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
+import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
+import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
+import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
+import org.eclipse.papyrus.infra.nattable.dataprovider.HierarchicalRowLabelHeaderDataProvider;
+import org.eclipse.papyrus.infra.nattable.layer.PapyrusTreeLayer;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITreeNattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
+import org.eclipse.papyrus.infra.nattable.painter.PapyrusIndentedTreeImagePainter;
+
+import ca.odell.glazedlists.TreeList;
+
+/**
+ *
+ * @author VL222926
+ * Layer stack used for row header
+ */
+public class RowHeaderHierarchicalLayerStack extends RowHeaderLayerStack {
+
+
+ private Object rowSortModel;// TODO
+
+ private ColumnHideShowLayer columnHideShowLayer;
+
+ private TreeLayer treeLayer;
+
+ private ViewportLayer viewportLayer;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param indexDataProvider
+ * the index data provider
+ * @param labelDataProvider
+ * the label data provider
+ * @param bodyLayer
+ * the body layer
+ */
+ public RowHeaderHierarchicalLayerStack(final BodyLayerStack bodyLayer, final INattableModelManager tableManager) { // 1. create the index row layer
+ super(bodyLayer, tableManager);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack#createLabelDataProvider()
+ *
+ * @return
+ */
+ @Override
+ protected IDataProvider createLabelDataProvider() {
+ return new HierarchicalRowLabelHeaderDataProvider(this.tableManager);
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack#createLabelRowHeaderLayer(org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack, org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager)
+ *
+ * @param bodyLayerStack
+ * @param tableManager
+ * @return
+ */
+ @Override
+ protected AbstractLayer createLabelRowHeaderLayer(BodyLayerStack bodyLayerStack, INattableModelManager tableManager) {
+ List<?> managedAxis = ((ITreeNattableModelManager) tableManager).getTreeList();
+ if (managedAxis instanceof TreeList<?>) {
+ @SuppressWarnings("unchecked")
+ GlazedListTreeData<ITreeItemAxis> glazedListTreeData = new GlazedListTreeData<ITreeItemAxis>((TreeList<ITreeItemAxis>) managedAxis);
+ this.columnHideShowLayer = new ColumnHideShowLayer(getLabelDataLayer());
+ this.treeLayer = new PapyrusTreeLayer(this.columnHideShowLayer, new GlazedListTreeRowModel<ITreeItemAxis>(glazedListTreeData), new PapyrusIndentedTreeImagePainter(), true);
+ this.viewportLayer = new ViewportLayer(this.treeLayer);
+
+ return new RowHeaderLayer(viewportLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer(), false) {
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.AbstractLayer#getCellPainter(int, int, org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param columnPosition
+ * @param rowPosition
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ @Override
+ public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) {
+ rowPosition = this.underlyingToLocalRowPosition(treeLayer, rowPosition);
+ columnPosition = this.underlyingToLocalColumnPosition(treeLayer, columnPosition);
+ return treeLayer.getCellPainter(columnPosition, rowPosition, cell, configRegistry);
+ }
+ };
+ }
+
+ return super.createLabelRowHeaderLayer(bodyLayerStack, tableManager);
+ }
+
+ public ColumnHideShowLayer getRowHeaderColumnHideShowLayer() {
+ return this.columnHideShowLayer;
+ }
+
+ /**
+ *
+ * @return
+ * the tree layer;
+ */
+ public TreeLayer getTreeLayer() {
+ return this.treeLayer;
+ }
+
+ /**
+ *
+ * @return
+ * the viewport layer;
+ */
+ public ViewportLayer getViewportLayer() {
+ return this.viewportLayer;
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ this.columnHideShowLayer = null;
+ this.treeLayer = null;
+ }
+}
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 438f676d556..ae658dbbbf4 100755
--- 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012, 2014 CEA LIST and others.
+ * Copyright (c) 2012, 2016 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 402525
* Christian W. Damus (CEA) - bug 430880
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 488234
*
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;
@@ -245,7 +246,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
/**
* the composite layer providing the filter row in the column header
*/
- private FilterRowHeaderComposite<?> filterColumnHeaderComposite;
+ protected FilterRowHeaderComposite<?> filterColumnHeaderComposite;
/**
* the sort model used for rows
@@ -354,7 +355,6 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
this.gridLayer.addConfiguration(new DefaultPrintBindings());
this.natTable = new NatTable(parent, this.gridLayer, false);
-
// we register nattable configuration
registerPopupMenuConfiguration(this.natTable);
@@ -412,7 +412,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
/**
* Register the menu configuration for the table
- *
+ *
* @param natTable
* the nattable to configure
*/
@@ -422,7 +422,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
/**
* Configure the row sort selecting column header
- *
+ *
* @param natTable
* the nattable widget
*/
@@ -609,7 +609,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
/**
- *
+ *
* @return
* the label provider service
*/
@@ -624,7 +624,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
/**
- *
+ *
* @return
* the decoration service
*/
@@ -642,7 +642,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @param natTable
* @return
- *
+ *
* @deprecated since Papyrus 1.3 (Eclipse Neon)
*/
@Deprecated
@@ -655,7 +655,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
* @param natTable
* @param site
* @param selectionProvider
- *
+ *
* @return
* This method creates the MenuManager used for theBody of the table and register it, with the selection provider in the {@link IWorkbenchPartSite} of the editor when not <code>null</code>
*/
@@ -1833,4 +1833,5 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
return Collections.emptyMap();
}
+
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java
index dcc96b5e117..47e1e5ba1a7 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
+ * Copyright (c) 2015, 2016 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Dirk Fauth <dirk.fauth@googlemail.com> - Bug 488234
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;
@@ -32,8 +33,18 @@ import org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideComma
import org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnShowCommand;
import org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter;
+import org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter;
+import org.eclipse.nebula.widgets.nattable.resize.action.VerticalResizeCursorAction;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter;
+import org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter;
+import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
+import org.eclipse.nebula.widgets.nattable.viewport.SliderScroller;
+import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
import org.eclipse.papyrus.infra.emf.gmf.util.GMFUnsafe;
import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.clientarea.ClientAreaResizeDragMode;
+import org.eclipse.papyrus.infra.nattable.clientarea.ClientAreaResizeMatcher;
import org.eclipse.papyrus.infra.nattable.command.CommandIds;
import org.eclipse.papyrus.infra.nattable.configuration.TreeTableClickSortConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.TreeTablePopupMenuConfiguration;
@@ -67,8 +78,16 @@ import org.eclipse.papyrus.infra.nattable.utils.FillingConfigurationUtils;
import org.eclipse.papyrus.infra.nattable.utils.StyleUtils;
import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
import org.eclipse.papyrus.infra.ui.util.EclipseCommandUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Slider;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.commands.ICommandService;
@@ -99,6 +118,11 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
protected DatumExpansionModel expansionModel;
+ /**
+ * the height of the scrollbar
+ */
+ private static final int scrollbarHeight = 17;
+
/**
* the listener used to refresh the update the hidden rows
@@ -213,7 +237,72 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
*/
@Override
public NatTable createNattable(Composite parent, int style, IWorkbenchPartSite site) {
- NatTable nattable = super.createNattable(parent, style, site);
+ // Wrap NatTable in composite so we can slap on the external horizontal
+ // sliders
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(1, false);
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 0;
+ composite.setLayout(gridLayout);
+
+ NatTable nattable = super.createNattable(composite, style, site);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ natTable.setLayoutData(gridData);
+
+ // MULTI-VIEWPORT-CONFIGURATION
+ createSplitSliders(composite, getRowHeaderLayerStack().getViewportLayer(), getBodyLayerStack().getViewportLayer());
+
+ // as the CompositeLayer is setting a IClientAreaProvider for the
+ // composition we need to set a special ClientAreaAdapter after the
+ // creation of the CompositeLayer to support split viewports
+ int leftWidth = RowHeaderLayerStack.DEFAULT_ROW_HEIGHT;
+ ClientAreaAdapter leftClientAreaAdapter =
+ new ClientAreaAdapter(getRowHeaderLayerStack().getViewportLayer().getClientAreaProvider());
+ leftClientAreaAdapter.setWidth(leftWidth);
+ getRowHeaderLayerStack().getViewportLayer().setClientAreaProvider(leftClientAreaAdapter);
+
+ getRowHeaderLayerStack().getViewportLayer().setVerticalScrollbarEnabled(false);
+
+ // use a cell layer painter that is configured for left clipping
+ // this ensures that the rendering works correctly for split
+ // viewports
+ getBodyLayerStack().getSelectionLayer().setLayerPainter(new SelectionLayerPainter(true, false));
+
+ filterColumnHeaderComposite.setLayerPainter(new CellLayerPainter(true, false));
+
+ // add an IOverlayPainter to render the split viewport border
+ natTable.addOverlayPainter(new IOverlayPainter() {
+
+ @Override
+ public void paintOverlay(GC gc, ILayer layer) {
+ Color beforeColor = gc.getForeground();
+ gc.setForeground(GUIHelper.COLOR_GRAY);
+ int viewportBorderX = getRowHeaderLayerStack().getWidth() - 1;
+ gc.drawLine(viewportBorderX, 0, viewportBorderX, layer.getHeight() - 1);
+ gc.setForeground(beforeColor);
+ }
+ });
+
+ // Mouse move - Show resize cursor
+ natTable.getUiBindingRegistry().registerFirstMouseMoveBinding(
+ new ClientAreaResizeMatcher(getRowHeaderLayerStack()),
+ new VerticalResizeCursorAction());
+
+ natTable.getUiBindingRegistry().registerFirstMouseDragMode(
+ new ClientAreaResizeMatcher(getRowHeaderLayerStack()),
+ new ClientAreaResizeDragMode(
+ getRowHeaderLayerStack().getIndexRowHeaderLayer(),
+ getRowHeaderLayerStack().getTreeLayer(),
+ leftClientAreaAdapter,
+ getRowHeaderLayerStack().getViewportLayer(),
+ getBodyLayerStack().getViewportLayer()));
+
// update the hidden categories
List<Integer> hiddenDepth = StyleUtils.getHiddenDepths(this);
@@ -234,6 +323,59 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
return nattable;
}
+ private void createSplitSliders(Composite natTableParent, final ViewportLayer left, final ViewportLayer right) {
+ Composite sliderComposite = new Composite(natTableParent, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = false;
+ gridData.heightHint = scrollbarHeight;
+ sliderComposite.setLayoutData(gridData);
+
+ GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 0;
+ sliderComposite.setLayout(gridLayout);
+
+ // Slider Left
+ // Need a composite here to set preferred size because Slider can't be
+ // subclassed.
+ Composite sliderLeftComposite = new Composite(sliderComposite, SWT.NONE) {
+ @Override
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ int width = ((ClientAreaAdapter) left.getClientAreaProvider()).getWidth()
+ + getRowHeaderLayerStack().getIndexRowHeaderLayer().getWidth();
+ return new Point(width, scrollbarHeight);
+ }
+ };
+ sliderLeftComposite.setLayout(new FillLayout());
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.BEGINNING;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ sliderLeftComposite.setLayoutData(gridData);
+
+ Slider sliderLeft = new Slider(sliderLeftComposite, SWT.HORIZONTAL);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ sliderLeft.setLayoutData(gridData);
+
+ left.setHorizontalScroller(new SliderScroller(sliderLeft));
+
+ // Slider Right
+ Slider sliderRight = new Slider(sliderComposite, SWT.HORIZONTAL);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = false;
+ sliderRight.setLayoutData(gridData);
+
+ right.setHorizontalScroller(new SliderScroller(sliderRight));
+ }
+
/**
* @see org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager#addClickSortConfiguration(org.eclipse.nebula.widgets.nattable.NatTable)
*
@@ -427,10 +569,10 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
}
/**
- *
+ *
* @param bodyLayerStack
* the body layer stack to use
- *
+ *
* @return
* the row header layer stack to use
*/
@@ -439,8 +581,12 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
return new RowHeaderHierarchicalLayerStack(bodyLayerStack, this);
}
+ public RowHeaderHierarchicalLayerStack getRowHeaderLayerStack() {
+ return (RowHeaderHierarchicalLayerStack) super.getRowHeaderLayerStack();
+ }
+
/**
- *
+ *
* @see org.eclipse.papyrus.infra.nattable.manager.table.ITreeNattableModelManager#doCollapseExpandAction(org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum, java.util.List)
*
* @param actionId
@@ -463,7 +609,7 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
/**
* Modify the axis when it is disposed.
- *
+ *
* @param iAxis
* The list of axis.
*/

Back to the top