com.levigo.util.swing.menu
Class AbstractSubmenuContributor

java.lang.Object
  extended by com.levigo.util.swing.menu.AbstractSubmenuContributor
All Implemented Interfaces:
MenuContributor
Direct Known Subclasses:
ActionFactoryMenuContributor, AnnotationVisibilityMenuContributor, EmbeddedAnnotationVisibilityMenuContributor

public abstract class AbstractSubmenuContributor
extends Object
implements MenuContributor

Abstract 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.


Field Summary
protected  Logger log
           
 
Constructor Summary
AbstractSubmenuContributor()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final Logger log
Constructor Detail

AbstractSubmenuContributor

public AbstractSubmenuContributor()
Method Detail

setTargetSubmenu

public void setTargetSubmenu(String id)
Specifies the 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.

Parameters:
id - the id of the submenu which shall be reused.
Throws:
IllegalArgumentException - if id is null

setTargetSubmenu

public void setTargetSubmenu(String group,
                             String id,
                             Action action)
Specifies the 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.

Parameters:
group - the group to which the submenu should be added
id - 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)
Throws:
IllegalArgumentException - if id is null

contribute

public void contribute(ContributionContext context,
                       MenuBuilder menuBuilder)
Description copied from interface: MenuContributor
This method is called in order to give the menu contributor a chance to contribute context menu entries via the supplied MenuBuilder.

Specified by:
contribute in interface MenuContributor
Parameters:
context - the ContributionContext which provides contribution context informations
menuBuilder - the MenuBuilder to which the tool may contribute entries.

doContribute

protected abstract void doContribute(ContributionContext context,
                                     MenuBuilder target)
Parameters:
context -
target -


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.