站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

PasteAction (NetBeans APIs) - NetBeans API Javadoc 4.1.0


org.openide.actions
Class PasteAction

java.lang.Object
  extended byorg.openide.util.SharedClassObject
      extended byorg.openide.util.actions.SystemAction
          extended byorg.openide.util.actions.CallableSystemAction
              extended byorg.openide.util.actions.CallbackSystemAction
                  extended byorg.openide.actions.PasteAction
All Implemented Interfaces:
Action, ActionListener, ContextAwareAction, EventListener, Externalizable, HelpCtx.Provider, Presenter, Presenter.Menu, Presenter.Popup, Presenter.Toolbar, Serializable

public final class PasteAction
extends CallbackSystemAction

Paste from clipboard. This is a callback system action, with enhanced behaviour. Others can plug in by adding

 topcomponent.getActionMap ().put (javax.swing.text.DefaultEditorKit.pasteAction, theActualAction);
 
or by using the now deprecated setPasteTypes and setActionPerformer methods.

There is a special support for more than one type of paste to be enabled at once. If the theActualAction returns array of actions from getValue ("delegates") than those actions are offered as subelements by the paste action presenter.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
Field Summary
 
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
PasteAction()
           
 
Method Summary
 void actionPerformed(ActionEvent ev)
          Perform the action.
protected  boolean asynchronous()
          If true, this action should be performed asynchronously in a private thread.
 Action createContextAwareInstance(Lookup actionContext)
          Implements ContextAwareAction interface method.
 Object getActionMapKey()
          Getter for action map key, which is used to find action from provided context (i.e.
 HelpCtx getHelpCtx()
          Get a help context for the action.
 JMenuItem getMenuPresenter()
          Get a menu item that can present this action in a JMenu.
 String getName()
          Get a human presentable name of the action.
 PasteType[] getPasteTypes()
          Get all paste types.
 JMenuItem getPopupPresenter()
          Get a menu item that can present this action in a JPopupMenu.
protected  String iconResource()
          Specify the proper resource name for the action's icon.
protected  void initialize()
          Initialize the action to have no performer.
 void setPasteTypes(PasteType[] types)
          Deprecated. Use TopComponent.getActionMap ().put (javax.swing.text.DefaultEditorKit.pasteAction, yourPasteAction); If you want register more paste types then use an action which delegates to an array of PasteAction or also can delegate to an array of org.openide.util.datatransfer.PasteType.
 
Methods inherited from class org.openide.util.actions.CallbackSystemAction
getActionPerformer, getSurviveFocusChange, performAction, setActionPerformer, setSurviveFocusChange
 
Methods inherited from class org.openide.util.actions.CallableSystemAction
getToolbarPresenter
 
Methods inherited from class org.openide.util.actions.SystemAction
clearSharedData, createPopupMenu, createToolbarPresenter, get, getIcon, getIcon, getValue, 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, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 

Constructor Detail

PasteAction

public PasteAction()
Method Detail

initialize

protected void initialize()
Description copied from class: CallbackSystemAction
Initialize the action to have no performer.

Overrides:
initialize in class CallbackSystemAction

getName

public String getName()
Description copied from class: SystemAction
Get a human presentable name of the action. This may be presented as an item in a menu.

Using the normal menu presenters, an included ampersand before a letter will be treated as the name of a mnemonic.

Specified by:
getName in class SystemAction
Returns:
the name of the action

getHelpCtx

public HelpCtx getHelpCtx()
Description copied from class: SystemAction
Get a help context for the action.

Specified by:
getHelpCtx in interface HelpCtx.Provider
Specified by:
getHelpCtx in class SystemAction
Returns:
the help context for this action

iconResource

protected String iconResource()
Description copied from class: SystemAction
Specify the proper resource name for the action's icon. May be overridden by subclasses; the default is to have no icon. Typically this should be a 16x16 color GIF. Do not use relative paths nor an initial slash. If e.g. myIcon.gif is accompanied with myIcon_pressed.gif, myIcon_disabled.gif and/or myIcon_rollover.gif these images are used to call methods on JButton.setPressedIcon(), JButton.setDisabledIcon() and/or JButton.setRolloverIcon() with appropriate images. Please check Actions.connect(AbstractButton, Action) for additional info how this is achieved (using special "iconBase" key for getValue). As of APIs version 3.24, this path will be used for a localized search automatically.

Overrides:
iconResource in class SystemAction
Returns:
the resource name for the icon, e.g. com/mycom/mymodule/myIcon.gif; or null to have no icon (make a text label)

getMenuPresenter

public JMenuItem getMenuPresenter()
Description copied from interface: Presenter.Menu
Get a menu item that can present this action in a JMenu.

Specified by:
getMenuPresenter in interface Presenter.Menu
Overrides:
getMenuPresenter in class CallableSystemAction

getPopupPresenter

public JMenuItem getPopupPresenter()
Description copied from interface: Presenter.Popup
Get a menu item that can present this action in a JPopupMenu.

Specified by:
getPopupPresenter in interface Presenter.Popup
Overrides:
getPopupPresenter in class CallableSystemAction

createContextAwareInstance

public Action createContextAwareInstance(Lookup actionContext)
Description copied from class: CallbackSystemAction
Implements ContextAwareAction interface method.

Specified by:
createContextAwareInstance in interface ContextAwareAction
Overrides:
createContextAwareInstance in class CallbackSystemAction

getActionMapKey

public Object getActionMapKey()
Description copied from class: CallbackSystemAction
Getter for action map key, which is used to find action from provided context (i.e. ActionMap provided by the context), which acts as a callback. Override this method in subclasses to provide 'nice' key.

Overrides:
getActionMapKey in class CallbackSystemAction
Returns:
key which is used to find the action which performs callback, default returned key is a class name.

actionPerformed

public void actionPerformed(ActionEvent ev)
Description copied from class: CallbackSystemAction
Perform the action. Tries the performer and then scans the ActionMap of selected topcomponent.

Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class CallbackSystemAction

asynchronous

protected boolean asynchronous()
Description copied from class: CallableSystemAction
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.

Overrides:
asynchronous in class CallableSystemAction
Returns:
true if this action should automatically be performed asynchronously

setPasteTypes

public void setPasteTypes(PasteType[] types)
Deprecated. Use TopComponent.getActionMap ().put (javax.swing.text.DefaultEditorKit.pasteAction, yourPasteAction); If you want register more paste types then use an action which delegates to an array of PasteAction or also can delegate to an array of org.openide.util.datatransfer.PasteType.

Set possible paste types. Automatically enables or disables the paste action according to whether there are any.

Parameters:
types - the new types to allow, or null

getPasteTypes

public PasteType[] getPasteTypes()
Get all paste types.

Returns:
all possible paste types, or null


Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.