com.guiseframework.model
Class AbstractListSelectEditor<V>

java.lang.Object
  extended by com.guiseframework.model.AbstractListSelectEditor<V>
Type Parameters:
V - The type of values contained in the model.
All Implemented Interfaces:
ListSelectEditor<V>
Direct Known Subclasses:
DefaultListSelectEditor

public abstract class AbstractListSelectEditor<V>
extends java.lang.Object
implements ListSelectEditor<V>

An abstract class for editing values in a list model. Prototypes are provided for common edit functionality. This class registers itself with the given list, which will cause memory leaks if an instance of this class is discarded without also discarding the list.

Author:
Garret Wilson

Constructor Summary
AbstractListSelectEditor(ListSelectModel<V> listSelectModel)
          List select model constructor.
 
Method Summary
protected abstract  V createValue()
          Creates a new value to add to the list.
protected abstract  ValuedComponent<V> createValuedComponent()
          Creates a component for editing a value.
 void editValue()
          Edits the currently selected value in the list.
protected  void editValue(V value, int index, boolean replace)
          Commences editing a value.
 ActionPrototype getEditActionPrototype()
           
 ActionPrototype getInsertActionPrototype()
           
 ListSelectModel<V> getListSelectModel()
           
 ActionPrototype getLowerActionPrototype()
           
 ActionPrototype getRaiseActionPrototype()
           
 ActionPrototype getRemoveActionPrototype()
           
 void insertValue()
          Creates and allows the user to edit a new value.
 void lowerValue()
          Lowers the currently selected value in the list.
 void raiseValue()
          Raises the currently selected value in the list.
 void removeValue()
          Removes the currently selected value in the list.
protected  void updateProperties()
          Updates the action properties based upon the current state of the list select model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractListSelectEditor

public AbstractListSelectEditor(ListSelectModel<V> listSelectModel)
List select model constructor.

Parameters:
listSelectModel - The list select model this prototype manipulates.
Throws:
java.lang.NullPointerException - if the given list select model is null.
Method Detail

getListSelectModel

public ListSelectModel<V> getListSelectModel()
Specified by:
getListSelectModel in interface ListSelectEditor<V>
Returns:
The list select model being edited.

getInsertActionPrototype

public ActionPrototype getInsertActionPrototype()
Specified by:
getInsertActionPrototype in interface ListSelectEditor<V>
Returns:
The prototype for inserting a value into the list.

getEditActionPrototype

public ActionPrototype getEditActionPrototype()
Specified by:
getEditActionPrototype in interface ListSelectEditor<V>
Returns:
The prototype for editing a value in the list.

getRemoveActionPrototype

public ActionPrototype getRemoveActionPrototype()
Specified by:
getRemoveActionPrototype in interface ListSelectEditor<V>
Returns:
The prototype for removing a value from the list.

getLowerActionPrototype

public ActionPrototype getLowerActionPrototype()
Specified by:
getLowerActionPrototype in interface ListSelectEditor<V>
Returns:
The prototype for lowering a value from the list to a lesser index.

getRaiseActionPrototype

public ActionPrototype getRaiseActionPrototype()
Specified by:
getRaiseActionPrototype in interface ListSelectEditor<V>
Returns:
The prototype for raising a value from the list to a higher index.

updateProperties

protected void updateProperties()
Updates the action properties based upon the current state of the list select model.


editValue

protected void editValue(V value,
                         int index,
                         boolean replace)
Commences editing a value. This method returns immediately before editing is finished. Once the value has been edited and accepted, it will be added to the list and the selected value updated to the edited value.

Parameters:
value - The value to edit.
index - The index at which the edited value will be placed.
replace - true if the value should replace the value at the given index, or false if the value should be inserted at the given index.

insertValue

public void insertValue()
Creates and allows the user to edit a new value. If the user accepts the changes, the value is inserted before the currently selected value in the list, or at the end of the list if no value is selected.

Specified by:
insertValue in interface ListSelectEditor<V>

editValue

public void editValue()
Edits the currently selected value in the list. If no value is selected in the list, no action occurs.

Specified by:
editValue in interface ListSelectEditor<V>

removeValue

public void removeValue()
Removes the currently selected value in the list. If no value is selected in the list, no action occurs.

Specified by:
removeValue in interface ListSelectEditor<V>

lowerValue

public void lowerValue()
Lowers the currently selected value in the list. If no value is selected in the list, or the first item is selected, no action occurs.


raiseValue

public void raiseValue()
Raises the currently selected value in the list. If no value is selected in the list, or the last item is selected, no action occurs.


createValue

protected abstract V createValue()
Creates a new value to add to the list.

Returns:
A new default value to add.

createValuedComponent

protected abstract ValuedComponent<V> createValuedComponent()
Creates a component for editing a value.

Parameters:
value - The current value.
Returns:
A component for editing the value.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.