public interface ExtensionPopupMenuComponent
MainPopupMenu
) with
enhanced behaviour (compared to JMenu
s and JMenuItem
s).
The menu component will be queried:
Component
where the pop up menu is being
invoked, by calling isEnableForComponent(Component)
;
MessageContainer
where the pop up menu is
being invoked, by calling isEnableForMessageContainer(MessageContainer)
;
Control.Mode
doesn't allow potential dangerous operations, by calling
isSafe()
;
getMenuIndex()
.
precedeWithSeparator()
and succeedWithSeparator()
, respectively.
The menu component will be notified when no longer shown (i.e. the pop up menu was dismissed)
by calling dismissed(ExtensionPopupMenuComponent)
, so it can free any resources (e.g.
clean any references to UI components).
ExtensionPopupMenu
,
ExtensionPopupMenuItem
,
MainPopupMenu
,
Control.Mode
,
MessageContainer
Modifier and Type | Method and Description |
---|---|
void |
dismissed(ExtensionPopupMenuComponent selectedMenuComponent)
Called after the pop up menu in which this pop up menu component is is dismissed, indicating
the menu component that was selected or
null if none. |
int |
getMenuIndex()
Returns the position that the pop up menu component should occupy in the pop up menu.
|
boolean |
isEnableForComponent(Component invoker)
Tells whether or not the pop up menu component is enable for the given
invoker ,
therefore shown (or not) in the pop up menu. |
boolean |
isEnableForMessageContainer(MessageContainer<?> invoker)
Tells whether or not the pop up menu component is enable for the given
invoker ,
therefore shown (or not) in the pop up menu. |
boolean |
isSafe()
Tells whether or not the pop up menu component is safe, that is, doesn't do any potentially
dangerous operations (for example, active scan a target server).
|
boolean |
precedeWithSeparator()
Tells whether or not the pop up menu component should be preceded with a separator.
|
boolean |
succeedWithSeparator()
Tells whether or not the pop up menu component should be succeeded with a separator.
|
boolean isEnableForComponent(Component invoker)
invoker
,
therefore shown (or not) in the pop up menu.
It is responsibility of the pop up menu component to enable/disable itself in case it should be shown but shouldn't be active/enabled.
Note: Calling this method implies that the pop up menu in which this pop up menu component is, is being invoked.
invoker
- the component where the pop up menu was invokedtrue
if the menu component is enable for the given invoker
, false
otherwise.isEnableForMessageContainer(MessageContainer)
boolean isEnableForMessageContainer(MessageContainer<?> invoker)
invoker
,
therefore shown (or not) in the pop up menu.
It is responsibility of the pop up menu component to enable/disable itself in case it should be shown but shouldn't be active/enabled.
Note: Calling this method implies that the pop up menu in which this pop up menu component is, is being invoked.
invoker
- the message container where the pop up menu was invokedtrue
if the menu component is enable for the given invoker
, false
otherwise.isEnableForComponent(Component)
int getMenuIndex()
boolean precedeWithSeparator()
true
if the menu component should be preceded with a separator, false
otherwise.JPopupMenu.Separator
boolean succeedWithSeparator()
true
if the menu component should be succeeded with a separator, false
otherwise.JPopupMenu.Separator
boolean isSafe()
The pop up menu component will be automatically disabled when it is not safe and the
Control.Mode
set doesn't allow potentially dangerous operations.
true
if the menu component is safe, false
otherwise.Control.Mode
void dismissed(ExtensionPopupMenuComponent selectedMenuComponent)
null
if none.
Can be used to free any resources no longer needed (e.g. references to UI components) after being shown in the pop up menu.
Note 1: Any resource needed to execute the action should only be freed in this method if the menu was not selected. If it was selected the resources should only be freed after executing the action.
Note 2: This method will not be called if this pop up menu component is
not enabled for the invoker
.
selectedMenuComponent
- the selected menu component or null
if noneisEnableForComponent(Component)
,
isEnableForMessageContainer(MessageContainer)