diff options
| author | Vincent Lorenzo | 2015-11-09 15:37:44 +0000 |
|---|---|---|
| committer | Gerrit Code Review @ Eclipse.org | 2015-11-27 12:40:38 +0000 |
| commit | 5300b188ca21d528f371de6a2d0f3399256bab77 (patch) | |
| tree | 4190029155867c3b93228e59c8a693d7cd19740d | |
| parent | 0ebafaddfc38f9be44be2e5392bddb9570504712 (diff) | |
| download | org.eclipse.papyrus-5300b188ca21d528f371de6a2d0f3399256bab77.tar.gz org.eclipse.papyrus-5300b188ca21d528f371de6a2d0f3399256bab77.tar.xz org.eclipse.papyrus-5300b188ca21d528f371de6a2d0f3399256bab77.zip | |
bug 481727: [Table] Papyrus must refactore the popup menu of the table
Change-Id: I00c640154cc16d18fb33495258d90efa1b4bfbbf
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
6 files changed, 117 insertions, 198 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/plugin.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/plugin.xml index 79a5bc9df58..c04c18e6d79 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/plugin.xml +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/plugin.xml @@ -271,7 +271,7 @@ point="org.eclipse.ui.menus"> <menuContribution allPopups="false" - locationURI="popup:org.eclipse.ui.popup.any"> + locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu?endof=table.generic.actions"> <command commandId="org.eclipse.papyrus.infra.nattable.common.reload.table.editor.command" label="Reload Table Editor" 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 62c29fa9f0c..5aacefbe93e 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml @@ -12,22 +12,21 @@ point="org.eclipse.ui.menus"> <menuContribution allPopups="true" - locationURI="popup:org.eclipse.ui.popup.any"> + locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu"> + + <separator + name="table.generic.actions" + visible="false"> + </separator> <command - commandId="org.eclipse.papyrus.infra.nattable.import.command" + commandId="org.eclipse.ui.file.print" + label="Print Table" + mnemonic="&P" + style="push"> + </command> + <command + commandId="org.eclipse.papyrus.infra.nattable.exporttoXLScommand" style="push"> - <visibleWhen> - <and> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> - </and> - </visibleWhen> </command> <command commandId="org.eclipse.papyrus.infra.nattable.invert.axis" @@ -38,14 +37,6 @@ variable="selection"> <test forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> - <with - variable="selection"> - <test - forcePluginActivation="true" property="org.eclipse.papyrus.infra.nattable.tester.canInvertAxis" value="true"> </test> @@ -53,65 +44,53 @@ </and> </visibleWhen> </command> + <separator + name="edit" + visible="true"> + </separator> <command - commandId="org.eclipse.ui.file.print" - label="Print Table" - mnemonic="&P" + commandId="org.eclipse.ui.edit.selectAll" style="push"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> - </visibleWhen> </command> <command - commandId="org.eclipse.ui.edit.selectAll" + commandId="org.eclipse.ui.edit.paste" style="push"> <visibleWhen> <with variable="selection"> <test + args="cell" forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" + property="org.eclipse.papyrus.infra.nattable.canPaste" value="true"> </test> </with> </visibleWhen> </command> - <command - commandId="org.eclipse.papyrus.infra.nattable.row.categories.command" + <command + commandId="org.eclipse.papyrus.infra.nattable.import.command" style="push"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isHierarchicTable" - value="true"> - </test> - </with> - </visibleWhen> </command> <command - commandId="org.eclipse.papyrus.infra.nattable.exporttoXLScommand" + commandId="org.eclipse.papyrus.infra.nattable.insert" style="push"> <visibleWhen> <with variable="selection"> <test + args="none" forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" + property="org.eclipse.papyrus.infra.nattable.canInsert" value="true"> </test> </with> </visibleWhen> </command> - <menu + <separator + name="table.tree.separator" + visible="true"> + </separator> + <menu label="Hierarchic Style"> <visibleWhen> <with @@ -142,30 +121,27 @@ </parameter> </command> </menu> - <menu - icon="icons/mergeTable.gif" - label="Merge Options"> - <visibleWhen> - <and> - <with + <command + commandId="org.eclipse.papyrus.infra.nattable.row.categories.command" + style="push"> + <visibleWhen> + <with variable="selection"> - <test + <test forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" + property="org.eclipse.papyrus.infra.nattable.tester.isHierarchicTable" value="true"> - </test> - </with> - </and> + </test> + </with> </visibleWhen> -<!-- <command - commandId="org.eclipse.papyrus.infra.nattable.mergeTable" - label="Merge/UnMerge all Table Cells" - style="toggle" - tooltip="Merge/UnMerge all Table Cells option"> - <visibleWhen - checkEnabled="false"> - </visibleWhen> - </command> --> + </command> + <separator + name="cell.separator" + visible="true"> + </separator> + <menu + icon="icons/mergeTable.gif" + label="Merge Options"> <command commandId="org.eclipse.papyrus.infra.nattable.mergeRows" label="Merge/UnMerge Rows Cells" @@ -178,28 +154,27 @@ </command> <command commandId="org.eclipse.papyrus.infra.nattable.mergeSelectedRows" - label="Merge/UnMerge Selected Rows' Cells" + label="Merge/UnMerge Selected Rows' Cells" style="toggle"> </command> <command commandId="org.eclipse.papyrus.infra.nattable.mergeSelectedColumns" - label="Merge/UnMerge Selected Columns' Cells" + label="Merge/UnMerge Selected Columns' Cells" style="toggle"> </command> </menu> + <command + commandId="org.eclipse.papyrus.infra.nattable.mark.as.resolved.command" + style="push"> + </command> + <separator + name="rows.and.columns.separator" + visible="true"> + </separator> <menu icon="icons/tableColumnAction.gif" + id="org.eclipse.papyrus.infra.nattable.columns.menu" label="Columns"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> - </visibleWhen> <command commandId="org.eclipse.papyrus.infra.nattable.createdestroycolumns" label="Create/Destroy columns" @@ -218,15 +193,8 @@ name="org.eclipse.papyrus.infra.nattable.sort.command.alphabetic.order.parameter" value="true"> </parameter> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> + <visibleWhen + checkEnabled="false"> </visibleWhen> </command> <command @@ -238,15 +206,8 @@ name="org.eclipse.papyrus.infra.nattable.sort.command.alphabetic.order.parameter" value="false"> </parameter> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> + <visibleWhen + checkEnabled="true"> </visibleWhen> </command> <command @@ -382,19 +343,12 @@ style="push"> </command> </menu> - <menu icon="icons/tableRowAction.gif" + id="org.eclipse.papyrus.infra.nattable.rows.menu" label="Rows"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> + <visibleWhen + checkEnabled="true"> </visibleWhen> <command commandId="org.eclipse.papyrus.infra.nattable.createdestroyrows" @@ -532,8 +486,7 @@ <command commandId="org.eclipse.papyrus.infra.nattable.row.disconnect.slave" style="toggle"> - <visibleWhen - checkEnabled="true"> + <visibleWhen> <with variable="selection"> <test @@ -555,63 +508,14 @@ style="push"> </command> </menu> - <command - commandId="org.eclipse.papyrus.infra.nattable.mark.as.resolved.command" - style="push"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - </with> - </visibleWhen> - </command> <separator - name="org.eclipse.papyrus.infra.nattable.separator1"> + name="creations" + visible="true"> + </separator> + <separator + name="additions" + visible="true"> </separator> - <command - commandId="org.eclipse.ui.edit.paste" - style="push"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - <test - args="cell" - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.canPaste" - value="true"> - </test> - </with> - </visibleWhen> - </command> - <command - commandId="org.eclipse.papyrus.infra.nattable.insert" - style="push"> - <visibleWhen> - <with - variable="selection"> - <test - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.tester.isNattableWidget" - value="true"> - </test> - <test - args="none" - forcePluginActivation="true" - property="org.eclipse.papyrus.infra.nattable.canInsert" - value="true"> - </test> - </with> - </visibleWhen> - </command> </menuContribution> </extension> <extension 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 4b9c33ee8ee..fff8e2cb4ad 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 @@ -43,6 +43,7 @@ import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.nebula.widgets.nattable.NatTable; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; import org.eclipse.nebula.widgets.nattable.coordinate.Range; @@ -162,6 +163,16 @@ 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 @@ -401,16 +412,8 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan addRowHeaderResizeListener(this.rowHeaderLayerStack); addDragAndDropSupport(this.natTable); - - if (site != null) { - final MenuManager menuMgr = createMenuManager(this.natTable); - final Menu menu = menuMgr.createContextMenu(this.natTable); - this.natTable.setMenu(menu); - - this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer()); - site.registerContextMenu(menuMgr, this.selectionProvider); - site.setSelectionProvider(this.selectionProvider); - } + this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer()); + createAndRegisterMenuManagerAndSelectionProvider(this.natTable, site, this.selectionProvider); new PapyrusNatTableToolTipProvider(this.natTable, GridRegion.BODY, GridRegion.COLUMN_HEADER, GridRegion.ROW_HEADER); @@ -640,23 +643,35 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan * * @param natTable * @return + * + * @deprecated since Papyrus 1.3 (Eclipse Neon) */ + @Deprecated public MenuManager createMenuManager(final NatTable natTable) { - final MenuManager menuManager = new MenuManager("#PopUp", "org.eclipse.papyrus.infra.nattable.widget.menu") { //$NON-NLS-1$ //$NON-NLS-2$ + return createAndRegisterMenuManagerAndSelectionProvider(natTable, null, this.selectionProvider); + } - @Override - public void add(final IAction action) { - super.add(action); - } + /** + * + * @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> + */ + public MenuManager createAndRegisterMenuManagerAndSelectionProvider(final NatTable natTable, final IWorkbenchPartSite site, ISelectionProvider selectionProvider) { + final MenuManager menuManager = new MenuManager(POPUP, TABLE_POPUP_MENU_ID); + menuManager.setRemoveAllWhenShown(true); - @Override - public void add(final IContributionItem item) { - super.add(item); - } - }; - menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + final Menu menu = menuManager.createContextMenu(this.natTable); + + this.natTable.setMenu(menu); + if (site != null) { + site.registerContextMenu(menuManager.getId(), menuManager, selectionProvider); + site.setSelectionProvider(this.selectionProvider); + } - menuManager.setRemoveAllWhenShown(true); return menuManager; } diff --git a/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.menu/plugin.xml b/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.menu/plugin.xml index 3c1f5df209f..a7fcb74faf7 100644 --- a/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.menu/plugin.xml +++ b/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.menu/plugin.xml @@ -412,7 +412,7 @@ point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
- locationURI="popup:org.eclipse.ui.popup.any">
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu?after=creations">
<menu
id="org.eclipse.papyrus.sysml.nattable.create.sysml.menu"
label="Create SysML Element">
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/plugin.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/plugin.xml index d3eeecb49ea..9f60ca00c78 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/plugin.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/plugin.xml @@ -2460,7 +2460,7 @@ point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
- locationURI="popup:org.eclipse.ui.popup.any">
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu?after=creations">
<menu
id="org.eclipse.papyrus.uml.nattable.create.uml.menu"
label="Create UML Element">
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml index 69c20bbcec5..8d74e3770f6 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml @@ -115,14 +115,14 @@ <extension point="org.eclipse.ui.menus"> <menuContribution - allPopups="true" + allPopups="false" class="org.eclipse.papyrus.uml.nattable.menu.CreateColumnStereotypePropertyMenuFactory" - locationURI="popup:org.eclipse.ui.popup.any"> + locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu?after=org.eclipse.papyrus.infra.nattable.columns.menu"> </menuContribution> <menuContribution - allPopups="true" + allPopups="false" class="org.eclipse.papyrus.uml.nattable.menu.CreateRowStereotypePropertyMenuFactory" - locationURI="popup:org.eclipse.ui.popup.any"> + locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu?after=org.eclipse.papyrus.infra.nattable.rows.menu"> </menuContribution> </extension> <extension |
