Package be.gaudry.swing.action
Class RunnablePanelAction
java.lang.Object
javax.swing.AbstractAction
be.gaudry.swing.action.RunnablePanelAction
- All Implemented Interfaces:
ActionListener
,Serializable
,Cloneable
,EventListener
,Action
- Direct Known Subclasses:
BuildFileChartAction
,BuildMReportAction
,ConvertCewe2PdfAction
,Runtastic2GpxAction
,SearchAction
,TransfertPhotosAction
Action associated to a runnable component.
Allows to control the way to display the action(the image and the name)
depending on the status(if the process is running or not) and on the
availability of the component(if the panel is hidden, the action is disabled).
Provided by the broldev.core.swing project.
- Since:
- 1.0 (Mar 23, 2009), broldev.core.swing 0.0.1-SNAPSHOT dependency
- Version:
- 1.3 (Sep 4, 2009)
- Author:
- Steph GAUDRY
- See Also:
- Serialized Form
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic String
Action command for the ActionEvent if we want canceling previous execution of the process and starting a new execution with new parametersFields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
Constructor Summary
ConstructorsConstructorDescriptionBuilds a default instance of an action to start or stop a runnableRunnablePanelAction(String lRBPath, String lRBStartKey, String lRBStopKey)
Builds a custom instance of an action to start or stop a runnableRunnablePanelAction(Icon startProcessImage, Icon stopProcessImage, String lRBPath, String lRBStartKey, String lRBStopKey)
Builds a custom instance of an action to start or stop a runnable -
Method Summary
Modifier and TypeMethodDescriptionvoid
getPanel()
Returns the runnable componentboolean
Returns the runnable statusvoid
Forces to read localized strings to actualize this.void
setPanel(IRunnablePanel panel)
Sets the JPanel to link to this action, and adds aComponentListener
to enable or disable this action when the panel is shown or not.void
setPauseAction(RunnablePanelPauseAction pauseAction)
void
setStarted(boolean started)
Toggles the runnable status, and sets theAction.SMALL_ICON
andAction.NAME
values according to the status.Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
FORCE_START_COMMAND
Action command for the ActionEvent if we want canceling previous execution of the process and starting a new execution with new parameters- See Also:
- Constant Field Values
-
-
Constructor Details
-
RunnablePanelAction
public RunnablePanelAction()Builds a default instance of an action to start or stop a runnable -
RunnablePanelAction
public RunnablePanelAction(Icon startProcessImage, Icon stopProcessImage, String lRBPath, String lRBStartKey, String lRBStopKey)Builds a custom instance of an action to start or stop a runnable- Parameters:
startProcessImage
- icon associated to the "start" actionstopProcessImage
- icon associated to the "stop" actionlRBPath
- language resource bundle pathlRBStartKey
- key to access the "start" localized stringlRBStopKey
- key to access the "stop" localized string
-
RunnablePanelAction
Builds a custom instance of an action to start or stop a runnable- Parameters:
lRBPath
- language resource bundle pathlRBStartKey
- key to access the "start" localized stringlRBStopKey
- key to access the "stop" localized string
-
-
Method Details
-
setPauseAction
-
actionPerformed
-
setLanguage
public void setLanguage()Forces to read localized strings to actualize this. -
isStarted
public boolean isStarted()Returns the runnable status- Returns:
- true if the runnable is started
-
setStarted
public void setStarted(boolean started)Toggles the runnable status, and sets theAction.SMALL_ICON
andAction.NAME
values according to the status. \nThis sets the status to provide a way to know if the runnable is running or not without knowing the process, but doesn't affect the process itself. As starting and stopping the process is usually done in another thread, the responsibility of setting this status is left to the client.- Parameters:
started
- set true if the runnable is started
-
getPanel
Returns the runnable component- Returns:
- the panel, or null
-
setPanel
Sets the JPanel to link to this action, and adds aComponentListener
to enable or disable this action when the panel is shown or not. \nDoes nothing if the parameter is not an instance ofJPanel
.- Parameters:
panel
- the panel to set
-