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 class
FreeColAction.InnerMenuKeyListener
A class used by Actions which have a mnemonic.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ACCELERATOR_TAG
static java.lang.String
ACTION_ID
static java.lang.String
BUTTON_DISABLED_IMAGE
static java.lang.String
BUTTON_IMAGE
static java.lang.String
BUTTON_PRESSED_IMAGE
static java.lang.String
BUTTON_ROLLOVER_IMAGE
protected FreeColClient
freeColClient
private java.util.List<java.lang.String>
imageIconKeys
protected static java.util.logging.Logger
logger
Protected to congregate the subclasses here.private static int
ORDER_BUTTON_COUNT
There are four versions of the order buttons: normal, rollover, pressed, disabled.private int
orderButtonImageCount
static java.lang.String
TAG
-
Constructor Summary
Constructors Modifier Constructor Description protected
FreeColAction(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 void
addImageIcons(java.lang.String key)
Adds icons for the order buttons.FreeColAction
cloneOption()
Don't use this method.javax.swing.KeyStroke
getAccelerator()
Gets the keyboard accelerator for this option.protected ActionManager
getActionManager()
Get the action manager.protected ClientOptions
getClientOptions()
Get the client optionsprotected ConnectController
getConnectController()
Get the connect controller.java.lang.String
getEnabledBy()
Gets the key of anBooleanOption
that must be true for this option to be enabled.protected FreeColClient
getFreeColClient()
Gets the main controller object for the client.protected Game
getGame()
Gets the game.java.lang.String
getGroup()
Gets the option group identifier for this option.protected GUI
getGUI()
Get the GUI.java.lang.String
getId()
Get the identifier of thisOption
.private static java.lang.String
getKeyStrokeText(javax.swing.KeyStroke keyStroke)
Creates aString
that keeps the attributes givenKeyStroke
.protected Map
getMap()
Gets the map.javax.swing.event.MenuKeyListener
getMenuKeyListener()
java.lang.Integer
getMnemonic()
Gets the mnemonic to be used for selecting this actionjava.lang.String
getName()
Returns the name of thisOption
.java.lang.String
getShortDescription()
Gives a short description of thisOption
.FreeColAction
getValue()
Gets the value of this option.java.lang.String
getXMLTagName()
boolean
hasOrderButtons()
Are all the order button images present?protected InGameController
igc()
Get the controller.void
readFromXML(FreeColXMLReader xr)
Initialize this object from an XML-representation of this object.void
setAccelerator(javax.swing.KeyStroke accelerator)
Sets a keyboard accelerator.void
setGroup(java.lang.String group)
Set the option group for this option.void
setMnemonic(int mnemonic)
void
setValue(FreeColAction value)
Sets the value of this option.protected boolean
shouldBeEnabled()
Checks if this action should be enabled.java.lang.String
toString()
void
toXML(FreeColXMLWriter xw)
This method writes an XML-representation of this object to the given stream.void
update()
Updates the "enabled"-status with the value returned byshouldBeEnabled()
.private void
updateImageIcon(java.lang.String key)
void
updateRegisteredImageIcons()
-
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
- TheFreeColClient
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 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
. Usingnull
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
ornull
if 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:
getId
in 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 aString
that keeps the attributes givenKeyStroke
. ThisString
can be used to store the key stroke in an XML-file.- Parameters:
keyStroke
- TheKeyStroke
.- Returns:
- A
String
that produces a key stroke equal to the givenKeyStroke
if 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
ClientOptionsDialog
is 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:
getGroup
in interfaceOption<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 interfaceOption<FreeColAction>
- Parameters:
group
- The identifier for the option group.
-
getValue
public FreeColAction getValue()
Gets the value of this option.- Specified by:
getValue
in interfaceOption<FreeColAction>
- Returns:
- The value of this
Option
.
-
setValue
public void setValue(FreeColAction value)
Sets the value of this option.- Specified by:
setValue
in interfaceOption<FreeColAction>
- Parameters:
value
- The new value of thisOption
.
-
getEnabledBy
public java.lang.String getEnabledBy()
Gets the key of anBooleanOption
that must be true for this option to be enabled.- Specified by:
getEnabledBy
in interfaceOption<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 interfaceOption<FreeColAction>
- Parameters:
xw
- TheFreeColXMLWriter
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 interfaceOption<FreeColAction>
- Parameters:
xr
- TheFreeColXMLReader
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 interfaceOption<FreeColAction>
- Overrides:
toString
in classjava.lang.Object
-
-