com.pietschy.command.group.impl
Class MemberManager

java.lang.Object
  extended by com.pietschy.command.group.impl.MemberManager
All Implemented Interfaces:
CommandContainerListener, java.util.EventListener

public class MemberManager
extends java.lang.Object
implements CommandContainerListener

Manages members on behalf of CommandGroup.


Field Summary
(package private) static java.lang.String _ID_
           
 
Constructor Summary
MemberManager(CommandGroup parent)
          Creates a new instance for the specified parent.
 
Method Summary
 void acceptVisitor(GroupVisitor visitor)
          Accepts the visitor to this managers members commands and groups.
(package private)  void acceptVisitor(Visitor<GroupMember> visitor)
          Accepts the visitor to this managers members.
(package private)  void add(GroupMember member)
          Adds the specified member to the manager.
 void addGroupListener(GroupListener l)
          Adds a GroupListener to the group.
(package private)  void applyExpansionPointBuilderChanges(java.util.ArrayList<Contribution> newContributions)
          Applies the changes made by the current expansion point builder.
(package private)  void applyGroupBuilderChanges(java.util.Collection<GroupMember> newMembers)
          Applies the changes made by the current group builder.
 void commandAdded(CommandContainerEvent e)
          CommandContainerListener implementation.
 void commandRemoved(CommandContainerEvent e)
          CommandContainerListener implementation.
 void containerPropertyChanged(java.beans.PropertyChangeEvent e)
          CommandContainerListener implementation.
(package private)  void discardGroupBuilder()
          Discards the current group builder.
(package private)  void fireMembersChanged()
          Notifies all group listeners that this managers contents has changed.
 GroupBuilder getBuilder()
          Gets the current builder instance.
(package private)  CommandContainer getCommandContainer()
          Returns the CommandContainer this manager is to use.
(package private)  java.util.List<Contribution> getContributions()
          Get all the expansion point contributions of this manager.
 ExpansionPointBuilder getExpansionPointBuilder()
          Gets the current expansion point builder.
 int getMemberCount()
          Gets the number of realised memebers in the group.
(package private)  GroupMember getMemberFor(java.lang.String id)
          Gets the member that represents the command with the specified id.
(package private)  java.util.Collection<GroupMember> getMembers()
          Gets all the members of this manager.
(package private)  void installContributions()
          Iterates over the current expansion point contributions and installs them.
 java.util.Iterator<GroupMember> iterator()
          Returns an iterator over this managers members.
(package private)  void notifyParentHeirarchyChangedAndRebuild()
          Notifies all members that the container hierarchy has changed, rebuilds all the group containers and notifies any listeners that our membership has changed.
 void parentHierarchyChanged(CommandContainerEvent e)
          CommandContainerListener implementation.
 void populateContainer(javax.swing.JComponent container, ButtonFactory factory, java.lang.String context)
          Populates the specified container with buttons for each group member.
 void populateContainer(javax.swing.JComponent container, MenuFactory factory, java.lang.String context)
          Populates the specified container with a menu item for each group member.
protected  void rebuildContainersAndNotifyListeners()
          Invoked whenever this groups membership changes.
(package private)  void remove(GroupMember member)
          Removes the specified member from the manager.
 void removeGroupListener(GroupListener l)
          Removes a GroupListener from the group.
(package private)  void resetDynamicMember(java.lang.String id)
          Finds the DynamicMember for the specified command and resets it.
 void setCommandContainer(CommandContainer commandContainer)
          Sets the CommandContainer this manager is to use.
 java.lang.String toString()
          Returns a string representation of this manager.
(package private)  void uninstallContributions()
          Iterates over the current expansion point contributions and uninstalls them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_ID_

static final java.lang.String _ID_
See Also:
Constant Field Values
Constructor Detail

MemberManager

public MemberManager(CommandGroup parent)
Creates a new instance for the specified parent.

Parameters:
parent - the parent group.
Method Detail

getCommandContainer

CommandContainer getCommandContainer()
Returns the CommandContainer this manager is to use. May be null.

Returns:
the CommandContainer this manager is to use.

setCommandContainer

public void setCommandContainer(CommandContainer commandContainer)
Sets the CommandContainer this manager is to use. May be null.

Parameters:
commandContainer - the container this manager is to use.

getBuilder

public GroupBuilder getBuilder()
Gets the current builder instance. If there is no builder a new instance is created and returned.

Returns:
the current builder instance.

getExpansionPointBuilder

public ExpansionPointBuilder getExpansionPointBuilder()
Gets the current expansion point builder. If there is no builder a new instance is created and returned.

