Class FreeColAction

    • Field Detail

      • logger

        protected static final java.util.logging.Logger logger
        Protected to congregate the subclasses here.
      • ORDER_BUTTON_COUNT

        private static final int ORDER_BUTTON_COUNT
        There are four versions of the order buttons: normal, rollover, pressed, disabled.
        See Also:
        Constant Field Values
      • BUTTON_ROLLOVER_IMAGE

        public static final java.lang.String BUTTON_ROLLOVER_IMAGE
        See Also:
        Constant Field Values
      • BUTTON_PRESSED_IMAGE

        public static final java.lang.String BUTTON_PRESSED_IMAGE
        See Also:
        Constant Field Values
      • BUTTON_DISABLED_IMAGE

        public static final java.lang.String BUTTON_DISABLED_IMAGE
        See Also:
        Constant Field Values
      • orderButtonImageCount

        private int orderButtonImageCount
      • imageIconKeys

        private java.util.List<java.lang.String> imageIconKeys
    • Constructor Detail

      • FreeColAction

        protected FreeColAction​(FreeColClient freeColClient,
                                java.lang.String id)
        Creates a new FreeColAction.
        Parameters:
        freeColClient - The FreeColClient for the game.
        id - The object identifier for this action.
    • Method Detail

      • getFreeColClient

        protected FreeColClient getFreeColClient()
        Gets the main controller object for the client.
        Returns:
        The main controller object for the client.
      • getGame

        protected Game getGame()
        Gets the game.
        Returns:
        The Game.
      • getMap

        protected Map getMap()
        Gets the map.
        Returns:
        The Map.
      • getGUI

        protected GUI getGUI()
        Get the GUI.
        Returns:
        The GUI.
      • igc

        protected InGameController igc()
        Get the controller.
        Returns:
        The InGameController.
      • getConnectController

        protected ConnectController getConnectController()
        Get the connect controller.
        Returns:
        The ConnectController.
      • getActionManager

        protected ActionManager getActionManager()
        Get the action manager.
        Returns:
        The ActionManager.
      • getClientOptions

        protected ClientOptions getClientOptions()
        Get the client options
        Returns:
        The ClientOptions.
      • cloneOption

        public FreeColAction cloneOption()
                                  throws java.lang.CloneNotSupportedException
        Don't use this method.
        Specified by:
        cloneOption in interface Option<FreeColAction>
        Returns:
        A clone of this option.
        Throws:
        java.lang.CloneNotSupportedException - if we can not clone.
      • getMnemonic

        public java.lang.Integer getMnemonic()
        Gets the mnemonic to be used for selecting this action
        Returns:
        The mnemonic of the action
      • setMnemonic

        public void setMnemonic​(int mnemonic)
      • hasOrderButtons

        public boolean hasOrderButtons()
        Are all the order button images present?
        Returns:
        True if all the order button images are present.
      • addImageIcons

        protected void addImageIcons​(java.lang.String key)
        Adds icons for the order buttons.
        Parameters:
        key - The identifier of the action.
      • updateRegisteredImageIcons

        public void updateRegisteredImageIcons()
      • updateImageIcon

        private void updateImageIcon​(java.lang.String key)
      • setAccelerator

        public final void setAccelerator​(javax.swing.KeyStroke accelerator)
        Sets a keyboard accelerator.
        Parameters:
        accelerator - The KeyStroke. Using null is the same as disabling the keyboard accelerator.
      • getAccelerator

        public final javax.swing.KeyStroke getAccelerator()
        Gets the keyboard accelerator for this option.
        Returns:
        The KeyStroke or null if the keyboard accelerator is disabled.
      • getShortDescription

        public final java.lang.String getShortDescription()
        Gives a short description of this Option. Can for instance be used as a tooltip text.
        Returns:
        A short description of this action.
      • getId

        public final java.lang.String getId()
        Get the identifier of this Option.
        Specified by:
        getId in interface ObjectWithId
        Returns:
        An unique identifier for this action.
      • getName

        public java.lang.String getName()
        Returns the name of this Option.
        Returns:
        The name as provided in the constructor.
      • getKeyStrokeText

        private static java.lang.String getKeyStrokeText​(javax.swing.KeyStroke keyStroke)
        Creates a String that keeps the attributes given KeyStroke. This String can be used to store the key stroke in an XML-file.
        Parameters:
        keyStroke - The KeyStroke.
        Returns:
        A String that produces a key stroke equal to the given KeyStroke if passed as a parameter to getAWTKeyStroke(String).
      • getMenuKeyListener

        public javax.swing.event.MenuKeyListener getMenuKeyListener()
      • shouldBeEnabled

        protected boolean shouldBeEnabled()
        Checks if this action should be enabled.
        Returns:
        True if the ClientOptionsDialog is not visible.
      • update

        public void update()
        Updates the "enabled"-status with the value returned by shouldBeEnabled().
      • getGroup

        public java.lang.String getGroup()
        Gets the option group identifier for this option.
        Specified by:
        getGroup in interface Option<FreeColAction>
        Returns:
        The option group identifier.
      • setGroup

        public void setGroup​(java.lang.String group)
        Set the option group for this option.
        Specified by:
        setGroup in interface Option<FreeColAction>
        Parameters:
        group - The identifier for the option group.
      • getEnabledBy

        public java.lang.String getEnabledBy()
        Gets the key of an BooleanOption that must be true for this option to be enabled.
        Specified by:
        getEnabledBy in interface Option<FreeColAction>
        Returns:
        The key of the BooleanOption that needs to be enabled.
      • toXML

        public void toXML​(FreeColXMLWriter xw)
                   throws javax.xml.stream.XMLStreamException
        This method writes an XML-representation of this object to the given stream.
        Specified by:
        toXML in interface Option<FreeColAction>
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem writing to the stream.
      • readFromXML

        public void readFromXML​(FreeColXMLReader xr)
                         throws javax.xml.stream.XMLStreamException
        Initialize this object from an XML-representation of this object.
        Specified by:
        readFromXML in interface Option<FreeColAction>
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
      • getXMLTagName

        public java.lang.String getXMLTagName()
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface Option<FreeColAction>
        Overrides:
        toString in class java.lang.Object