|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder
public class PopupMenuBuilder
This class is used to create a context menu.
Nested Class Summary | |
---|---|
protected class |
PopupMenuBuilder.PopupContributionItem
Wrapper class to build up a ContributionItem based on a given
IMenuItemProvider . |
Constructor Summary | |
---|---|
PopupMenuBuilder(NatTable parent)
Creates PopupMenuBuilder that builds up a new Menu that
is only configurable with this instance of PopupMenuBuilder . |
|
PopupMenuBuilder(NatTable natTable,
org.eclipse.swt.widgets.Menu menu)
Creates a popup menu builder based on the given menu. |
|
PopupMenuBuilder(NatTable parent,
org.eclipse.jface.action.MenuManager manager)
Creates a PopupMenuBuilder that builds up a new Menu
using the given MenuManager . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String HIDE_COLUMN_MENU_ITEM_ID
public static final String SHOW_ALL_COLUMNS_MENU_ITEM_ID
public static final String HIDE_ROW_MENU_ITEM_ID
public static final String SHOW_ALL_ROWS_MENU_ITEM_ID
public static final String AUTO_RESIZE_COLUMN_MENU_ITEM_ID
public static final String AUTO_RESIZE_ROW_MENU_ITEM_ID
public static final String AUTO_RESIZE_ALL_SELECTED_COLUMN_MENU_ITEM_ID
public static final String COLUMN_CHOOSER_MENU_ITEM_ID
public static final String COLUMN_STYLE_EDITOR_MENU_ITEM_ID
public static final String COLUMN_RENAME_MENU_ITEM_ID
public static final String CREATE_COLUMN_GROUP_MENU_ITEM_ID
public static final String RENAME_COLUMN_GROUP_MENU_ITEM_ID
public static final String REMOVE_COLUMN_GROUP_MENU_ITEM_ID
public static final String UNGROUP_COLUMNS_MENU_ITEM_ID
public static final String INSPECT_LABEL_MENU_ITEM_ID
public static final String CATEGORIES_BASED_COLUMN_CHOOSER_MENU_ITEM_ID
public static final String CLEAR_ALL_FILTERS_MENU_ITEM_ID
public static final String TOGGLE_FILTER_ROW_MENU_ITEM_ID
public static final String STATE_MANAGER_MENU_ITEM_ID
public static final String SEPARATOR_MENU_ITEM_ID
protected NatTable natTable
protected org.eclipse.swt.widgets.Menu popupMenu
Menu
that is created with this popup menu builder.
protected org.eclipse.jface.action.MenuManager menuManager
MenuManager
that is used by this popup menu builder. Can be
null
if plain SWT menu mechanisms are used.
protected final MenuItemStateMap visibility
protected final MenuItemStateMap enablement
Constructor Detail |
---|
public PopupMenuBuilder(NatTable parent)
PopupMenuBuilder
that builds up a new Menu
that
is only configurable with this instance of PopupMenuBuilder
. Uses
a MenuManager
internally to be able to configure visibility and
enabled states.
parent
- The active NatTable instance the context menu should be added
to.public PopupMenuBuilder(NatTable parent, org.eclipse.jface.action.MenuManager manager)
PopupMenuBuilder
that builds up a new Menu
using the given MenuManager
.
parent
- The active NatTable instance the context menu should be added
to.manager
- The MenuManager
that should be used to create the
Menu
.public PopupMenuBuilder(NatTable natTable, org.eclipse.swt.widgets.Menu menu)
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 a MenuManager
in the Widget.getData()
which
will be used within this PopupMenuBuilder
.
menuService.registerContextMenu(natTable, menuId); Menu swtMenu = natTable.getMenu(); natTable.setMenu(null);
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 Detail |
---|
public PopupMenuBuilder withMenuItemProvider(IMenuItemProvider menuItemProvider)
IMenuItemProvider
to the
popup menu. You can use this to add your own item to the popup menu.
Items added by this method can not be identified by id, so adding visible or enabled state checkers is not possible for these providers.
menuItemProvider
- The IMenuItemProvider
that provides the menu item that
should be added to the popup menu.
PopupMenuBuilder
with the added item.public PopupMenuBuilder withMenuItemProvider(String id, IMenuItemProvider menuItemProvider)
IMenuItemProvider
to the
popup menu. You can use this to add your own item to the popup menu.
As items added by this method can be identified via the given id it is possible to register visible or enabled state checkers for these providers.
id
- The id under which the given IMenuItemProvider
should
be identifiable.menuItemProvider
- The IMenuItemProvider
that provides the menu item that
should be added to the popup menu.
PopupMenuBuilder
with the added item.public PopupMenuBuilder withContributionItem(org.eclipse.jface.action.ContributionItem contributionItem)
PopupMenuBuilder.PopupContributionItem
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 a
MenuManager
.
Using this adds support for visibility and enabled states of menu items.
contributionItem
- The PopupMenuBuilder.PopupContributionItem
that is used to add a menu item
to the menu.
PopupMenuBuilder
with the added item.
IllegalStateException
- if this PopupMenuBuilder
does not use a
MenuManager
public PopupMenuBuilder withHideColumnMenuItem()
PopupMenuBuilder
with the hide column menu item
added.MenuItemProviders.hideColumnMenuItemProvider()
public PopupMenuBuilder withHideColumnMenuItem(String menuLabel)
menuLabel
- The label to use for showing the item in the popup menu.
PopupMenuBuilder
with the hide column menu item
added.MenuItemProviders.hideColumnMenuItemProvider(String)
public PopupMenuBuilder withShowAllColumnsMenuItem()
PopupMenuBuilder
with the show all columns menu item
added.MenuItemProviders.showAllColumnsMenuItemProvider()
public PopupMenuBuilder withShowAllColumnsMenuItem(String menuLabel)
menuLabel
- The label to use for showing the item in the popup menu.
PopupMenuBuilder
with the show all columns menu item
added.MenuItemProviders.showAllColumnsMenuItemProvider(String)
public PopupMenuBuilder withHideRowMenuItem()
PopupMenuBuilder
with the hide row menu item added.MenuItemProviders.hideRowMenuItemProvider()
public PopupMenuBuilder withHideRowMenuItem(String menuLabel)
menuLabel
- The label to use for showing the item in the popup menu.
PopupMenuBuilder
with the hide row menu item added.MenuItemProviders.hideRowMenuItemProvider(String)
public PopupMenuBuilder withShowAllRowsMenuItem()
PopupMenuBuilder
with the show all rows menu item
added.MenuItemProviders.showAllRowsMenuItemProvider()
public PopupMenuBuilder withShowAllRowsMenuItem(String menuLabel)
menuLabel
- The label to use for showing the item in the popup menu.
PopupMenuBuilder
with the show all rows menu item
added.MenuItemProviders.showAllRowsMenuItemProvider(String)
public PopupMenuBuilder withAutoResizeSelectedColumnsMenuItem()
PopupMenuBuilder
with the resize selected columns
menu item added.MenuItemProviders.autoResizeColumnMenuItemProvider()
public PopupMenuBuilder withAutoResizeSelectedColumnsMenuItem(String menuLabel)
PopupMenuBuilder
with the resize selected columns
menu item added.MenuItemProviders.autoResizeColumnMenuItemProvider(String)
public PopupMenuBuilder withAutoResizeSelectedRowsMenuItem()
public PopupMenuBuilder withAutoResizeSelectedRowsMenuItem(String menuLabel)
public PopupMenuBuilder withColumnChooserMenuItem()
public PopupMenuBuilder withColumnChooserMenuItem(String menuLabel)
public PopupMenuBuilder withColumnStyleEditor()
public PopupMenuBuilder withColumnStyleEditor(String menuLabel)
public PopupMenuBuilder withColumnRenameDialog()
public PopupMenuBuilder withColumnRenameDialog(String menuLabel)
public PopupMenuBuilder withCreateColumnGroupsMenuItem()
public PopupMenuBuilder withCreateColumnGroupsMenuItem(String menuLabel)
public PopupMenuBuilder withUngroupColumnsMenuItem()
public PopupMenuBuilder withUngroupColumnsMenuItem(String menuLabel)
public PopupMenuBuilder withRenameColumnGroupMenuItem()
public PopupMenuBuilder withRenameColumnGroupMenuItem(String menuLabel)
public PopupMenuBuilder withRemoveColumnGroupMenuItem()
public PopupMenuBuilder withRemoveColumnGroupMenuItem(String menuLabel)
public PopupMenuBuilder withInspectLabelsMenuItem()
public PopupMenuBuilder withCategoriesBasedColumnChooser()
public PopupMenuBuilder withCategoriesBasedColumnChooser(String menuLabel)
public PopupMenuBuilder withClearAllFilters()
public PopupMenuBuilder withClearAllFilters(String menuLabel)
public PopupMenuBuilder withToggleFilterRow()
PopupMenuBuilder
with the toggle filter row menu item
added.MenuItemProviders.clearToggleFilterRowMenuItemProvider()
public PopupMenuBuilder withToggleFilterRow(String menuLabel)
menuLabel
- The label to use for showing the item in the popup menu.
PopupMenuBuilder
with the toggle filter row menu item
added.MenuItemProviders.clearToggleFilterRowMenuItemProvider(String)
public PopupMenuBuilder withStateManagerMenuItemProvider()
PopupMenuBuilder
with the menu item added for showing
the view management dialog for managing NatTable states.MenuItemProviders.stateManagerMenuItemProvider()
public PopupMenuBuilder withStateManagerMenuItemProvider(String menuLabel)
menuLabel
- The label to use for showing the item in the popup menu.
PopupMenuBuilder
with the menu item added for showing
the view management dialog for managing NatTable states.MenuItemProviders.stateManagerMenuItemProvider(String)
public PopupMenuBuilder withSeparator()
PopupMenuBuilder
with an added separator.MenuItemProviders.separatorMenuItemProvider()
public PopupMenuBuilder withSeparator(String id)
id
- The id to identify the separator. Necessary if there should be
visibility contraints for specific separators.
PopupMenuBuilder
with an added separator.MenuItemProviders.separatorMenuItemProvider()
public org.eclipse.swt.widgets.Menu build()
Menu
.
Note: Calling this method will also add a DisposeListener
to the NatTable instance to ensure the created Menu
is disposed
when the NatTable itself gets disposed.
Menu
that is created by this builder.public PopupMenuBuilder withVisibleState(String id, IMenuItemState state)
IMenuItemState
with the menu item
identified by the given id.
The visibility state is handled by the internal MenuManager
. If
no MenuManager
is used, this method will have not effect.
For the item to be visible, all associated IMenuItemState
must be
active OR no IMenuItemState
must be associated with the item.
id
- the registered IMenuItemState
will affect the menu
item identified by the given id.state
- the IMenuItemState
to queried for the visibility state
of the menu item with the given id.
PopupMenuBuilder
with the visible state checker for
the given id.public PopupMenuBuilder withEnabledState(String id, IMenuItemState state)
IMenuItemState
with the menu item identified
by the given id.
The enabled state is handled by the internal MenuManager
. If no
MenuManager
is used, this method will have not effect.
For the item to be enabled, all associated IMenuItemState
must be
active OR no IMenuItemState
must be associated with the item.
id
- the registered IMenuItemState
will affect the menu
item identified by the given id.state
- the IMenuItemState
to queried for the enabled state of
the menu item with the given id.
PopupMenuBuilder
with the enabled state checker for
the given id.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |