@OpenApiAll public class SelectItemAction extends ActionsCategory implements java.beans.PropertyChangeListener
toString()
method. When this action is represented
as toolbar GUI component is a combo box. When this action is represented as
menu GUI component is a sub menu. By default combo box and sub menu items
displays only strings from list elements, but it can be changed by overriding
createAction(Object, String)
method which can create another
type of actions used to display list items.
Selected item can be got using getCurrent()
method. When
selection is changed action fires property change event with name
getValueName()
.createAction(Object, String)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
ADDITIONAL_PROPERTY_MAX_WIDTH
A name of additional action property for specifying max width of component.
|
ACTIONS_PROPERTY, ADDED_ACTION_PROPERTY, CHANGE_ACTIONS_PROPERTY, MAX_CATEGORY_ACTIONS, REMOVED_ACTION_PROPERTY, USE_AS_SEPARATOR_IN_UI
ACTION_SHORTCUTS, BELONGS_TO_SEPARATE_GROUP_IN_UI, DO_NO_SHOW_ACTION_NAME_IN_UI, GENERATED_ID_PREFIX, GROUP, ID, LARGE_ICON, MENU_SHORTCUT_MASK, TINY_ICON
Constructor and Description |
---|
SelectItemAction(java.lang.String id,
java.lang.String name,
int stroke,
java.lang.String group,
java.util.List<?> items,
java.lang.String valueName)
Creates action and fills it with action for each element from list.
|
SelectItemAction(java.lang.String id,
java.lang.String name,
javax.swing.KeyStroke stroke,
java.lang.String group,
java.util.List<?> items,
java.lang.String valueName)
Creates action and fills it with action for each element from list.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(ActionsVisitor visitor)
If given visitor is
MainActionsVisitor , visit this action in
different way. |
SelectItemAction |
clone()
Clones the category.
|
protected SelectionStateItem |
createAction(java.lang.Object obj,
java.lang.String valueName)
Method creates action which represents given object, and fires
PropertyChangeEvent with name valueName when it is executed. |
java.util.List<?> |
getItems() |
java.lang.Object |
getValue()
Method returns current selection.
|
java.lang.String |
getValueName()
Returns property name which will be used to fire property change and to put value.
|
boolean |
isChangeable()
Returns true if new action item can be added.
|
boolean |
isDisplayAsComboBox() |
boolean |
isShowActionName() |
void |
propertyChange(java.beans.PropertyChangeEvent e)
Listens for child action.
|
void |
setChangeable(boolean val)
Sets changeable property.
|
void |
setDisplayAsComboBox(boolean displayAsComboBox) |
void |
setItems(java.util.List<?> items)
Sets List value.
|
void |
setList(java.util.List newList)
Deprecated.
use #setItems(java.util.List)
|
void |
setShowActionName(boolean showActionName) |
void |
setValue(java.lang.Object value)
Sets new value of this list action.
|
void |
updateState()
Updates state for actions from actions in list.
|
actionPerformed, addAction, addAction, addActions, breakActions, breakActions, breakActions, breakeActions, getAction, getActions, getActionsRecursively, getCategories, isDisplayHeader, isEmpty, isNested, isUseActionForDisable, removeAction, setActions, setDisplayHeader, setNested, setUseActionForDisable, shallowClone, size, sort
addPropertyChangeListener, addShortcut, addShotcut, addWeakPropertyChangeListener, compareTo, createMenuItem, equals, firePropertyChange, getCommandKey, getDescription, getGroup, getIcon, getID, getLargeIcon, getLargeOrSmallIcon, getMenuShortcutMaskAsString, getMnemonicKey, getName, getPropertyChangeListeners, getShortcuts, getSmallIcon, getSmallOrLargeIcon, getTinyIcon, hashCode, hasMenuShortcutMask, isIDGenerated, removePropertyChangeListener, removeShortcut, removeWeakPropertyChangeListener, setDescription, setGroup, setIcon, setLargeIcon, setMnemonicKey, setName, setShortcuts, setSmallIcon, setTinyIcon, toString
public static final java.lang.String ADDITIONAL_PROPERTY_MAX_WIDTH
public SelectItemAction(java.lang.String id, java.lang.String name, @CheckForNull javax.swing.KeyStroke stroke, @CheckForNull java.lang.String group, @CheckForNull java.util.List<?> items, java.lang.String valueName)
id
- id of actionname
- action namestroke
- key stroke for action.group
- action group.items
- list of selections.valueName
- name of fired property when value is changed.setItems(List)
public SelectItemAction(java.lang.String id, java.lang.String name, int stroke, @CheckForNull java.lang.String group, @CheckForNull java.util.List<?> items, java.lang.String valueName)
id
- id of actionname
- action namestroke
- key stroke for action.group
- action group.items
- list selections.valueName
- name of fired property when value is changed.setItems(List)
public void setItems(@CheckForNull java.util.List<?> items)
items
- items of objects from which actions will be created.public java.util.List<?> getItems()
@Deprecated public void setList(java.util.List newList)
protected SelectionStateItem createAction(java.lang.Object obj, java.lang.String valueName)
PropertyChangeEvent
with name valueName when it is executed.obj
- object from which action will be created.valueName
- property name which should be fired when created action is executed.SelectionStateItem
public void propertyChange(java.beans.PropertyChangeEvent e)
getPropertyName()
using setCurrent( method )
method. If children actions is state actions updates theirs state.propertyChange
in interface java.beans.PropertyChangeListener
public void updateState()
updateState
in class NMAction
NMStateAction.setState(boolean)
public SelectItemAction clone()
ActionsCategory
clone
in class ActionsCategory
public java.lang.Object getValue()
public boolean isChangeable()
public void setChangeable(boolean val)
val
- new value.public void setValue(java.lang.Object value)
public java.lang.String getValueName()
public void accept(ActionsVisitor visitor)
MainActionsVisitor
, visit this action in
different way.accept
in class ActionsCategory
visitor
- the given visitor.public boolean isShowActionName()
public void setShowActionName(boolean showActionName)
public boolean isDisplayAsComboBox()
public void setDisplayAsComboBox(boolean displayAsComboBox)