org.openide.util.actions
Class CallableSystemAction

java.lang.Object
  extended by org.openide.util.SharedClassObject
      extended by org.openide.util.actions.SystemAction
          extended by org.openide.util.actions.CallableSystemAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Externalizable, java.io.Serializable, java.util.EventListener, javax.swing.Action, Presenter, Presenter.Menu, Presenter.Popup, Presenter.Toolbar, HelpCtx.Provider
Direct Known Subclasses:
CallbackSystemAction

public abstract class CallableSystemAction
extends SystemAction
implements Presenter.Menu, Presenter.Popup, Presenter.Toolbar

An action which may be called programmatically. Typically a presenter will call its performAction() method, which must be implemented.

Provides default presenters using the Actions utility class.

Author:
Ian Formanek, Jaroslav Tulach, Jan Jancura, Petr Hamernik
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
Nested classes/interfaces inherited from interface org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
Nested classes/interfaces inherited from interface org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
Field Summary
(package private) static long serialVersionUID
          serialVersionUID
 
Fields inherited from class org.openide.util.actions.SystemAction
PROP_ENABLED, PROP_ICON
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
CallableSystemAction()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ev)
          Actually perform the action.
protected  boolean asynchronous()
          If true, this action should be performed asynchronously in a private thread.
 javax.swing.JMenuItem getMenuPresenter()
          Get a menu item that can present this action in a JMenu.
 javax.swing.JMenuItem getPopupPresenter()
          Get a menu item that can present this action in a JPopupMenu.
 java.awt.Component getToolbarPresenter()
          Get a component that can present this action in a JToolBar.
abstract  void performAction()
          Actually perform the action.
 
Methods inherited from class org.openide.util.actions.SystemAction
clearSharedData, createPopupMenu, createToolbarPresenter, get, getHelpCtx, getIcon, getIcon, getName, getValue, iconResource, initialize, isEnabled, linkActions, putValue, setEnabled, setIcon
 
Methods inherited from class org.openide.util.SharedClassObject
addNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, putProperty, putProperty, readExternal, removeNotify, removePropertyChangeListener, reset, writeExternal, writeReplace
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

serialVersionUID

static final long serialVersionUID
serialVersionUID

See Also:
Constant Field Values
Constructor Detail

CallableSystemAction

public CallableSystemAction()
Method Detail

getMenuPresenter

public javax.swing.JMenuItem getMenuPresenter()
Description copied from interface: Presenter.Menu
Get a menu item that can present this action in a JMenu. If your menu content is dynamic in nature, consider using DynamicMenuContent

Specified by:
getMenuPresenter in interface Presenter.Menu
Returns:
the representation for this action

getPopupPresenter

public javax.swing.JMenuItem getPopupPresenter()
Description copied from interface: Presenter.Popup
Get a menu item that can present this action in a JPopupMenu. If your menu content is dynamic in nature, consider using DynamicMenuContent

Specified by:
getPopupPresenter in interface Presenter.Popup
Returns:
the representation for this action

getToolbarPresenter

public java.awt.Component getToolbarPresenter()
Description copied from interface: Presenter.Toolbar
Get a component that can present this action in a JToolBar.

Specified by:
getToolbarPresenter in interface Presenter.Toolbar
Returns:
the representation for this action

performAction

public abstract void performAction()
Actually perform the action. This is the method which should be called programmatically. Presenters in Actions use this.

See SystemAction.actionPerformed(java.awt.event.ActionEvent) for a note on threading usage: in particular, do not access GUI components without explicitly asking for the AWT event thread!


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ev)
Description copied from class: SystemAction
Actually perform the action. Specified in ActionListener.actionPerformed(java.awt.event.ActionEvent).

In some cases, the implementation may have an empty body, if the presenters handle the performing of the action in a different way than by calling this method.

Since 4.11, will be performed directly in the event thread.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Specified by:
actionPerformed in class SystemAction
Parameters:
ev - the event triggering the action

asynchronous

protected boolean asynchronous()
If true, this action should be performed asynchronously in a private thread. If false, it will be performed synchronously as called in the event thread.

The default value is true for compatibility reasons; subclasses are strongly encouraged to override it to be false, and to either do their work promptly in the event thread and return, or to somehow do work asynchronously (for example using RequestProcessor.getDefault()).

You may currently set the global default to false by setting the system property org.openide.util.actions.CallableSystemAction.synchronousByDefault to true.

When true, the current implementation also provides for a wait cursor during the execution of the action. Subclasses which override to return false should consider directly providing a wait or busy cursor if the nature of the action merits it.

Returns:
true if this action should automatically be performed asynchronously
Since:
4.11