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

public class RunnablePanelAction extends AbstractAction
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 Details

    • FORCE_START_COMMAND

      public static final String 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" action
      stopProcessImage - icon associated to the "stop" action
      lRBPath - language resource bundle path
      lRBStartKey - key to access the "start" localized string
      lRBStopKey - key to access the "stop" localized string
    • RunnablePanelAction

      public RunnablePanelAction(String lRBPath, String lRBStartKey, String lRBStopKey)
      Builds a custom instance of an action to start or stop a runnable
      Parameters:
      lRBPath - language resource bundle path
      lRBStartKey - key to access the "start" localized string
      lRBStopKey - key to access the "stop" localized string
  • Method Details

    • setPauseAction

      public void setPauseAction(RunnablePanelPauseAction pauseAction)
    • actionPerformed

      public void actionPerformed(ActionEvent e)
    • 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 the Action.SMALL_ICON and Action.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

      public JPanel getPanel()
      Returns the runnable component
      Returns:
      the panel, or null
    • setPanel

      public void setPanel(IRunnablePanel panel)
      Sets the JPanel to link to this action, and adds a ComponentListener to enable or disable this action when the panel is shown or not. \nDoes nothing if the parameter is not an instance of JPanel.
      Parameters:
      panel - the panel to set