Package io.guise.framework.model
Class AbstractListSelectEditor<V>
- java.lang.Object
-
- io.guise.framework.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
Constructors Constructor Description AbstractListSelectEditor(ListSelectModel<V> listSelectModel)
List select model constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 isnull
.
-
-
Method Detail
-
getListSelectModel
public ListSelectModel<V> getListSelectModel()
- Specified by:
getListSelectModel
in interfaceListSelectEditor<V>
- Returns:
- The list select model being edited.
-
getInsertActionPrototype
public ActionPrototype getInsertActionPrototype()
- Specified by:
getInsertActionPrototype
in interfaceListSelectEditor<V>
- Returns:
- The prototype for inserting a value into the list.
-
getEditActionPrototype
public ActionPrototype getEditActionPrototype()
- Specified by:
getEditActionPrototype
in interfaceListSelectEditor<V>
- Returns:
- The prototype for editing a value in the list.
-
getRemoveActionPrototype
public ActionPrototype getRemoveActionPrototype()
- Specified by:
getRemoveActionPrototype
in interfaceListSelectEditor<V>
- Returns:
- The prototype for removing a value from the list.
-
getLowerActionPrototype
public ActionPrototype getLowerActionPrototype()
- Specified by:
getLowerActionPrototype
in interfaceListSelectEditor<V>
- Returns:
- The prototype for lowering a value from the list to a lesser index.
-
getRaiseActionPrototype
public ActionPrototype getRaiseActionPrototype()
- Specified by:
getRaiseActionPrototype
in interfaceListSelectEditor<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, orfalse
if the value should be inserted at the given index.
-
insertValue
public void insertValue()
Description copied from interface:ListSelectEditor
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 interfaceListSelectEditor<V>
-
editValue
public void editValue()
Description copied from interface:ListSelectEditor
Edits the currently selected value in the list. If no value is selected in the list, no action occurs.- Specified by:
editValue
in interfaceListSelectEditor<V>
-
removeValue
public void removeValue()
Description copied from interface:ListSelectEditor
Removes the currently selected value in the list. If no value is selected in the list, no action occurs.- Specified by:
removeValue
in interfaceListSelectEditor<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.- Returns:
- A component for editing the value.
-
-