Returns:
the current expansion point builder.

populateContainer

public void populateContainer(javax.swing.JComponent container,
                              MenuFactory factory,
                              java.lang.String context)
Populates the specified container with a menu item for each group member. From this point on the manager will ensure the container remains in sync with the group membership changes.

Parameters:
container - the container to hold the groups members.
factory - the menu factory to use.
context - the face context to use.

populateContainer

public void populateContainer(javax.swing.JComponent container,
                              ButtonFactory factory,
                              java.lang.String context)
Populates the specified container with buttons for each group member. From this point on the manager will ensure the container remains in sync with the group membership changes.

Parameters:
container - the container to hold the groups members.
factory - the button factory to use.
context - the face context to use.

rebuildContainersAndNotifyListeners

protected void rebuildContainersAndNotifyListeners()
Invoked whenever this groups membership changes. It rebuilds all containers and notifies listeners of the change.


commandAdded

public void commandAdded(CommandContainerEvent e)
CommandContainerListener implementation.

Specified by:
commandAdded in interface CommandContainerListener
Parameters:
e - the event

commandRemoved

public void commandRemoved(CommandContainerEvent e)
CommandContainerListener implementation.

Specified by:
commandRemoved in interface CommandContainerListener
Parameters:
e - the event

resetDynamicMember

void resetDynamicMember(java.lang.String id)
Finds the DynamicMember for the specified command and resets it.

Parameters:
id - the command that changed.

parentHierarchyChanged

public void parentHierarchyChanged(CommandContainerEvent e)
CommandContainerListener implementation.

Specified by:
parentHierarchyChanged in interface CommandContainerListener
Parameters:
e - the event

containerPropertyChanged

public void containerPropertyChanged(java.beans.PropertyChangeEvent e)
CommandContainerListener implementation.

Specified by:
containerPropertyChanged in interface CommandContainerListener
Parameters:
e - the event

notifyParentHeirarchyChangedAndRebuild

void notifyParentHeirarchyChangedAndRebuild()
Notifies all members that the container hierarchy has changed, rebuilds all the group containers and notifies any listeners that our membership has changed.


add

void add(GroupMember member)
Adds the specified member to the manager.

Parameters:
member - the member to add.

remove

void remove(GroupMember member)
Removes the specified member from the manager.

Parameters:
member - the member to remove.

getMembers

java.util.Collection<GroupMember> getMembers()
Gets all the members of this manager.

Returns:
all the members of this manager.

getContributions

java.util.List<Contribution> getContributions()
Get all the expansion point contributions of this manager.

Returns:
all the expansion point contributions of this manager.

iterator

public java.util.Iterator<GroupMember> iterator()
Returns an iterator over this managers members.

Returns:
an iterator over this managers members.

acceptVisitor

void acceptVisitor(Visitor<GroupMember> visitor)
Accepts the visitor to this managers members.

Parameters:
visitor - the visitor.

acceptVisitor

public void acceptVisitor(GroupVisitor visitor)
Accepts the visitor to this managers members commands and groups.

Parameters:
visitor - the visitor.

getMemberCount

public int getMemberCount()
Gets the number of realised memebers in the group.

Returns:
the number of realised members in the group.

getMemberFor

GroupMember getMemberFor(java.lang.String id)
Gets the member that represents the command with the specified id.

Parameters:
id - the command id.
Returns:
the member for the specified command id.

addGroupListener

public void addGroupListener(GroupListener l)
Adds a GroupListener to the group.

Parameters:
l - the listener to installFace.

removeGroupListener

public void removeGroupListener(GroupListener l)
Removes a GroupListener from the group.

Parameters:
l - the listener to remove.

fireMembersChanged

void fireMembersChanged()
Notifies all group listeners that this managers contents has changed.


applyGroupBuilderChanges

void applyGroupBuilderChanges(java.util.Collection<GroupMember> newMembers)
Applies the changes made by the current group builder.

Parameters:
newMembers - the new member list.

discardGroupBuilder

void discardGroupBuilder()
Discards the current group builder.


applyExpansionPointBuilderChanges

void applyExpansionPointBuilderChanges(java.util.ArrayList<Contribution> newContributions)
Applies the changes made by the current expansion point builder.

Parameters:
newContributions - the new contribution list.

installContributions

void installContributions()
Iterates over the current expansion point contributions and installs them.


uninstallContributions

void uninstallContributions()
Iterates over the current expansion point contributions and uninstalls them.


toString

public java.lang.String toString()
Returns a string representation of this manager.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this manager.


Copyright © 2006 - 2007 Andrew Pietsch