org.pietschy.command
Class MatchVisitor

java.lang.Object
  extended by org.pietschy.command.AbstractVisitor
      extended by 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

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, mode, SHALLOW
 
Constructor Summary
MatchVisitor(CommandGroup groupToMatch, java.lang.String faceName)
           
MatchVisitor(CommandGroup groupToMatch, java.lang.String faceName, AbstractVisitor.VisitMode mode)
           
 
Method Summary
 boolean foundMatch()
           
 CommandGroup getMatchingGroup()
           
 void visit(ActionCommand command)
          Called to visit a ActionCommand member of a CommandGroup.
 void visit(CommandGroup group)
          Called to visit a CommandGroup member of a CommandGroup.
 
Methods inherited from class org.pietschy.command.AbstractVisitor
conditionallyVisitChildren, isParentGroup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatchVisitor

public MatchVisitor(CommandGroup groupToMatch,
                    java.lang.String faceName)

MatchVisitor

public MatchVisitor(CommandGroup groupToMatch,
                    java.lang.String faceName,
                    AbstractVisitor.VisitMode mode)
Method Detail

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()