public abstract class AbstractSubmenuContributor extends Object implements MenuContributor
MenuContributor
which adds contributions to a
submenu
. Implementations have to
implement the Method doContribute(ContributionContext, MenuBuilder)
which will be called
with the appropriate submenu MenuBuilder
.
If neither setTargetSubmenu(String)
or setTargetSubmenu(String, String, Action)
have been called, no submenu will be created instead the default main menu will be used.
Constructor and Description |
---|
AbstractSubmenuContributor() |
Modifier and Type | Method and Description |
---|---|
void |
contribute(ContributionContext context,
MenuBuilder menuBuilder)
This method is called in order to give the menu contributor a chance to contribute context menu
entries via the supplied
MenuBuilder . |
protected abstract void |
doContribute(ContributionContext context,
MenuBuilder target) |
void |
setTargetSubmenu(String id)
Specifies the
submenu into which shall be used as the
base. |
void |
setTargetSubmenu(String group,
String id,
Action action)
Specifies the
submenu into which shall be used as the
base. |
protected final Logger log
public void setTargetSubmenu(String id)
submenu
into which shall be used as the
base. If a submenu with the given id has not been found,
doContribute(ContributionContext, MenuBuilder)
will not be called and a
warning
is logged.id
- the id of the submenu which shall be reused.IllegalArgumentException
- if id
is nullpublic void setTargetSubmenu(String group, String id, Action action)
submenu
into which shall be used as the
base. If the submenu doesn't exist and an Action
has been specified, the submenu will
be created. If the Action
is null and the submenu has not been found,
doContribute(ContributionContext, MenuBuilder)
will not be called and a
warning
is logged.
Please not that even if an Action
and group
has been specified, this
implementation will fist check whether a group with the given id
exists and only
if it doesn't create a new one.
group
- the group to which the submenu should be addedid
- the id of the submenu.action
- the action that shall be used to define the submenu (will be used primarily to
extract the name and icon of the submenu)IllegalArgumentException
- if id
is nullpublic void contribute(ContributionContext context, MenuBuilder menuBuilder)
MenuContributor
MenuBuilder
.contribute
in interface MenuContributor
context
- the ContributionContext
which provides contribution context informationsmenuBuilder
- the MenuBuilder
to which the tool may contribute entries.protected abstract void doContribute(ContributionContext context, MenuBuilder target)
context
- target
- Copyright © 2024 levigo holding gmbh. All rights reserved.