com.pietschy.command.group.impl
Class DynamicMember

java.lang.Object
  extended by com.pietschy.command.group.impl.AbstractGroupMember
      extended by com.pietschy.command.group.impl.DynamicMember
All Implemented Interfaces:
GroupMember
Direct Known Subclasses:
DebugDynamicMember

public class DynamicMember
extends AbstractGroupMember

Dynamic members are used handle commands and groups that are specified only by their id. This means all members loaded from configuration files are managed by dynamic members.

Dynamic members continually monitor the command container hierarchy and update accordingly.

When the actual member is located that task of managing it is delegated to instances of StaticMember and InlineMember.


Constructor Summary
DynamicMember(CommandGroup parent, java.lang.String commandId, boolean inlineGroup)
          Creates a new member for the group with the specified id.
 
Method Summary
 void acceptVisitor(GroupVisitor visitor)
          Accepts a visitor to the members command or commands.
 int addComponentTo(javax.swing.JComponent container, Factory factory, java.lang.String defaultFaceId, java.util.List<java.awt.Component> previousComponents, int buttonIndex)
          Invoked to add this members content to the specified component.
 void addNotify()
          Invoked to notify that this member has been added to its parent group.
 java.lang.Object getId()
          Gets this members id.
(package private)  GroupMember getRealGroupMember()
           
(package private)  boolean isAddedToParent()
          Checks if the member has already been added to it's parent group.
(package private)  boolean isInline()
          Checks if this member represents an inline group.
 boolean isMemberFor(java.lang.String id)
          Checks if this member represents the command with the specified id.
(package private)  GroupMember lookupRealMember(CommandGroup parentGroup, java.lang.String commandId)
          Attempts to retreive the command that this member represents.
 void notifyCommandContainerHierarchyChanged()
          Clears the current member and causes it to scan the container hierarchy again.
 void removeNotify()
          Invoked to notify that this member has been removed from its parent group.
 boolean reset()
          Returns true if the member changed as a result of the reset.
protected  boolean resolved()
          Ensures this members command has been resolved from the container hierarchy.
 int size()
          Returns the size of this member.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class com.pietschy.command.group.impl.AbstractGroupMember
addChangeListener, fireChanged, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DynamicMember

public DynamicMember(CommandGroup parent,
                     java.lang.String commandId,
                     boolean inlineGroup)
Creates a new member for the group with the specified id.

Parameters:
parent - the parent group.
commandId - the command id to track and add
inlineGroup - true if the group is to be inlined, false otherwise.
Method Detail

getId

public java.lang.Object getId()
Description copied from interface: GroupMember
Gets this members id. This is typcially the id of the command the member represents.

Returns:
this members id.

getRealGroupMember

GroupMember getRealGroupMember()

addComponentTo

public int addComponentTo(javax.swing.JComponent container,
                          Factory factory,
                          java.lang.String defaultFaceId,
                          java.util.List<java.awt.Component> previousComponents,
                          int buttonIndex)
Description copied from interface: GroupMember
Invoked to add this members content to the specified component.

Parameters:
container - the component to add the component to.
factory - the factory to be used, either a ButtonFactory or MenuFactory.
defaultFaceId - the context to use when adding the component.
previousComponents - the list of previsous components built by the parent. The member should reuse and components in preference to creating new ones.
buttonIndex - the index that of the member in the parent group.
Returns:
the number of components added by this member.

resolved

protected boolean resolved()
Ensures this members command has been resolved from the container hierarchy.

Returns:
true if this member has been resolved and has a command to insert, false if no command has been located.

lookupRealMember

GroupMember lookupRealMember(CommandGroup parentGroup,
                             java.lang.String commandId)
Attempts to retreive the command that this member represents.

Parameters:
parentGroup - the parent group.
commandId - the command id to locate.
Returns:
the Command this member respresents, or null if it isn't available.

isMemberFor

public boolean isMemberFor(java.lang.String id)
Description copied from interface: GroupMember
Checks if this member represents the command with the specified id.

Parameters:
id - the command id.
Returns:
true if this member represents the specified command, false otherwise.

isInline

boolean isInline()
Checks if this member represents an inline group.

Returns:
true if this member represents an inline group, false otherwise.

isAddedToParent

boolean isAddedToParent()
Checks if the member has already been added to it's parent group.

Returns:
true if this member has already been added to its parent group, false otherwise.

notifyCommandContainerHierarchyChanged

public void notifyCommandContainerHierarchyChanged()
Clears the current member and causes it to scan the container hierarchy again.

Specified by:
notifyCommandContainerHierarchyChanged in interface GroupMember
Overrides:
notifyCommandContainerHierarchyChanged in class AbstractGroupMember

reset

public boolean reset()
Returns true if the member changed as a result of the reset.

Returns:
true;

size

public int size()
Returns the size of this member. If !resolved() this method returns 0, if isInline() it returns the size of the inlined group, otherwise it returns 1.

Returns:
the size of the member.

acceptVisitor

public void acceptVisitor(GroupVisitor visitor)
Description copied from interface: GroupMember
Accepts a visitor to the members command or commands.

Parameters:
visitor - the visitor.

addNotify

public void addNotify()
Description copied from interface: GroupMember
Invoked to notify that this member has been added to its parent group.


removeNotify

public void removeNotify()
Description copied from interface: GroupMember
Invoked to notify that this member has been removed from its parent group.


toString

public java.lang.String toString()
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.


Copyright © 2006 - 2007 Andrew Pietsch