org.grinvin.list.actions

Class AbstractListAction<E>

Implemented Interfaces:
ListSelectionListener
Known Direct Subclasses:
RenameAction<T,extends,HasName>

public abstract class AbstractListAction<E>
extends SimpleAction
implements ListSelectionListener

Abstract implementation for list actions. These actions work on a TypedListModel and use a ListSelectionModel to know on which elements to apply the action. The TypedListModel has to contain elements of type E. This action will listen to the ListSelectionModel to know if it's enabled.

Field Summary

protected TypedListModel
list
protected ListSelectionModel
selection

Constructor Summary

AbstractListAction(TypedListModel list, ListSelectionModel selection, ResourceBundle bundle, String resourceID)

Method Summary

protected List
getSelectedElements()
Returns the selected elements in the TypedListModel based on the ListSelectionModel.
void
setEnabled()
Decides the enabled status of this action, based on the selection.
void
valueChanged(ListSelectionEvent e)

Field Details

list

protected TypedListModel list

selection

protected ListSelectionModel selection

Constructor Details

AbstractListAction

public AbstractListAction(TypedListModel list,
                          ListSelectionModel selection,
                          ResourceBundle bundle,
                          String resourceID)

Method Details

getSelectedElements

protected List getSelectedElements()
Returns the selected elements in the TypedListModel based on the ListSelectionModel.

setEnabled

public void setEnabled()
Decides the enabled status of this action, based on the selection. This method is called every time the selection changes. By default the action will be disabled when there are no elements selected and enabled in all other cases. This method can be overridden to alter this behaviour.

valueChanged

public void valueChanged(ListSelectionEvent e)