Package net.sf.freecol.client.gui.action
Class FreeColAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- net.sf.freecol.client.gui.action.FreeColAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action,ObjectWithId,Option<FreeColAction>
- Direct Known Subclasses:
AboutAction,ChatAction,ColopediaAction,ContinueAction,DebugAction,DetermineHighSeasAction,MapboardAction,MapEditorAction,NewAction,OpenAction,PreferencesAction,QuitAction,ReconnectAction,ReportCargoAction,ReportColonyAction,ReportContinentalCongressAction,ReportEducationAction,ReportExplorationAction,ReportForeignAction,ReportHighScoresAction,ReportHistoryAction,ReportIndianAction,ReportLabourAction,ReportMilitaryAction,ReportNavalAction,ReportProductionAction,ReportReligionAction,ReportRequirementsAction,ReportTradeAction,ReportTurnAction,RetireAction,SaveAction,SaveAndQuitAction,ScaleMapAction,ShowDifficultyAction,ShowGameOptionsAction,ShowMainAction,ShowMapGeneratorOptionsAction,StartMapAction
public abstract class FreeColAction extends javax.swing.AbstractAction implements Option<FreeColAction>
The super class of all actions in FreeCol. Subclasses of this object is stored in anActionManager.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classFreeColAction.InnerMenuKeyListenerA class used by Actions which have a mnemonic.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringACCELERATOR_TAGstatic java.lang.StringACTION_IDstatic java.lang.StringBUTTON_DISABLED_IMAGEstatic java.lang.StringBUTTON_IMAGEstatic java.lang.StringBUTTON_PRESSED_IMAGEstatic java.lang.StringBUTTON_ROLLOVER_IMAGEprotected FreeColClientfreeColClientprivate java.util.List<java.lang.String>imageIconKeysprotected static java.util.logging.LoggerloggerProtected to congregate the subclasses here.private static intORDER_BUTTON_COUNTThere are four versions of the order buttons: normal, rollover, pressed, disabled.private intorderButtonImageCountstatic java.lang.StringTAG
-
Constructor Summary
Constructors Modifier Constructor Description protectedFreeColAction(FreeColClient freeColClient, java.lang.String id)Creates a newFreeColAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddImageIcons(java.lang.String key)Adds icons for the order buttons.FreeColActioncloneOption()Don't use this method.javax.swing.KeyStrokegetAccelerator()Gets the keyboard accelerator for this option.protected ActionManagergetActionManager()Get the action manager.protected ClientOptionsgetClientOptions()Get the client optionsprotected ConnectControllergetConnectController()Get the connect controller.java.lang.StringgetEnabledBy()Gets the key of anBooleanOptionthat must be true for this option to be enabled.protected FreeColClientgetFreeColClient()Gets the main controller object for the client.protected GamegetGame()Gets the game.java.lang.StringgetGroup()Gets the option group identifier for this option.protected GUIgetGUI()Get the GUI.java.lang.StringgetId()Get the identifier of thisOption.private static java.lang.StringgetKeyStrokeText(javax.swing.KeyStroke keyStroke)Creates aStringthat keeps the attributes givenKeyStroke.protected MapgetMap()Gets the map.javax.swing.event.MenuKeyListenergetMenuKeyListener()java.lang.IntegergetMnemonic()Gets the mnemonic to be used for selecting this actionjava.lang.StringgetName()Returns the name of thisOption.java.lang.StringgetShortDescription()Gives a short description of thisOption.FreeColActiongetValue()Gets the value of this option.java.lang.StringgetXMLTagName()booleanhasOrderButtons()Are all the order button images present?protected InGameControllerigc()Get the controller.voidreadFromXML(FreeColXMLReader xr)Initialize this object from an XML-representation of this object.voidsetAccelerator(javax.swing.KeyStroke accelerator)Sets a keyboard accelerator.voidsetGroup(java.lang.String group)Set the option group for this option.voidsetMnemonic(int mnemonic)voidsetValue(FreeColAction value)Sets the value of this option.protected booleanshouldBeEnabled()Checks if this action should be enabled.java.lang.StringtoString()voidtoXML(FreeColXMLWriter xw)This method writes an XML-representation of this object to the given stream.voidupdate()Updates the "enabled"-status with the value returned byshouldBeEnabled().private voidupdateImageIcon(java.lang.String key)voidupdateRegisteredImageIcons()-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
logger
protected static final java.util.logging.Logger logger
Protected to congregate the subclasses here.
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
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
-
ACTION_ID
public static final java.lang.String ACTION_ID
- See Also:
- Constant Field Values
-
BUTTON_IMAGE
public static final java.lang.String BUTTON_IMAGE
- 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
-
freeColClient
protected final FreeColClient freeColClient
-
orderButtonImageCount
private int orderButtonImageCount
-
imageIconKeys
private java.util.List<java.lang.String> imageIconKeys
-
ACCELERATOR_TAG
private static final java.lang.String ACCELERATOR_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FreeColAction
protected FreeColAction(FreeColClient freeColClient, java.lang.String id)
Creates a newFreeColAction.- Parameters:
freeColClient- TheFreeColClientfor 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:
cloneOptionin interfaceOption<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- TheKeyStroke. Usingnullis the same as disabling the keyboard accelerator.
-
getAccelerator
public final javax.swing.KeyStroke getAccelerator()
Gets the keyboard accelerator for this option.- Returns:
- The
KeyStrokeornullif the keyboard accelerator is disabled.
-
getShortDescription
public final java.lang.String getShortDescription()
Gives a short description of thisOption. 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 thisOption.- Specified by:
getIdin interfaceObjectWithId- Returns:
- An unique identifier for this action.
-
getName
public java.lang.String getName()
Returns the name of thisOption.- Returns:
- The name as provided in the constructor.
-
getKeyStrokeText
private static java.lang.String getKeyStrokeText(javax.swing.KeyStroke keyStroke)
Creates aStringthat keeps the attributes givenKeyStroke. ThisStringcan be used to store the key stroke in an XML-file.- Parameters:
keyStroke- TheKeyStroke.- Returns:
- A
Stringthat produces a key stroke equal to the givenKeyStrokeif passed as a parameter togetAWTKeyStroke(String).
-
getMenuKeyListener
public javax.swing.event.MenuKeyListener getMenuKeyListener()
-
shouldBeEnabled
protected boolean shouldBeEnabled()
Checks if this action should be enabled.- Returns:
- True if the
ClientOptionsDialogis not visible.
-
update
public void update()
Updates the "enabled"-status with the value returned byshouldBeEnabled().
-
getGroup
public java.lang.String getGroup()
Gets the option group identifier for this option.- Specified by:
getGroupin interfaceOption<FreeColAction>- Returns:
- The option group identifier.
-
setGroup
public void setGroup(java.lang.String group)
Set the option group for this option.- Specified by:
setGroupin interfaceOption<FreeColAction>- Parameters:
group- The identifier for the option group.
-
getValue
public FreeColAction getValue()
Gets the value of this option.- Specified by:
getValuein interfaceOption<FreeColAction>- Returns:
- The value of this
Option.
-
setValue
public void setValue(FreeColAction value)
Sets the value of this option.- Specified by:
setValuein interfaceOption<FreeColAction>- Parameters:
value- The new value of thisOption.
-
getEnabledBy
public java.lang.String getEnabledBy()
Gets the key of anBooleanOptionthat must be true for this option to be enabled.- Specified by:
getEnabledByin interfaceOption<FreeColAction>- Returns:
- The key of the
BooleanOptionthat 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:
toXMLin interfaceOption<FreeColAction>- Parameters:
xw- TheFreeColXMLWriterto 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:
readFromXMLin interfaceOption<FreeColAction>- Parameters:
xr- TheFreeColXMLReaderto 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:
toStringin interfaceOption<FreeColAction>- Overrides:
toStringin classjava.lang.Object
-
-