com.pietschy.command.group.impl
Class AbstractExpansionPointBuilder

java.lang.Object
  extended by com.pietschy.command.group.impl.AbstractExpansionPointBuilder
All Implemented Interfaces:
ExpansionPointBuilder

public abstract class AbstractExpansionPointBuilder
extends java.lang.Object
implements ExpansionPointBuilder

Implementation of ExpansionPointBuilder. This class handles most of the builder functionality, sub classes must override applyChanges() and ExpansionPointBuilder.discard() to enact the builder changes.


Constructor Summary
AbstractExpansionPointBuilder(java.util.List<Contribution> contributions)
          Creates a new instance that is initialised with the specified contributions.
 
Method Summary
 void add(ActionCommand command)
          Adds the specified command to the expansion point.
 void add(CommandGroup group)
          Adds the specified group to the expansion point.
 void addEmbedded(CommandGroup group, java.util.Comparator<CommandGroup> comparator)
          Adds the specified group as an embedded member of the parent group.
 void addEmbedded(CommandGroup group, java.lang.String context)
          Adds the specified group as an embedded member of the parent group.
 void addInline(CommandGroup group)
          Adds the specified group as an inline member of the expansion point.
 void applyChanges()
          Applies the current builder state to the group and discards the builder.
protected abstract  void applyChanges(java.util.ArrayList<Contribution> contributions)
          Invoked to apply the specified contribution list to the group.
 void clear()
          Clears the expansion point.
 void remove(ActionCommand command)
          Removes the specified command from the expansion point.
 void remove(CommandGroup command)
          Removes the specified group from the expansion point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.pietschy.command.group.ExpansionPointBuilder
discard
 

Constructor Detail

AbstractExpansionPointBuilder

public AbstractExpansionPointBuilder(java.util.List<Contribution> contributions)
Creates a new instance that is initialised with the specified contributions.

Parameters:
contributions - the existing expansion point members.
Method Detail

add

public void add(ActionCommand command)
Description copied from interface: ExpansionPointBuilder
Adds the specified command to the expansion point. The command can be anonymous and does not need to be bound.

Specified by:
add in interface ExpansionPointBuilder
Parameters:
command - the command to add.

add

public void add(CommandGroup group)
Description copied from interface: ExpansionPointBuilder
Adds the specified group to the expansion point. The group can be anonymous and does not need to be bound.

Specified by:
add in interface ExpansionPointBuilder
Parameters:
group - the group to add.

addInline

public void addInline(CommandGroup group)
Description copied from interface: ExpansionPointBuilder
Adds the specified group as an inline member of the expansion point. Inline members have thier contents embedded directly in the expansion point instead of as a sub menu. The added group can be anonymous and does not need to be bound.

The group will use it's current binding to locate the actual group instance.

Specified by:
addInline in interface ExpansionPointBuilder
Parameters:
group - the group to add.

addEmbedded

public void addEmbedded(CommandGroup group,
                        java.lang.String context)
Description copied from interface: ExpansionPointBuilder
Adds the specified group as an embedded member of the parent group. Before adding to the expansion point the parents existing members are searched to find a match with the specified group. If found, the new member is added inline to the expasion point of the matching member. Groups are deemed to match if they have the same face text for the specified context. If no match is found, the group is added to the expansion point as per ExpansionPointBuilder.add(CommandGroup).

Specified by:
addEmbedded in interface ExpansionPointBuilder
Parameters:
group - the group to be embedded.
See Also:
#addEmbedded(CommandGroup, Comparator)

addEmbedded

public void addEmbedded(CommandGroup group,
                        java.util.Comparator<CommandGroup> comparator)
Description copied from interface: ExpansionPointBuilder
Adds the specified group as an embedded member of the parent group. Before adding to the expansion point the parents existing members are searched to find a match with the specified group. If found, the new member is added inline to the expasion point of the matching member. The specified comparator is used to determine a match. If no match is found, the group is added to the expansion point as per ExpansionPointBuilder.add(CommandGroup).

Specified by:
addEmbedded in interface ExpansionPointBuilder
Parameters:
group - the group to be embedded.
See Also:
#addEmbedded(CommandGroup, Comparator)

remove

public void remove(ActionCommand command)
Description copied from interface: ExpansionPointBuilder
Removes the specified command from the expansion point.

Specified by:
remove in interface ExpansionPointBuilder
Parameters:
command - the command to remove.

remove

public void remove(CommandGroup command)
Description copied from interface: ExpansionPointBuilder
Removes the specified group from the expansion point.

Specified by:
remove in interface ExpansionPointBuilder
Parameters:
command - the group to remove.

clear

public void clear()
Description copied from interface: ExpansionPointBuilder
Clears the expansion point.

Specified by:
clear in interface ExpansionPointBuilder

applyChanges

public void applyChanges()
Description copied from interface: ExpansionPointBuilder
Applies the current builder state to the group and discards the builder. Further changes to the expansion point will require a new builder instance.

Specified by:
applyChanges in interface ExpansionPointBuilder

applyChanges

protected abstract void applyChanges(java.util.ArrayList<Contribution> contributions)
Invoked to apply the specified contribution list to the group.

Parameters:
contributions - the new contribution list to use.


Copyright © 2006 - 2007 Andrew Pietsch