Class PopupMenuBuilder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Wrapper class to build up aContributionItem
based on a givenIMenuItemProvider
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected final MenuItemStateMap
Collection of all registered enablement state checkers for configured id's.static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected org.eclipse.jface.action.MenuManager
TheMenuManager
that is used by this popup menu builder.protected NatTable
The active NatTable instance the context menu should be added to.protected PopupMenuBuilder
The parentPopupMenuBuilder
in case this instance is for building a submenu.protected org.eclipse.swt.widgets.Menu
TheMenu
that is created with this popup menu builder.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected final MenuItemStateMap
Collection of all registered visibility state checkers for configured id's. -
Constructor Summary
ConstructorsConstructorDescriptionPopupMenuBuilder
(org.eclipse.jface.action.MenuManager manager) PopupMenuBuilder
(NatTable parent) CreatesPopupMenuBuilder
that builds up a newMenu
that is only configurable with this instance ofPopupMenuBuilder
.PopupMenuBuilder
(NatTable parent, org.eclipse.jface.action.MenuManager manager) PopupMenuBuilder
(NatTable natTable, PopupMenuBuilder parent, org.eclipse.jface.action.MenuManager menuManager) Constructor to create a submenu.PopupMenuBuilder
(NatTable natTable, PopupMenuBuilder parent, org.eclipse.swt.widgets.Menu menu) Constructor to create a submenu.PopupMenuBuilder
(NatTable natTable, org.eclipse.swt.widgets.Menu menu) Creates a popup menu builder based on the given menu. -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.swt.widgets.Menu
build()
Builds and returns the createdMenu
.org.eclipse.swt.widgets.Menu
build
(boolean diposeMenuManager) Builds and returns the createdMenu
.org.eclipse.jface.action.MenuManager
Sets the given NatTable to this builder and returns theMenuManager
that is used to create the context menu.Build the submenu and return the parentPopupMenuBuilder
to implement the builder pattern.protected NatEventData
protected boolean
protected boolean
Adds the menu item for auto resizing selected columns to the popup menu.withAutoResizeSelectedColumnsMenuItem
(String menuLabel) Adds the menu item for auto resizing selected columns to the popup menu.withAutoResizeSelectedRowsMenuItem
(String menuLabel) withCategoriesBasedColumnChooser
(String menuLabel) withClearAllFilters
(String menuLabel) withColumnChooserMenuItem
(String menuLabel) withColumnRenameDialog
(String menuLabel) withColumnStyleEditor
(String menuLabel) withContributionItem
(org.eclipse.jface.action.ContributionItem contributionItem) Adds the menu item(s) provided by the givenContributionItem
to the popup menu.Adds the menu item for creating a column group with the new performance ColumnGroupHeaderLayer.withCreateColumnGroupMenuItem
(String menuLabel) Adds the menu item for creating a column group with the new performance ColumnGroupHeaderLayer.withCreateColumnGroupsMenuItem
(String menuLabel) Adds the menu item for creating a row group with the new performance RowGroupHeaderLayer.withCreateRowGroupMenuItem
(String menuLabel) Adds the menu item for creating a row group with the new performance RowGroupHeaderLayer.withEnabledState
(String id, IMenuItemState state) Associate a enabledIMenuItemState
with the menu item identified by the given id.Add the menu item for exporting to image to the popup menu.withExportToImageMenuItem
(String menuLabel) Add the menu item for exporting to image to the popup menu.Adds the menu item for for freezing a grid at a given column position.withFreezeColumnMenuItem
(String menuLabel) Adds the menu item for for freezing a grid at a given column position.withFreezePositionMenuItem
(boolean include) Adds the menu item for freezing a grid at a given cell position.withFreezePositionMenuItem
(String menuLabel, boolean include) Adds the menu item for freezing a grid at a given cell position.Adds the menu item for for freezing a grid at a given row position.withFreezeRowMenuItem
(String menuLabel) Adds the menu item for for freezing a grid at a given row position.Adds the menu item for hiding a column to the popup menu.withHideColumnMenuItem
(String menuLabel) Adds the menu item for hiding a column to the popup menu.Adds the menu item for hiding a row to the popup menu by using theRowHideCommand
.withHideRowMenuItem
(String menuLabel) Adds the menu item for hiding a row to the popup menu by using theRowHideCommand
.Adds the menu item for hiding a row to the popup menu by using theRowPositionHideCommand
.withHideRowPositionMenuItem
(String menuLabel) Adds the menu item for hiding a row to the popup menu by using theRowPositionHideCommand
.withMenuItemProvider
(String id, IMenuItemProvider menuItemProvider) Adds the menu item provided by the givenIMenuItemProvider
to the popup menu.withMenuItemProvider
(IMenuItemProvider menuItemProvider) Adds the menu item provided by the givenIMenuItemProvider
to the popup menu.withRemoveColumnGroupMenuItem
(String menuLabel) Adds the menu item for removing a row group.withRemoveRowGroupMenuItem
(String menuLabel) Adds the menu item for removing a row group.withRenameColumnGroupMenuItem
(String menuLabel) Adds the menu item for renaming a row group.withRenameRowGroupMenuItem
(String menuLabel) Adds the menu item for renaming a row group.Adds a separator to the popup menu.withSeparator
(String id) Adds a separator to the popup menu with the given id.Adds the menu item for showing all columns to the popup menu.withShowAllColumnsMenuItem
(String menuLabel) Adds the menu item for showing all columns to the popup menu.Adds the menu item for showing all rows to the popup menu.withShowAllRowsMenuItem
(String menuLabel) Adds the menu item for showing all rows to the popup menu.Adds the menu item for opening the view management dialog to the popup menu.withStateManagerMenuItemProvider
(String menuLabel) Adds the menu item for opening the view management dialog to the popup menu.withSubMenu
(String label) Adds a submenu to the popup menu with the given label.withSubMenu
(String id, String label) Adds a submenu to the popup menu with the given id and label.withSubMenu
(String id, String label, org.eclipse.jface.resource.ImageDescriptor image) Adds a submenu to the popup menu with the given id, label and image.Adds a menu item for toggling the visibility of the filter row.withToggleFilterRow
(String menuLabel) Adds a menu item for toggling the visibility of the filter row.Adds the menu item for removing a frozen state.withUnfreezeMenuItem
(String menuLabel) Adds the menu item for removing a frozen state.withUngroupColumnsMenuItem
(String menuLabel) Adds the menu item for ungrouping selected rows from an existing row group.withUngroupRowsMenuItem
(String menuLabel) Adds the menu item for ungrouping selected rows from an existing row group.withVisibleState
(String id, IMenuItemState state) Associate a visibilityIMenuItemState
with the menu item identified by the given id.
-
Field Details
-
HIDE_COLUMN_MENU_ITEM_ID
- See Also:
-
SHOW_ALL_COLUMNS_MENU_ITEM_ID
- See Also:
-
HIDE_ROW_MENU_ITEM_ID
- See Also:
-
SHOW_ALL_ROWS_MENU_ITEM_ID
- See Also:
-
AUTO_RESIZE_COLUMN_MENU_ITEM_ID
- See Also:
-
AUTO_RESIZE_ROW_MENU_ITEM_ID
- See Also:
-
AUTO_RESIZE_ALL_SELECTED_COLUMN_MENU_ITEM_ID
- See Also:
-
COLUMN_CHOOSER_MENU_ITEM_ID
- See Also:
-
COLUMN_STYLE_EDITOR_MENU_ITEM_ID
- See Also:
-
COLUMN_RENAME_MENU_ITEM_ID
- See Also:
-
CREATE_COLUMN_GROUP_MENU_ITEM_ID
- See Also:
-
RENAME_COLUMN_GROUP_MENU_ITEM_ID
- See Also:
-
REMOVE_COLUMN_GROUP_MENU_ITEM_ID
- See Also:
-
UNGROUP_COLUMNS_MENU_ITEM_ID
- See Also:
-
INSPECT_LABEL_MENU_ITEM_ID
- See Also:
-
CATEGORIES_BASED_COLUMN_CHOOSER_MENU_ITEM_ID
- See Also:
-
CLEAR_ALL_FILTERS_MENU_ITEM_ID
- See Also:
-
TOGGLE_FILTER_ROW_MENU_ITEM_ID
- See Also:
-
STATE_MANAGER_MENU_ITEM_ID
- See Also:
-
SEPARATOR_MENU_ITEM_ID
- See Also:
-
EXPORT_IMAGE_MENU_ITEM_ID
- Since:
- 1.5
- See Also:
-
CREATE_ROW_GROUP_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
RENAME_ROW_GROUP_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
REMOVE_ROW_GROUP_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
UNGROUP_ROWS_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
FREEZE_COLUMN_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
FREEZE_ROW_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
FREEZE_POSITION_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
UNFREEZE_MENU_ITEM_ID
- Since:
- 1.6
- See Also:
-
natTable
The active NatTable instance the context menu should be added to. Needed in advance to be able to add custom menu items that need the NatTable instance. -
popupMenu
protected org.eclipse.swt.widgets.Menu popupMenuTheMenu
that is created with this popup menu builder. -
visibility
Collection of all registered visibility state checkers for configured id's. -
enablement
Collection of all registered enablement state checkers for configured id's. -
parentBuilder
The parentPopupMenuBuilder
in case this instance is for building a submenu.- Since:
- 2.3
-
-
Constructor Details
-
PopupMenuBuilder
CreatesPopupMenuBuilder
that builds up a newMenu
that is only configurable with this instance ofPopupMenuBuilder
. Uses aMenuManager
internally to be able to configure visibility and enabled states.- Parameters:
parent
- The active NatTable instance the context menu should be added to.
-
PopupMenuBuilder
public PopupMenuBuilder(org.eclipse.jface.action.MenuManager manager) Creates aPopupMenuBuilder
that builds up a newMenu
using the givenMenuManager
.Note: If this constructor is used a
Menu
can only be created by usingbuild(NatTable)
, otherwise it will fail with an exception.- Parameters:
manager
- TheMenuManager
that should be used to create theMenu
.- Since:
- 1.6
-
PopupMenuBuilder
- Parameters:
parent
- The active NatTable instance the context menu should be added to.manager
- TheMenuManager
that should be used to create theMenu
.
-
PopupMenuBuilder
Creates a popup menu builder based on the given menu. Using this enables the possibility to use configured context menus from plugin.xml and adding NatTable commands programmatically.As an example you might want to create a PopupMenuBuilder by using a configured menu with the id org.eclipse.nebula.widgets.nattable.example.contextmenu
ISelectionProvider isp = new RowSelectionProvider<?>(selectionLayer, bodyDataProvider, false); MenuManager menuManager = new MenuManager(); menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); getSite().registerContextMenu( "org.eclipse.nebula.widgets.nattable.example.contextmenu", menuManager, isp); PopupMenuBuilder popupMenu = new PopupMenuBuilder(menuManager.createContextMenu(natTable));
For usage with Eclipse 4 you can use the
EMenuService
to register the menu to a NatTable instance. Afterwards get the menu and remove it from the NatTable to avoid the SWT control menu. The generated menu carries aMenuManager
in theWidget.getData()
which will be used within thisPopupMenuBuilder
.menuService.registerContextMenu(natTable, menuId); Menu swtMenu = natTable.getMenu(); natTable.setMenu(null);
- Parameters:
natTable
- The active NatTable instance which might be needed for creation of menu items that need the NatTable instance to work.menu
- The registered context menu.
-
-
Method Details
-
withContributionItem
public PopupMenuBuilder withContributionItem(org.eclipse.jface.action.ContributionItem contributionItem) Adds the menu item(s) provided by the givenContributionItem
to the popup menu. You can use this to add your own item to the popup menu.This method is only working if the
PopupMenuBuilder
is using aMenuManager
.Using this adds support for visibility and enabled states of menu items.
- Parameters:
contributionItem
- TheContributionItem
that is used to add a menu item to the menu.- Returns:
- The current
PopupMenuBuilder
with the added item. - Throws:
IllegalStateException
- if thisPopupMenuBuilder
does not use aMenuManager
-
withHideColumnMenuItem
Adds the menu item for hiding a column to the popup menu. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the hide column menu item added. - See Also:
-
withHideColumnMenuItem
Adds the menu item for hiding a column to the popup menu. Uses the given String as label for the menu item.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the hide column menu item added. - See Also:
-
withShowAllColumnsMenuItem
Adds the menu item for showing all columns to the popup menu. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the show all columns menu item added. - See Also:
-
withShowAllColumnsMenuItem
Adds the menu item for showing all columns to the popup menu. Uses the given String as label for the menu item.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the show all columns menu item added. - See Also:
-
withExportToImageMenuItem
Add the menu item for exporting to image to the popup menu. Use the default text localized in NatTable core resource bundles.IMPORTANT: the
ImageExporter
needs to be configured for the configuration attributeExportConfigAttributes.TABLE_EXPORTER
to really export to an image. Also theExportTableCommandHandler
needs to be registered on anILayer
in the layer stack, e.g. the GridLayer.- Returns:
- The
PopupMenuBuilder
with the export to image menu item added. - Since:
- 1.5
- See Also:
-
withExportToImageMenuItem
Add the menu item for exporting to image to the popup menu. Use the given String as label for the menu item.IMPORTANT: the
ImageExporter
needs to be configured for the configuration attributeExportConfigAttributes.TABLE_EXPORTER
to really export to an image. Also theExportTableCommandHandler
needs to be registered on anILayer
in the layer stack, e.g. the GridLayer.- Parameters:
menuLabel
- The label to use for exporting to image in the popup menu.- Returns:
- The
PopupMenuBuilder
with the exporting to image menu item added. - Since:
- 1.5
- See Also:
-
withHideRowMenuItem
Adds the menu item for hiding a row to the popup menu by using theRowHideCommand
. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the hide row menu item added. - See Also:
-
withHideRowMenuItem
Adds the menu item for hiding a row to the popup menu by using theRowHideCommand
. Uses the given String as label for the menu item.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the hide row menu item added. - See Also:
-
withHideRowPositionMenuItem
Adds the menu item for hiding a row to the popup menu by using theRowPositionHideCommand
. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the hide row menu item added. - Since:
- 1.6
- See Also:
-
withHideRowPositionMenuItem
Adds the menu item for hiding a row to the popup menu by using theRowPositionHideCommand
. Uses the given String as label for the menu item.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the hide row menu item added. - Since:
- 1.6
- See Also:
-
withShowAllRowsMenuItem
Adds the menu item for showing all rows to the popup menu. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the show all rows menu item added. - See Also:
-
withShowAllRowsMenuItem
Adds the menu item for showing all rows to the popup menu. Uses the given String as label for the menu item.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the show all rows menu item added. - See Also:
-
withAutoResizeSelectedColumnsMenuItem
Adds the menu item for auto resizing selected columns to the popup menu. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the resize selected columns menu item added. - See Also:
-
withAutoResizeSelectedColumnsMenuItem
Adds the menu item for auto resizing selected columns to the popup menu. Uses the given String as label for the menu item.- Returns:
- The
PopupMenuBuilder
with the resize selected columns menu item added. - See Also:
-
withAutoResizeSelectedRowsMenuItem
-
withAutoResizeSelectedRowsMenuItem
-
withColumnChooserMenuItem
-
withColumnChooserMenuItem
-
withColumnStyleEditor
-
withColumnStyleEditor
-
withColumnRenameDialog
-
withColumnRenameDialog
-
withCreateColumnGroupsMenuItem
-
withCreateColumnGroupsMenuItem
-
withCreateColumnGroupMenuItem
Adds the menu item for creating a column group with the new performance ColumnGroupHeaderLayer.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withCreateColumnGroupMenuItem
Adds the menu item for creating a column group with the new performance ColumnGroupHeaderLayer.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withUngroupColumnsMenuItem
-
withUngroupColumnsMenuItem
-
withRenameColumnGroupMenuItem
-
withRenameColumnGroupMenuItem
-
withRemoveColumnGroupMenuItem
-
withRemoveColumnGroupMenuItem
-
withCreateRowGroupMenuItem
Adds the menu item for creating a row group with the new performance RowGroupHeaderLayer.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withCreateRowGroupMenuItem
Adds the menu item for creating a row group with the new performance RowGroupHeaderLayer.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withUngroupRowsMenuItem
Adds the menu item for ungrouping selected rows from an existing row group.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withUngroupRowsMenuItem
Adds the menu item for ungrouping selected rows from an existing row group.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withRenameRowGroupMenuItem
Adds the menu item for renaming a row group.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withRenameRowGroupMenuItem
Adds the menu item for renaming a row group.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withRemoveRowGroupMenuItem
Adds the menu item for removing a row group.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withRemoveRowGroupMenuItem
Adds the menu item for removing a row group.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withFreezeColumnMenuItem
Adds the menu item for for freezing a grid at a given column position.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withFreezeColumnMenuItem
Adds the menu item for for freezing a grid at a given column position.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withFreezeRowMenuItem
Adds the menu item for for freezing a grid at a given row position.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withFreezeRowMenuItem
Adds the menu item for for freezing a grid at a given row position.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withFreezePositionMenuItem
Adds the menu item for freezing a grid at a given cell position. This menu item is intended to be used in a body menu.- Parameters:
include
- whether the selected cell should be included in the freeze region or not. Include means the freeze borders will be to the right and bottom, while exclude means the freeze borders are to the left and top.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withFreezePositionMenuItem
Adds the menu item for freezing a grid at a given cell position. This menu item is intended to be used in a body menu.- Parameters:
menuLabel
- The label to be used for showing the menu item.include
- whether the selected cell should be included in the freeze region or not. Include means the freeze borders will be to the right and bottom, while exclude means the freeze borders are to the left and top.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withUnfreezeMenuItem
Adds the menu item for removing a frozen state.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withUnfreezeMenuItem
Adds the menu item for removing a frozen state.- Parameters:
menuLabel
- The label to be used for showing the menu item.- Returns:
- This PopupMenuBuilder.
- Since:
- 1.6
-
withInspectLabelsMenuItem
-
withCategoriesBasedColumnChooser
-
withCategoriesBasedColumnChooser
-
withClearAllFilters
-
withClearAllFilters
-
withToggleFilterRow
Adds a menu item for toggling the visibility of the filter row. Uses the default text localized in NatTable core resource bundles.- Returns:
- The
PopupMenuBuilder
with the toggle filter row menu item added. - See Also:
-
withToggleFilterRow
Adds a menu item for toggling the visibility of the filter row. Uses the given String as label for the menu item.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the toggle filter row menu item added. - See Also:
-
withStateManagerMenuItemProvider
Adds the menu item for opening the view management dialog to the popup menu. Uses the default text localized in NatTable core resource bundles. Uses the given String as label for the menu item.- Returns:
- The
PopupMenuBuilder
with the menu item added for showing the view management dialog for managing NatTable states. - See Also:
-
withStateManagerMenuItemProvider
Adds the menu item for opening the view management dialog to the popup menu.- Parameters:
menuLabel
- The label to use for showing the item in the popup menu.- Returns:
- The
PopupMenuBuilder
with the menu item added for showing the view management dialog for managing NatTable states. - See Also:
-
withSeparator
Adds a separator to the popup menu.- Returns:
- The
PopupMenuBuilder
with an added separator. - See Also:
-
withSeparator
Adds a separator to the popup menu with the given id.- Parameters:
id
- The id to identify the separator. Necessary if there should be visibility constraints for specific separators.- Returns:
- The
PopupMenuBuilder
with an added separator. - See Also:
-
withSubMenu
Adds a submenu to the popup menu with the given label.- Parameters:
label
- The label to be used for the submenu.- Returns:
- the
PopupMenuBuilder
of the submenu. - Since:
- 2.3
- See Also:
-
withSubMenu
Adds a submenu to the popup menu with the given id and label.- Parameters:
id
- The id to identify the submenu. Necessary if there should be visibility constraints for specific submenus.label
- The label to be used for the submenu.- Returns:
- the
PopupMenuBuilder
of the submenu. - Since:
- 2.3
- See Also:
-
withSubMenu
public PopupMenuBuilder withSubMenu(String id, String label, org.eclipse.jface.resource.ImageDescriptor image) Adds a submenu to the popup menu with the given id, label and image.- Parameters:
id
- The id to identify the submenu. Necessary if there should be visibility constraints for specific submenus.label
- The label to be used for the submenu.image
- The image to be used for the submenu.- Returns:
- the
PopupMenuBuilder
of the submenu. - Since:
- 2.3
- See Also:
-
MenuManager(String, ImageDescriptor, String)
-
buildSubMenu
Build the submenu and return the parentPopupMenuBuilder
to implement the builder pattern.- Returns:
- The parent
PopupMenuBuilder
. - Since:
- 2.3
-
build
Sets the given NatTable to this builder and returns theMenuManager
that is used to create the context menu.Note: Calling this method only brings the builder to a working state. The creation of the
Menu
needs to be done using theMenuManager
. In this case the caller is also responsible for theMenu
disposal.- Parameters:
natTable
- The NatTable instance for which theMenu
should be created by using the returnedMenuManager
. Needed to make theIMenuItemProvider
work.- Returns:
- The
MenuManager
that is used by this builder. - Since:
- 1.6
-
build
public org.eclipse.swt.widgets.Menu build()Builds and returns the createdMenu
.Note: Calling this method will also add a
DisposeListener
to the NatTable instance to ensure the createdMenu
is disposed when the NatTable itself gets disposed.- Returns:
- The
Menu
that is created by this builder.
-
build
public org.eclipse.swt.widgets.Menu build(boolean diposeMenuManager) Builds and returns the createdMenu
.Note: Calling this method will also add a
DisposeListener
to the NatTable instance to ensure the createdMenu
is disposed when the NatTable itself gets disposed. Via thediposeMenuManager
parameter it is possible to configure if also the internally usedMenuManager
should be disposed or not.Note: Generally it is recommended to trigger the disposal of the
MenuManager
. Especially if submenus are created, as otherwise theMenuItem
of the submenu will not be disposed and causes resource leaks.- Parameters:
diposeMenuManager
-true
if the internally usedMenuManager
should be disposed,false
if not. Default isfalse
to avoid unintentionally disposing it.- Returns:
- The
Menu
that is created by this builder. - Since:
- 2.3
-
isEnabled
- Parameters:
contributionItemId
- The id of the menu item to check.- Returns:
true
if the menu item is enabled,false
if not.- Since:
- 2.3
- See Also:
-
isVisible
- Parameters:
contributionItemId
- The id of the menu item to check.- Returns:
true
if the menu item is visible,false
if not.- Since:
- 2.3
- See Also:
-
getNatEventData
Return theNatEventData
that is set to theMenu
created by thisPopupMenuBuilder
. For a sub menu theNatEventData
of the root parent menu is returned.- Returns:
- The
NatEventData
set to the createdMenu
. - Since:
- 2.3