Class AbstractToolbarItem
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,GameComponent
,PropertyNameSource
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
- Direct Known Subclasses:
ChangePropertyButton
,DiceButton
,DoActionButton
,ImageSaver
,Inventory
,LayerControl
,LOS_Thread
,Map
,MapShader
,MassKeyCommand
,MoveCameraButton
,NotesWindow
,PieceRecenterer
,PlayerRoster
,TextSaver
,ToolbarMenu
AbstractConfigurable
and buildable from the
XML buildFile AbstractBuildable
, but which also has a Toolbar launch button.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Configures the toolbar's button icon.Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected boolean
static final String
protected IconConfigurer
static final String
protected boolean
static final String
static final String
protected LaunchButton
static final String
protected MutableProperty.Impl
static final String
protected String
protected boolean
static final String
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Classes extendingAbstractBuildable
should override this method in order to add the names of any image files they use to the collection.protected void
protected void
addPropertyGateListener
(boolean dontCheck) If we have a disable-this-button property, set a listener on itvoid
Default behavior adds the button to the parent componentvoid
Check our disable-this-button property and enable/disable our button as appropriate based on its valuevoid
disableIfTrue
(boolean disable) String[]
This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]
This getAttributeNames() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.Class<?>[]
This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.By default, all attributes are visibleprotected Component
The component to be added to the control window toolbarprotected String
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullboolean
protected LaunchButton
makeLaunchButton
(String tooltip, String button_text, String iconFile, ActionListener action) Create a standard toolbar launcher button for this itemvoid
Listens to our disable-this-button property; enables/disables our button as appropriate when it changesvoid
removeFrom
(Buildable parent) Remove from our parentprotected void
Remove any existing disable-this-button propertyvoid
setAttribute
(String key, Object value) Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.protected void
setButtonTextKey
(String buttonTextKey) protected void
setHotKeyKey
(String hotKeyKey) protected void
setIconKey
(String iconKey) protected void
setLaunchButton
(LaunchButton launch) Sets launch button for this toolbar itemprotected void
setNameKey
(String nameKey) protected void
setNamePrompt
(String namePrompt) protected void
setShowDisabledOptions
(boolean show) protected void
setTooltipKey
(String tooltipKey) void
setup
(boolean gameStarting) Notify the GameComponent that a game has started/endedMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getExpressionList, getFormattedStringList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validate
Methods inherited from class VASSAL.search.AbstractImageFinder
getAllImageNames, getLocalImageNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeName
Methods inherited from interface VASSAL.build.Buildable
build, getBuildElement, isMandatory, isMovable, isUnique
Methods inherited from interface VASSAL.build.Configurable
getAllowableConfigureComponents, getHelpFile
-
Field Details
-
NAME
- See Also:
-
TOOLTIP
- See Also:
-
BUTTON_TEXT
- See Also:
-
HOTKEY
- See Also:
-
ICON
- See Also:
-
CAN_DISABLE
- See Also:
-
PROPERTY_GATE
- See Also:
-
DISABLED_ICON
- See Also:
-
HIDE_WHEN_DISABLED
- See Also:
-
launch
-
disabledIconConfig
-
showDisabledOptions
protected boolean showDisabledOptions -
canDisable
protected boolean canDisable -
hideWhenDisabled
protected boolean hideWhenDisabled -
propertyGate
-
property
-
-
Constructor Details
-
AbstractToolbarItem
public AbstractToolbarItem()
-
-
Method Details
-
setNamePrompt
-
setNameKey
-
getNameKey
-
setTooltipKey
-
setButtonTextKey
-
setHotKeyKey
-
setIconKey
-
setShowDisabledOptions
protected void setShowDisabledOptions(boolean show) -
isShowDisabledOptions
public boolean isShowDisabledOptions() -
makeLaunchButton
protected LaunchButton makeLaunchButton(String tooltip, String button_text, String iconFile, ActionListener action) Create a standard toolbar launcher button for this item- Parameters:
tooltip
- String tooltip for buttonbutton_text
- Text for buttoniconFile
- filename for icon defaultaction
- Action Listener when launch button is clicked- Returns:
- launch button
-
getLaunchButton
- Returns:
- Launch button for this Toolbar item.
-
setLaunchButton
Sets launch button for this toolbar item- Parameters:
launch
- - launch button
-
addPropertyGateListener
protected void addPropertyGateListener() -
addPropertyGateListener
protected void addPropertyGateListener(boolean dontCheck) If we have a disable-this-button property, set a listener on it -
removePropertyGateListener
protected void removePropertyGateListener()Remove any existing disable-this-button property -
propertyChange
Listens to our disable-this-button property; enables/disables our button as appropriate when it changes- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
evt
- property change event
-
checkDisabled
public void checkDisabled()Check our disable-this-button property and enable/disable our button as appropriate based on its value -
disableIfTrue
public void disableIfTrue(boolean disable) - Parameters:
disable
- true to disable our launch button, false to enable it
-
setup
public void setup(boolean gameStarting) Description copied from interface:GameComponent
Notify the GameComponent that a game has started/ended- Specified by:
setup
in interfaceGameComponent
- Parameters:
gameStarting
- if true, a game is starting. If false, then a game is ending
-
getRestoreCommand
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommand
in interfaceGameComponent
-
getAttributeNames
This getAttributeNames() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeNames(), key1, ..., keyN), or supply their own order from scratch.Lists all the buildFile (XML) attribute names for this component. If this component is ALSO an
AbstractConfigurable
, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()
andAbstractConfigurable.getAttributeTypes()
.- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- an array of all buildFile (XML) attribute names for this component
-
getAttributeDescriptions
This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeDescriptions
in interfaceAutoConfigurable
- Specified by:
getAttributeDescriptions
in classAbstractConfigurable
- Returns:
- an array of Strings describing the buildFile (XML) attributes of this component. These strings are used as prompts in the
Properties window for this object, when the component is configured in the Editor. The order of descriptions should
be the same as the order of names in
AbstractBuildable.getAttributeNames()
-
getAttributeTypes
This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Specified by:
getAttributeTypes
in classAbstractConfigurable
- Returns:
- the Class for the buildFile (XML) attributes of this component. Valid classes include: String, Integer, Double, Boolean, Image,
Color, and KeyStroke, along with any class for which a Configurer exists in VASSAL.configure. The class determines, among other things,
which type of
AutoConfigurer
will be used to configure the attribute when the object is configured in the Editor.The order of classes should be the same as the order of names in
AbstractBuildable.getAttributeNames()
-
setAttribute
Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.Sets a buildFile (XML) attribute value for this component. The
key
parameter will be one of those listed ingetAttributeNames()
. If thevalue
parameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
will be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed ingetAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getAttributeValueString
Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Specified by:
getAttributeValueString
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed ingetAttributeNames()
- Returns:
- a String representation of the XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
setAttribute(java.lang.String, java.lang.Object)
. It is also frequently used for checking the current value of an attribute.
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classAbstractConfigurable
- Parameters:
key
- Name (key) of one of this component's attributes- Returns:
- a
VisibilityCondition
for this attribute, or null if attribute should always be visible.
-
getComponent
The component to be added to the control window toolbar -
addTo
-
removeFrom
Remove from our parent- Specified by:
removeFrom
in interfaceConfigurable
- Parameters:
parent
- parent
-
getPropertyList
Description copied from class:AbstractConfigurable
- Specified by:
getPropertyList
in interfaceSearchTarget
- Overrides:
getPropertyList
in classAbstractConfigurable
- Returns:
- a list of any Property Names referenced in the Configurable, if any (for search)
-
getMenuTextList
Description copied from class:AbstractConfigurable
- Specified by:
getMenuTextList
in interfaceSearchTarget
- Overrides:
getMenuTextList
in classAbstractConfigurable
- Returns:
- a list of any Menu/Button/Tooltip Text strings referenced in the Configurable, if any (for search)
-
getNamedKeyStrokeList
Description copied from class:AbstractConfigurable
- Specified by:
getNamedKeyStrokeList
in interfaceSearchTarget
- Overrides:
getNamedKeyStrokeList
in classAbstractConfigurable
- Returns:
- a list of any Named KeyStrokes referenced in the Configurable, if any (for search)
-
addLocalImageNames
Classes extendingAbstractBuildable
should override this method in order to add the names of any image files they use to the collection. For "find unused images" and "search".- Specified by:
addLocalImageNames
in interfaceImageSearchTarget
- Overrides:
addLocalImageNames
in classAbstractImageFinder
- Parameters:
s
- Collection to add image names to
-