Class IzMenu
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- IzMenu- (IzMenuItem parent) Constructor for cascaded menu.Constructor for menu on a Control.
- Method SummaryModifier and TypeMethodDescriptionAdds a menu item.Adds a menu item.Adds a submenu as a "contribution".Adds a menu item as a "push button".Adds a menu item as a "push button".Adds an action as a menu item to this menu.Adds all items that must be either instance of IAction of IzSubMenu, or null entries for separators.- addMenuListener- (Runnable menuListener) Sets the listener when the menu is about to be shown.Adds a separator to the menu.- clear()Removes all menu items so as to clear the menu.- void- dispose()Disposes of the menu.- static IzMenu- fromControl- (Control control) Gets the pop-up menu associated with a component.Gets the control for which the menu was created for.- getItem- (int index) Gets a menu item at index.- intReturns the number of items contained in the receiver.- getItems()Returns a (possibly empty) array of- MenuItems which are the items in the receiver.- booleanReturns if there are any enabled menu items to show.- booleanReturns if the menu is disposed.- booleanReturns- trueif the receiver is enabled and all of the receiver's ancestors are enabled, and- falseotherwise.- booleanReturns if the menu is currently displaying.Set the disabled menu item omitting when displaying the menu.- void- setEnabled- (boolean enabled) Enables the receiver if the argument is- true, and disables it otherwise.- void- setLocation- (int x, int y) Sets the location of the receiver, which must be a popup, to the point specified by the arguments which are relative to the display.- void- setLocation- (Point location) Sets the location of the receiver, which must be a popup, to the point specified by the argument which is relative to the display.Assigns the menu to the control.- void- setVisible- (boolean visible) Marks the receiver as visible if the argument is- true, and marks it invisible otherwise.
- Constructor Details- IzMenuConstructor for menu on a Control.- Parameters:
- parent- The control parent.
 
- IzMenuConstructor for cascaded menu.- Parameters:
- parent- The menu item parent.
 
 
- Method Details- fromControlGets the pop-up menu associated with a component. The parents are searched for the menu if not found.- Parameters:
- control- The control.
- Returns:
- The IzMenu associated with the control (to display), null if not found.
 
- clearRemoves all menu items so as to clear the menu. This call can be done during the call to the menu listener fired before the menu is shown.- Returns:
- thisin order to be able to concatenate calls.
 
- getControlGets the control for which the menu was created for.- Returns:
- The control, or null for cascaded menus.
 
- setMenuAssigns the menu to the control. It must be the same control as the parent. When the right button (SWT.MenuDetect) is pressed, the menu is shown.- Parameters:
- parent- The control parent.
- alignBottomLeft- Flag to align bottom left on control when mouse button 2 is pressed.
- Returns:
- thisin order to be able to concatenate calls.
- Throws:
- IllegalArgumentException- If the menu is set to another control than it's parent.
 
- disposepublic void dispose()Disposes of the menu.
- isDisposedpublic boolean isDisposed()Returns if the menu is disposed.
- getItemCountpublic int getItemCount()Returns the number of items contained in the receiver.- Returns:
- the number of items.
 
- getItemGets a menu item at index.- Parameters:
- index- The index.
- Returns:
- The menu item.
- Throws:
- IndexOutOfBoundsException- If range is wrong.
 
- getItemsReturns a (possibly empty) array of- MenuItems which are the items in the receiver.- Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver. - Returns:
- the items in the receiver.
 
- setLocationpublic void setLocation- (int x, int y) Sets the location of the receiver, which must be a popup, to the point specified by the arguments which are relative to the display.- Note that this is different from most widgets where the location of the widget is relative to the parent. - Note that the platform window manager ultimately has control over the location of popup menus. - Parameters:
- x- the new x coordinate for the receiver
- y- the new y coordinate for the receiver
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- setLocationSets the location of the receiver, which must be a popup, to the point specified by the argument which is relative to the display.- Note that this is different from most widgets where the location of the widget is relative to the parent. - Note that the platform window manager ultimately has control over the location of popup menus. - Parameters:
- location- the new location for the receiver
- Throws:
- NullPointerException- If location is null.
 
- setEnabledpublic void setEnabled- (boolean enabled) Enables the receiver if the argument is- true, and disables it otherwise. A disabled menu is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Parameters:
- enabled- the new enabled state
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- isEnabledpublic boolean isEnabled()Returns- trueif the receiver is enabled and all of the receiver's ancestors are enabled, and- falseotherwise. A disabled menu is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled state
 
- setVisiblepublic void setVisible- (boolean visible) Marks the receiver as visible if the argument is- true, and marks it invisible otherwise.- If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed. - Parameters:
- visible- the new visibility state
- Throws:
- SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
 
 
- isVisiblepublic boolean isVisible()Returns if the menu is currently displaying.- Returns:
- true when visible, false when not visible or a cascaded menu.
 
- omitDisabledSet the disabled menu item omitting when displaying the menu.- Returns:
- thisin order to be able to concatenate calls.
 
- hasEnabledItemspublic boolean hasEnabledItems()Returns if there are any enabled menu items to show.- Returns:
- false for separator, disabled menu item. Cascaded menu are also checked.
 
- addMenuListenerSets the listener when the menu is about to be shown. Menu states can then be processed.- Parameters:
- menuListener- The runnable that will be called prior to displaying the menu.
- Returns:
- thisin order to be able to concatenate calls.
 
- addSeparatorAdds a separator to the menu.- Returns:
- thisin order to be able to concatenate calls.
 
- addAdds an action as a menu item to this menu.- Parameters:
- action- The action to add.
- Returns:
- thisin order to be able to concatenate calls.
 
- addAdds a menu item as a "push button".- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- text- The text, null for none.
- selectionListener- The selection listener or null for none.
- Returns:
- thisin order to be able to concatenate calls.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- addAdds a menu item as a "push button".- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- text- The text, null for none.
- image- The image, null for none.
- selectionListener- The selection listener or null for none.
- Returns:
- thisin order to be able to concatenate calls.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- addAdds a menu item.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- style- The menu item style.
- text- The text, null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- addAdds a menu item.- NOTE: supported styles: SWT.SEPARATOR, SWT.PUSH, SWT.CHECK, SWT.RADIO and SWT.CASCADE: NO OTHER! - Parameters:
- style- The menu item style.
- text- The text, null for none.
- image- The image, null for none.
- Throws:
- IllegalArgumentException- For invalid styles.
 
- addAdds a submenu as a "contribution".- Parameters:
- subMenu- The submenu.
- Returns:
- The thisinstance for concatenation.
 
- addItemsAdds all items that must be either instance of IAction of IzSubMenu, or null entries for separators. An item can also be an Object [] in which case the addItems(objectArray) will be called.- Parameters:
- items- The items.
- Returns:
- The thisinstance for concatenation.