org.pietschy.command
Class MatchVisitor
- GroupVisitor
public class MatchVisitor
This class implements a visitor that will search the children of a group to find a group with the same
textural value. This visitor is typically used when embedding plugin menus into the main menu heirarchy.
For Example:
private void installMenu(GroupCommand pluginMenu)
{
// reset all the menus back to their default state
mainMenuGroup.visit(new ResetVisitor(ResetVisitor.SHALLOW));
// try and find an existing menu that has the same name as
// the menu being added
MatchVisitor visitor = new MatchVisitor(pluginMenu, Face.MENU, MatchVisitor.SHALLOW);
mainMenuGroup.visit(visitor);
// if we found one, installFace the menu to it, otherwise installFace it to the main menu
if (visitor.foundMatch())
visitor.getMatchingGroup().addInline(pluginMenu);
else
mainMenuGroup.installFace(pluginMenu);
}
MatchVisitor
public MatchVisitor(CommandGroup groupToMatch,
String faceName)
foundMatch
public boolean foundMatch()