org.pietschy.command
Class MatchVisitor
java.lang.Object
org.pietschy.command.AbstractVisitor
org.pietschy.command.MatchVisitor
- All Implemented Interfaces:
- GroupVisitor
public class MatchVisitor
- extends AbstractVisitor
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);
}
- Version:
- $Revision: 1.6 $
- Author:
- andrewp
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MatchVisitor
public MatchVisitor(CommandGroup groupToMatch,
java.lang.String faceName)
MatchVisitor
public MatchVisitor(CommandGroup groupToMatch,
java.lang.String faceName,
AbstractVisitor.VisitMode mode)
visit
public void visit(ActionCommand command)
- Description copied from interface:
GroupVisitor
- Called to visit a
ActionCommand
member of a CommandGroup
.
- Parameters:
command
- the member being visited.
visit
public void visit(CommandGroup group)
- Description copied from interface:
GroupVisitor
- Called to visit a
CommandGroup
member of a CommandGroup
.
- Parameters:
group
- the member being visited.
foundMatch
public boolean foundMatch()
getMatchingGroup
public CommandGroup getMatchingGroup()