org.openide.util.datatransfer
Class ExClipboard

java.lang.Object
  extended by java.awt.datatransfer.Clipboard
      extended by org.openide.util.datatransfer.ExClipboard

public abstract class ExClipboard
extends java.awt.datatransfer.Clipboard

Extended clipboard that supports listeners that can be notified about changes of content. Also contains support for attaching content convertors.

Author:
Jaroslav Tulach

Nested Class Summary
static interface ExClipboard.Convertor
          Convertor that can convert the contents of a clipboard to additional flavors.
 
Field Summary
 
Fields inherited from class java.awt.datatransfer.Clipboard
contents, owner
 
Constructor Summary
ExClipboard(java.lang.String name)
          Make a new clipboard.
 
Method Summary
 void addClipboardListener(ClipboardListener list)
          Add a listener to clipboard operations.
 java.awt.datatransfer.Transferable convert(java.awt.datatransfer.Transferable t)
          Method that takes a transferable, applies all convertors, and creates a new transferable using the abilities of the convertors.
protected  void fireClipboardChange()
          Fires event about change of content in the clipboard.
protected abstract  ExClipboard.Convertor[] getConvertors()
          Obtain a list of convertors assigned to this clipboard.
 void removeClipboardListener(ClipboardListener list)
          Remove a listener to clipboard operations.
 void setContents(java.awt.datatransfer.Transferable contents, java.awt.datatransfer.ClipboardOwner owner)
           
static void transferableAccepted(java.awt.datatransfer.Transferable t, int action)
          Notifies the transferable that it has been accepted by a drop.
static void transferableOwnershipLost(java.awt.datatransfer.Transferable t)
          Notifies the transferable that it has lost ownership in clipboard.
static void transferableRejected(java.awt.datatransfer.Transferable t)
          Notifies the transferable that it has been rejected by a drop.
 
Methods inherited from class java.awt.datatransfer.Clipboard
addFlavorListener, getAvailableDataFlavors, getContents, getData, getFlavorListeners, getName, isDataFlavorAvailable, removeFlavorListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExClipboard

public ExClipboard(java.lang.String name)
Make a new clipboard.

Parameters:
name - name of the clipboard
Method Detail

addClipboardListener

public final void addClipboardListener(ClipboardListener list)
Add a listener to clipboard operations.

Parameters:
list - the listener

removeClipboardListener

public final void removeClipboardListener(ClipboardListener list)
Remove a listener to clipboard operations.

Parameters:
list - the listener

fireClipboardChange

protected final void fireClipboardChange()
Fires event about change of content in the clipboard.


getConvertors

protected abstract ExClipboard.Convertor[] getConvertors()
Obtain a list of convertors assigned to this clipboard.

Returns:
the convertors

convert

public java.awt.datatransfer.Transferable convert(java.awt.datatransfer.Transferable t)
Method that takes a transferable, applies all convertors, and creates a new transferable using the abilities of the convertors.

This method is used when the contents of the clipboard are changed and also can be used by Drag & Drop to process transferables between source and target.

Note that it is possible for the results to vary according to order of the convertors as specified by getConvertors(). For example, the input transferable may contain flavor A, and there may be a convertor from A to B, and one from B to C; flavor B will always be available, but flavor C will only be available if the convertor list is in the order that these were mentioned. Since the standard clipboard implementation searches for convertors in lookup as well as manifests, ordering might be specified between a set of layer-supplied convertors by means of folder ordering attributes.

Parameters:
t - input transferable
Returns:
new transferable

transferableAccepted

public static void transferableAccepted(java.awt.datatransfer.Transferable t,
                                        int action)
Notifies the transferable that it has been accepted by a drop. Works only for ExTransferable, other types of transferables are not notified.

Parameters:
t - transferable to notify its listeners
action - which action has been performed

transferableRejected

public static void transferableRejected(java.awt.datatransfer.Transferable t)
Notifies the transferable that it has been rejected by a drop. Works only for ExTransferable, other types of transferables are not notified.

Parameters:
t - transferable to notify its listeners

setContents

public void setContents(java.awt.datatransfer.Transferable contents,
                        java.awt.datatransfer.ClipboardOwner owner)
Overrides:
setContents in class java.awt.datatransfer.Clipboard

transferableOwnershipLost

public static void transferableOwnershipLost(java.awt.datatransfer.Transferable t)
Notifies the transferable that it has lost ownership in clipboard. Works only for ExTransferable, other types of transferables are not notified.

Parameters:
t - transferable to notify its listeners