org.pietschy.command

Class MatchVisitor

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

Nested Class Summary

Nested classes/interfaces inherited from class org.pietschy.command.AbstractVisitor

AbstractVisitor.VisitMode

Field Summary

Fields inherited from class org.pietschy.command.AbstractVisitor

DEEP, SHALLOW, mode

Constructor Summary

MatchVisitor(CommandGroup groupToMatch, String faceName)
MatchVisitor(CommandGroup groupToMatch, String faceName, AbstractVisitor.VisitMode mode)

Method Summary

boolean
foundMatch()
CommandGroup
getMatchingGroup()
void
visit(ActionCommand command)
void
visit(CommandGroup group)

Methods inherited from class org.pietschy.command.AbstractVisitor

conditionallyVisitChildren, isParentGroup

Constructor Details

MatchVisitor

public MatchVisitor(CommandGroup groupToMatch,
                    String faceName)

MatchVisitor

public MatchVisitor(CommandGroup groupToMatch,
                    String faceName,
                    AbstractVisitor.VisitMode mode)

Method Details

foundMatch

public boolean foundMatch()

getMatchingGroup

public CommandGroup getMatchingGroup()

visit

public void visit(ActionCommand command)
Specified by:
visit in interface GroupVisitor

visit

public void visit(CommandGroup group)
Specified by:
visit in interface GroupVisitor