Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2015-12-02 13:12:55 +0000
committerGerrit Code Review @ Eclipse.org2015-12-04 14:31:39 +0000
commite0c715e90be0a8a8ba0332d5474b09c427321cd6 (patch)
treeba2bd0bb3fe8ca8238823d5ac6fc10727cdd7140 /plugins/infra
parentf8dedc59a0e9bc39beaa61b7a8c2cad1252c9438 (diff)
downloadorg.eclipse.papyrus-e0c715e90be0a8a8ba0332d5474b09c427321cd6.tar.gz
org.eclipse.papyrus-e0c715e90be0a8a8ba0332d5474b09c427321cd6.tar.xz
org.eclipse.papyrus-e0c715e90be0a8a8ba0332d5474b09c427321cd6.zip
bug 483358: [Table] Row Header and Column Header popup menu must be refactored
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml172
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java11
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java71
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java38
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java34
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java14
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java69
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java104
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java165
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java50
12 files changed, 710 insertions, 21 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
index 90b1b299d20..46c446cd903 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
@@ -26,6 +26,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable,
org.eclipse.papyrus.infra.nattable.manager.axis,
org.eclipse.papyrus.infra.nattable.manager.cell,
org.eclipse.papyrus.infra.nattable.manager.table,
+ org.eclipse.papyrus.infra.nattable.menu,
org.eclipse.papyrus.infra.nattable.messages,
org.eclipse.papyrus.infra.nattable.nattableconfiguration,
org.eclipse.papyrus.infra.nattable.painter,
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml
index 5aacefbe93e..c79511dd034 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml
@@ -68,6 +68,10 @@
</visibleWhen>
</command>
<command
+ commandId="org.eclipse.ui.edit.delete"
+ style="push">
+ </command>
+ <command
commandId="org.eclipse.papyrus.infra.nattable.import.command"
style="push">
</command>
@@ -517,6 +521,174 @@
visible="true">
</separator>
</menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.header.rows.menu?after=general.separator">
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.autoresize.rows"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.header.rows.menu?after=edit.separator">
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.edit.row.header"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.row"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.row.element"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.paste"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.insert"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.import.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.header.rows.menu?after=tree.separator">
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.collapse.all.tree.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.collapse.all.tree.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.expand.all.tree.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.expand.all.on.selection.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.expand.selection.on.2.level.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <separator
+ name="category.separator"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.categories.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.hide.allcategories.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.row.show.allcategories.command"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <dynamic
+ class="org.eclipse.papyrus.infra.nattable.menu.ShowHideCategoriesContributionItem"
+ id="org.eclipse.papyrus.infra.nattable.tree.show.hide.categories">
+ </dynamic>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.header.columns.menu?after=general.separator">
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.autoresize.columns"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.header.columns.menu?after=edit.separator">
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.edit.column.header"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.column"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.column.element"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.nattable.column.paste"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
index b9f8301082f..e5b27ee16de 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
@@ -25,18 +25,27 @@ import org.eclipse.swt.SWT;
* Adapted code from AbstractHeaderMenuConfiguration
*
* @author vl222926
- *
+ *
+ * @deprecated since Papyrus 1.2 (Eclipse Neon), Use TablePopupMenuConfiguration instead or a subclass)
*/
+@Deprecated
public class PapyrusHeaderMenuConfiguration extends AbstractUiBindingConfiguration {
/**
* the category used for the column command
+ *
+ * @deprecated with no replacement, because useless now
+ *
*/
+ @Deprecated
public static final String COLUMN_COMMANDS_CATEGORY_ID = "org.eclipse.papyrus.infra.nattable.columns.command.category"; //$NON-NLS-1$
/**
* the category used for the row command
+ *
+ * @deprecated with no replacement, because useless now
*/
+ @Deprecated
public static final String ROW_COMMANDS_CATEGORY_ID = "org.eclipse.papyrus.infra.nattable.rows.command.category"; //$NON-NLS-1$
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
index 9b7c6e2ab88..d5eaa976ba7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
@@ -56,7 +56,9 @@ import org.eclipse.ui.handlers.IHandlerService;
*
* @author vl222926
*
+ * @deprecated since Papyrus 1.2 (Eclipse Neon)
*/
+@Deprecated
public class PapyrusPopupMenuAction extends PopupMenuAction {
/** the category of the commands to add to this menu */
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
new file mode 100644
index 00000000000..32a52956901
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
+import org.eclipse.papyrus.infra.nattable.menu.PapyrusHeaderPopupMenuAction;
+import org.eclipse.swt.SWT;
+
+/**
+ * @author VL222926
+ * This configuration allows to register popup menu for row header, column header and body of the table
+ */
+public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration {
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.config.IConfiguration#configureUiBindings(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ registerBodyPopupMenu(uiBindingRegistry);
+ registerColumnHeaderPopupMenu(uiBindingRegistry);
+ registerRowHeaderPopupMenu(uiBindingRegistry);
+ }
+
+ /**
+ * register the menu configuration for the body of the table
+ *
+ * @param uiBindingRegistry
+ *
+ */
+ protected void registerBodyPopupMenu(final UiBindingRegistry uiBindingRegistry) {
+ // nothing to do
+ }
+
+ /**
+ * register the menu configuration for the row header of the table
+ *
+ * @param uiBindingRegistry
+ *
+ */
+ protected void registerRowHeaderPopupMenu(final UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID));
+ }
+
+ /**
+ * register the menu configuration for the column header of the table
+ *
+ * @param uiBindingRegistry
+ *
+ */
+ protected void registerColumnHeaderPopupMenu(final UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.COLUMN_HEADER_POPUP_MENU_ID));
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
new file mode 100644
index 00000000000..56ff1334c64
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
+import org.eclipse.papyrus.infra.nattable.menu.TreePapyrusHeaderPopupMenuAction;
+import org.eclipse.swt.SWT;
+
+/**
+ * @author VL222926
+ * The configuration to use to popup menu in Tree Table
+ */
+public class TreeTablePopupMenuConfiguration extends TablePopupMenuConfiguration {
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.TablePopupMenuConfiguration#registerRowHeaderPopupMenu(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ protected void registerRowHeaderPopupMenu(UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new TreePapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID));
+ }
+}
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 fff8e2cb4ad..3c9e988b831 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
@@ -37,9 +37,6 @@ import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
@@ -88,9 +85,9 @@ import org.eclipse.papyrus.infra.nattable.configuration.ClearSelectionUIBindingC
import org.eclipse.papyrus.infra.nattable.configuration.CornerConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.FilterRowAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.FilterRowCustomConfiguration;
-import org.eclipse.papyrus.infra.nattable.configuration.PapyrusHeaderMenuConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.RowSortModelConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.TableClickSortConfiguration;
+import org.eclipse.papyrus.infra.nattable.configuration.TablePopupMenuConfiguration;
import org.eclipse.papyrus.infra.nattable.dataprovider.AbstractCompositeDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.ColumnIndexHeaderDataProvider;
@@ -105,6 +102,7 @@ import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.ColumnHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.listener.NatTableDropListener;
+import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
@@ -150,7 +148,6 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.services.IDisposable;
@@ -163,16 +160,6 @@ import org.eclipse.ui.services.IDisposable;
public abstract class AbstractNattableWidgetManager implements INattableModelManager, NavigationTarget, IAdaptable {
/**
- * the table popup menu id
- */
- public static final String TABLE_POPUP_MENU_ID = "org.eclipse.papyrus.infra.nattable.widget.menu"; //$NON-NLS-1$
-
- /**
- * the string popup used to declare the menu location
- */
- public static final String POPUP = "popup"; //$NON-NLS-1$
-
- /**
* we need to keep it to be able to remove listener (required when we destroy the context of the table)
*
* The editing domain to use to edit context element
@@ -368,7 +355,8 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
// we register nattable configuration
- this.natTable.addConfiguration(new PapyrusHeaderMenuConfiguration());
+ registerPopupMenuConfiguration(this.natTable);
+
addClickSortConfiguration(this.natTable);
this.natTable.addConfiguration(new FilterRowCustomConfiguration());
this.natTable.addConfiguration(new RowSortModelConfiguration(getRowSortModel()));
@@ -422,6 +410,16 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
/**
+ * Register the menu configuration for the table
+ *
+ * @param natTable
+ * the nattable to configure
+ */
+ protected void registerPopupMenuConfiguration(final NatTable natTable) {
+ natTable.addConfiguration(new TablePopupMenuConfiguration());
+ }
+
+ /**
* Configure the row sort selecting column header
*
* @param natTable
@@ -661,7 +659,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
* 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>
*/
public MenuManager createAndRegisterMenuManagerAndSelectionProvider(final NatTable natTable, final IWorkbenchPartSite site, ISelectionProvider selectionProvider) {
- final MenuManager menuManager = new MenuManager(POPUP, TABLE_POPUP_MENU_ID);
+ final MenuManager menuManager = new MenuManager(MenuConstants.POPUP, MenuConstants.TABLE_POPUP_MENU_ID);
menuManager.setRemoveAllWhenShown(true);
final Menu menu = menuManager.createContextMenu(this.natTable);
@@ -1209,7 +1207,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
this.tableEditingDomain = null;
this.contextEditingDomain = null;
this.tableContext = null;
- if(this.natTable!=null){
+ if (this.natTable != null) {
this.natTable.dispose();
}
}
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 1a06b640938..ebb759849ad 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
@@ -34,6 +34,7 @@ import org.eclipse.papyrus.commands.Activator;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
import org.eclipse.papyrus.infra.nattable.command.CommandIds;
import org.eclipse.papyrus.infra.nattable.configuration.TreeTableClickSortConfiguration;
+import org.eclipse.papyrus.infra.nattable.configuration.TreeTablePopupMenuConfiguration;
import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderHierarchicalLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack;
@@ -143,6 +144,15 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
this(rawModel, new ObjectsSelectionExtractor());
}
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager#registerPopupMenuConfiguration(org.eclipse.nebula.widgets.nattable.NatTable)
+ *
+ * @param natTable
+ */
+ @Override
+ protected void registerPopupMenuConfiguration(final NatTable natTable) {
+ natTable.addConfiguration(new TreeTablePopupMenuConfiguration());
+ }
/**
* @see org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager#createHorizontalElementList()
@@ -463,9 +473,9 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
this.hideShowCategoriesListener = null;
}
final List<IAxis> iAxis;
- if(null == getHorizontalAxisProvider()){
+ if (null == getHorizontalAxisProvider()) {
iAxis = null;
- }else{
+ } else {
iAxis = getHorizontalAxisProvider().getAxis();
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java
new file mode 100644
index 00000000000..a9906c7074e
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.menu;
+
+/**
+ * @author VL222926
+ * This class grousp the constant used for table menu
+ */
+public class MenuConstants {
+
+ /**
+ * Constructor.
+ *
+ */
+ private MenuConstants() {
+ // to prevent instanciation
+ }
+
+ /**
+ * the string popup used to declare the menu location
+ */
+ public static final String POPUP = "popup"; //$NON-NLS-1$
+
+ /**
+ * the table body popup menu id
+ */
+ public static final String TABLE_POPUP_MENU_ID = "org.eclipse.papyrus.infra.nattable.widget.menu"; //$NON-NLS-1$
+
+ /**
+ * the table row header menu id
+ */
+ public static final String ROW_HEADER_POPUP_MENU_ID = "org.eclipse.papyrus.infra.nattable.widget.header.rows.menu"; //$NON-NLS-1$
+
+ /**
+ * the table column header menu id
+ */
+ public static final String COLUMN_HEADER_POPUP_MENU_ID = "org.eclipse.papyrus.infra.nattable.header.columns.menu"; //$NON-NLS-1$
+
+ /**
+ * the separator between menu location and menu id
+ */
+ public static final String DELIMITER = ":"; //$NON-NLS-1$
+
+ /**
+ * this separator is used to group contribution for tree table
+ */
+ public static final String TREE_SEPARATOR_ID = "tree.separator"; //$NON-NLS-1$
+
+ /**
+ * this separator is used to group general contribution
+ */
+ public static final String GENERAL_SEPARATOR_ID = "general.separator"; //$NON-NLS-1$
+
+ /**
+ * this separator is used to group edit contribution
+ */
+ public static final String EDIT_SEPARATOR_ID = "edit.separator";
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java
new file mode 100644
index 00000000000..c3eacc09725
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.menu;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * @author VL222926
+ *
+ * This class allows to fill the popup menu of the table, according to the contribution described in the plugin.xml
+ *
+ */
+public class PapyrusHeaderPopupMenuAction extends PopupMenuAction {
+
+ /**
+ * the id of the menu to create, plugins can contribute to the menu using this id;
+ */
+ private final String menuId;
+
+ /**
+ * the location used to fill the menu
+ */
+ private final String menuLocation;
+
+ /**
+ * Constructor.
+ *
+ * @param menu
+ */
+ public PapyrusHeaderPopupMenuAction(final String menuId) {
+ super(null);
+ this.menuId = menuId;
+ this.menuLocation = new StringBuilder(MenuConstants.POPUP).append(MenuConstants.DELIMITER).append(menuId).toString();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction#run(org.eclipse.nebula.widgets.nattable.NatTable, org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ @Override
+ public void run(NatTable natTable, MouseEvent event) {
+ final MenuManager menuManager = new MenuManager(MenuConstants.POPUP, this.menuId);
+ final Menu menu = menuManager.createContextMenu(natTable);
+
+ addMenuSeparators(menuManager);
+ /* This listener allows us to fill the popup menu using extension point contributing to the popup menu of the table */
+ menuManager.addMenuListener(new IMenuListener() {
+
+ /**
+ *
+ * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
+ *
+ * @param manager
+ */
+ @Override
+ public void menuAboutToShow(IMenuManager manager) {
+ IMenuService menuService = PlatformUI.getWorkbench().getService(IMenuService.class);
+ if (menuService != null) {
+ menuService.populateContributionManager(menuManager, PapyrusHeaderPopupMenuAction.this.menuLocation);
+ }
+ }
+ });
+
+ menu.setVisible(true);
+ return;
+ }
+
+ /**
+ *
+ * @param menuManager
+ * the menu manager
+ */
+ protected void addMenuSeparators(final MenuManager menuManager) {
+ final Separator general = new Separator(MenuConstants.GENERAL_SEPARATOR_ID);
+ general.setVisible(false);
+ menuManager.add(general);
+
+ final Separator edit = new Separator(MenuConstants.EDIT_SEPARATOR_ID);
+ edit.setVisible(true);
+ menuManager.add(edit);
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java
new file mode 100644
index 00000000000..0e9fc489d3f
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java
@@ -0,0 +1,165 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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.menu;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.handler.TreeRowHideShowCategoryHandler;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.utils.FillingConfigurationUtils;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.nattable.utils.StyleUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+
+/**
+ *
+ * @author VL222926
+ *
+ * This contribution creates a MenuItem for each depth of the tree table, in order to be able to show/hide it easily.
+ */
+public class ShowHideCategoriesContributionItem extends ContributionItem {
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ShowHideCategoriesContributionItem() {
+ super();
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param id
+ */
+ public ShowHideCategoriesContributionItem(String id) {
+ super(id);
+ }
+
+
+ /**
+ * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
+ *
+ * @param menu
+ * @param index
+ */
+ @Override
+ public void fill(Menu menu, int index) {
+ // 1. find the command service
+ final ICommandService serv = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
+ // 2. find the command associated to the handler
+ final Command command = serv.getCommand(TreeRowHideShowCategoryHandler.COMMAND_ID);
+ // 3. try to find the current nattable
+ Control control = Display.getDefault().getCursorControl();
+ if (control instanceof NatTable) {
+ // 4. contribute to the menu
+ addShowHideCategoryCommandToMenu(menu, command, (NatTable) control);
+ }
+ }
+
+ /**
+ *
+ * @param menu
+ * @param command
+ * @param natTable
+ */
+ private void addShowHideCategoryCommandToMenu(final Menu menu, final Command command, final NatTable natTable) {
+ Table table = getTable(natTable);
+ int maxDepth = FillingConfigurationUtils.getMaxDepthForTree(table);
+ int min = 0;
+ if (!FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(table, 0)) {
+ min++;
+ }
+ final IHandler handler = command.getHandler();
+ for (int depth = min; depth <= maxDepth; depth++) {
+ MenuItem item = new MenuItem(menu, SWT.CHECK);
+ final boolean isHidden = isHidden(table, depth);
+ item.setSelection(!isHidden);
+ String text = null;
+ text = NLS.bind(Messages.PapyrusPopupMenuAction_ShowCategoriesOnDepth, depth);
+ item.setText(text);
+ final Integer index = depth;
+ item.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ //we must be able to give the SelectionEvent to the handler using EclispeContext
+ Map<Object, Object> parameters = new HashMap<Object, Object>();
+ parameters.put(TreeRowHideShowCategoryHandler.DEPTH_PARAMETER_KEY, index);
+ parameters.put(TreeRowHideShowCategoryHandler.HIDE_CATEGORY_PARAMETER_KEY, Boolean.valueOf(!isHidden));
+ try {
+ handler.execute(new ExecutionEvent(command, parameters, null, null));
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ // nothing to do
+ }
+ });
+ }
+ }
+
+ /**
+ *
+ * @param natTable
+ * the natTable widget
+ * @return
+ * the table
+ */
+ private Table getTable(final NatTable natTable) {
+ final IConfigRegistry configRegistry = natTable.getConfigRegistry();
+ final INattableModelManager modelManager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ return modelManager.getTable();
+ }
+
+ /**
+ *
+ * @param table
+ * the current table
+ * @param depth
+ * a depth
+ * @return
+ * <code>true</code> if the depth is hidden
+ */
+ private boolean isHidden(Table table, int depth) {
+ return StyleUtils.getHiddenDepths(table).contains(Integer.valueOf(depth));
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java
new file mode 100644
index 00000000000..94d986f3654
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.menu;
+
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+
+/**
+ * @author VL222926
+ *
+ */
+public class TreePapyrusHeaderPopupMenuAction extends PapyrusHeaderPopupMenuAction {
+
+ /**
+ * Constructor.
+ *
+ * @param menuId
+ */
+ public TreePapyrusHeaderPopupMenuAction(String menuId) {
+ super(menuId);
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.menu.PapyrusHeaderPopupMenuAction#addMenuSeparators(org.eclipse.jface.action.MenuManager)
+ *
+ * @param menuManager
+ */
+ @Override
+ protected void addMenuSeparators(final MenuManager menuManager) {
+ //1. we add the common separators
+ super.addMenuSeparators(menuManager);
+ //2. we add a new separator for tree actions
+ final Separator tree = new Separator(MenuConstants.TREE_SEPARATOR_ID);
+ tree.setVisible(true);
+ menuManager.add(tree);
+
+ }
+}

Back to the top