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

public abstract class AbstractToolbarItem extends AbstractConfigurable implements GameComponent, PropertyChangeListener
Creates an item that is both configurable w/ an edit box AbstractConfigurable and buildable from the XML buildFile AbstractBuildable, but which also has a Toolbar launch button.
  • Field Details

  • Constructor Details

    • AbstractToolbarItem

      public AbstractToolbarItem()
  • Method Details

    • setNamePrompt

      protected void setNamePrompt(String namePrompt)
    • setNameKey

      protected void setNameKey(String nameKey)
    • getNameKey

      protected String getNameKey()
    • setTooltipKey

      protected void setTooltipKey(String tooltipKey)
    • setButtonTextKey

      protected void setButtonTextKey(String buttonTextKey)
    • setHotKeyKey

      protected void setHotKeyKey(String hotKeyKey)
    • setIconKey

      protected void setIconKey(String iconKey)
    • 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 button
      button_text - Text for button
      iconFile - filename for icon default
      action - Action Listener when launch button is clicked
      Returns:
      launch button
    • getLaunchButton

      public LaunchButton getLaunchButton()
      Returns:
      Launch button for this Toolbar item.
    • setLaunchButton

      protected void setLaunchButton(LaunchButton launch)
      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

      public void propertyChange(PropertyChangeEvent evt)
      Listens to our disable-this-button property; enables/disables our button as appropriate when it changes
      Specified by:
      propertyChange in interface PropertyChangeListener
      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 interface GameComponent
      Parameters:
      gameStarting - if true, a game is starting. If false, then a game is ending
    • getRestoreCommand

      public Command getRestoreCommand()
      Description copied from interface: GameComponent
      When saving a game, each GameComponent should return a Command 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 interface GameComponent
    • getAttributeNames

      public String[] 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 for AbstractConfigurable.getAttributeDescriptions() and AbstractConfigurable.getAttributeTypes().

      Specified by:
      getAttributeNames in interface AutoConfigurable
      Specified by:
      getAttributeNames in class AbstractBuildable
      Returns:
      an array of all buildFile (XML) attribute names for this component
    • getAttributeDescriptions

      public String[] 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 interface AutoConfigurable
      Specified by:
      getAttributeDescriptions in class AbstractConfigurable
      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

      public Class<?>[] 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 interface AutoConfigurable
      Specified by:
      getAttributeTypes in class AbstractConfigurable
      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

      public void 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.

      Sets a buildFile (XML) attribute value for this component. The key parameter will be one of those listed in getAttributeNames(). If the value parameter is a String, it will be the value returned by getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value will be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()

      Specified by:
      setAttribute in interface AutoConfigurable
      Specified by:
      setAttribute in interface Translatable
      Specified by:
      setAttribute in class AbstractBuildable
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      value - If the value parameter is a String, it will be the value returned by getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value can also be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()
    • getAttributeValueString

      public String getAttributeValueString(String key)
      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 interface AutoConfigurable
      Specified by:
      getAttributeValueString in interface Translatable
      Specified by:
      getAttributeValueString in class AbstractBuildable
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      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

      public VisibilityCondition getAttributeVisibility(String key)
      Description copied from class: AbstractConfigurable
      By default, all attributes are visible
      Specified by:
      getAttributeVisibility in interface AutoConfigurable
      Overrides:
      getAttributeVisibility in class AbstractConfigurable
      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

      protected Component getComponent()
      The component to be added to the control window toolbar
    • addTo

      public void addTo(Buildable parent)
      Default behavior adds the button to the parent component
      Specified by:
      addTo in interface Buildable
      Parameters:
      parent - parent Buildable to add this component to as a subcomponent.
    • removeFrom

      public void removeFrom(Buildable parent)
      Remove from our parent
      Specified by:
      removeFrom in interface Configurable
      Parameters:
      parent - parent
    • getPropertyList

      public List<String> getPropertyList()
      Description copied from class: AbstractConfigurable
      Specified by:
      getPropertyList in interface SearchTarget
      Overrides:
      getPropertyList in class AbstractConfigurable
      Returns:
      a list of any Property Names referenced in the Configurable, if any (for search)
    • getMenuTextList

      public List<String> getMenuTextList()
      Description copied from class: AbstractConfigurable
      Specified by:
      getMenuTextList in interface SearchTarget
      Overrides:
      getMenuTextList in class AbstractConfigurable
      Returns:
      a list of any Menu/Button/Tooltip Text strings referenced in the Configurable, if any (for search)
    • getNamedKeyStrokeList

      public List<NamedKeyStroke> getNamedKeyStrokeList()
      Description copied from class: AbstractConfigurable
      Specified by:
      getNamedKeyStrokeList in interface SearchTarget
      Overrides:
      getNamedKeyStrokeList in class AbstractConfigurable
      Returns:
      a list of any Named KeyStrokes referenced in the Configurable, if any (for search)
    • addLocalImageNames

      public void addLocalImageNames(Collection<String> s)
      Classes extending AbstractBuildable 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 interface ImageSearchTarget
      Overrides:
      addLocalImageNames in class AbstractImageFinder
      Parameters:
      s - Collection to add image names to