public class DelegatingEditActionHandler extends AbstractEditActionHandler
EditActionHandler
which delegates to an injected delegate
EditActionHandler
. If the delegate is set to null, this handler
will report that it cannot copy / cut / paste / delete and if another object
tries to invoke the do* methods on this handler, they will be no-ops. This
class is useful for chaining focused components all the way up to the
Designer itself for handling the main edit menu edit actions.listenerList
Constructor and Description |
---|
DelegatingEditActionHandler(EditActionHandler delegate)
Constructor for injecting the
EditActionHandler delegate (can be null) |
Modifier and Type | Method and Description |
---|---|
boolean |
canCopy()
Can this edit action handler handle the copy action, given its current selection? Note that if this and
EditActionHandler.canDelete() both return true, the cut action will also be enabled. |
boolean |
canDelete()
Can this edit action handler handle the delete action, given its current selection? Note that if this and
EditActionHandler.canCopy() both return true, the cut action will also be enabled. |
boolean |
canPaste(java.awt.datatransfer.Clipboard clipboard)
Can this action handler handle a paste given the data flavors currently available in the clipboard?
|
java.awt.datatransfer.Transferable |
doCopy()
Called when the copy action is performed.
|
java.awt.datatransfer.Transferable |
doCut()
Called when the cut action is performed.
|
void |
doDelete()
Called when the delete action is performed
|
void |
doPaste(java.awt.datatransfer.Transferable clipboardContents)
Called when the paste action is performed
|
EditActionHandler |
getDelegate()
Getter for the current delegate to whom this handler is delegating all
edit actions
|
void |
setDelegate(EditActionHandler delegate)
Setter for the delegate of this handler.
|
addChangeListener, fireChangeEvent, removeChangeListener
public DelegatingEditActionHandler(EditActionHandler delegate)
EditActionHandler
delegate (can be null)delegate
- The delegate to injectDelegatingEditActionHandler}
public EditActionHandler getDelegate()
public void setDelegate(EditActionHandler delegate)
delegate
- The delegate to whom this handler will delegate all edit
actionsAbstractEditActionHandler.fireChangeEvent()
,
DelegatingEditActionHandler}
public boolean canDelete()
EditActionHandler
EditActionHandler.canCopy()
both return true, the cut action will also be enabled.public boolean canCopy()
EditActionHandler
EditActionHandler.canDelete()
both return true, the cut action will also be enabled.public boolean canPaste(java.awt.datatransfer.Clipboard clipboard)
EditActionHandler
public void doDelete()
EditActionHandler
public java.awt.datatransfer.Transferable doCopy()
EditActionHandler
Transferable
, or null if the copy failed. Will be added to
the system clipboard.public java.awt.datatransfer.Transferable doCut()
EditActionHandler
Transferable
, or null if the cut failed. Will be added to the
system clipboard.public void doPaste(java.awt.datatransfer.Transferable clipboardContents)
EditActionHandler
clipboardContents
- The current contents of the clipboard to paste.