Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.awt.peer.gtk
Class GtkSelection  view GtkSelection download GtkSelection.java

java.lang.Object
  extended bygnu.java.awt.peer.gtk.GtkSelection
All Implemented Interfaces:
java.awt.datatransfer.Transferable

public class GtkSelection
extends java.lang.Object
implements java.awt.datatransfer.Transferable

Class representing the gtk+ clipboard selection. This is used when another program owns the clipboard. Whenever the system clipboard selection changes we create a new instance to notify the program that the available flavors might have changed. When requested it (lazily) caches the targets, and (text, image, or files/uris) clipboard contents.


Field Summary
private  byte[] bytes
          Set as response to a requestBytes(String) call.
private  boolean bytesDelivered
          Indicates a requestBytes(String) call was made and the corresponding bytesAvailable() callback was triggered.
private  boolean clipboard
          Whether we belong to the Clipboard (true) or to the Primary selection.
private  java.awt.datatransfer.DataFlavor[] dataFlavors
          Set and returned by getTransferDataFlavors.
private  java.awt.Image image
          Cached image value.
private  boolean imageDelivered
          Indicates a requestImage() call was made and the corresponding imageAvailable() callback was triggered.
private  gnu.classpath.Pointer imagePointer
          Set as response to a requestImage() call and possibly returned by getTransferData() for image targets.
private  boolean mimeTypesDelivered
          Indicates a requestMimeTypes() call was made and the corresponding mimeTypesAvailable() callback was triggered.
private  boolean requestInProgress
          Whether a request for mimetypes, text, images, uris or byte[] is currently in progress.
private static java.lang.Object requestLock
          Static lock used for requests of mimetypes and contents retrieval.
private  java.lang.String text
          Set as response to a requestText() call and possibly returned by getTransferData() for text targets.
private  boolean textDelivered
          Indicates a requestText() call was made and the corresponding textAvailable() callback was triggered.
private  java.util.List uris
          Set as response to a requestURIs() call.
private  boolean urisDelivered
          Indicates a requestUris() call was made and the corresponding urisAvailable() callback was triggered.
 
Constructor Summary
(package private) GtkSelection(GtkClipboard clipboard)
          Should only be created by the GtkClipboard class.
 
Method Summary
private  void bytesAvailable(byte[] bytes)
          Callback that sets the available byte array on the clipboard.
private  byte[] getBytes(java.lang.String target)
          Helper method that requests a byte[] for the given target mime-type flavor and waits till it is available.
private  java.awt.Image getImage()
          Helper method that tests whether we already have an image for the current gtk+ selection on the clipboard and if not requests it and waits till it is available.
private  java.lang.String getText()
          Helper method that tests whether we already have the text for the current gtk+ selection on the clipboard and if not requests it and waits till it is available.
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          Returns the data in the specified DataFlavor.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Gets an array of mime-type strings from the gtk+ clipboard and transforms them into an array of DataFlavors.
private  java.util.List getURIs()
          Helper method that test whether we already have a list of URIs/Files and if not requests them and waits till they are available.
private  void imageAvailable(gnu.classpath.Pointer pointer)
          Callback that sets the available image on the clipboard.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Gets the available data flavors for this selection and checks that at least one of them is equal to the given DataFlavor.
private  void mimeTypesAvailable(java.lang.String[] mimeTypes)
          Callback that sets the available DataFlavors[].
private  void requestBytes(boolean clipboard, java.lang.String target)
           
private  void requestImage(boolean clipboard)
           
private  void requestMimeTypes(boolean clipboard)
           
private  void requestText(boolean clipboard)
           
private  void requestURIs(boolean clipboard)
           
private  void textAvailable(java.lang.String text)
          Callback that sets the available text on the clipboard.
private  void urisAvailable(java.lang.String[] uris)
          Callback that sets the available File list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestLock

private static java.lang.Object requestLock
Static lock used for requests of mimetypes and contents retrieval.


clipboard

private final boolean clipboard
Whether we belong to the Clipboard (true) or to the Primary selection.


requestInProgress

private boolean requestInProgress
Whether a request for mimetypes, text, images, uris or byte[] is currently in progress. Should only be tested or set with requestLock held. When true no other requests should be made till it is false again.


mimeTypesDelivered

private boolean mimeTypesDelivered
Indicates a requestMimeTypes() call was made and the corresponding mimeTypesAvailable() callback was triggered.


dataFlavors

private java.awt.datatransfer.DataFlavor[] dataFlavors
Set and returned by getTransferDataFlavors. Only valid when mimeTypesDelivered is true.


textDelivered

private boolean textDelivered
Indicates a requestText() call was made and the corresponding textAvailable() callback was triggered.


text

private java.lang.String text
Set as response to a requestText() call and possibly returned by getTransferData() for text targets. Only valid when textDelivered is true.


imageDelivered

private boolean imageDelivered
Indicates a requestImage() call was made and the corresponding imageAvailable() callback was triggered.


imagePointer

private gnu.classpath.Pointer imagePointer
Set as response to a requestImage() call and possibly returned by getTransferData() for image targets. Only valid when imageDelivered is true and image is null.


image

private java.awt.Image image
Cached image value. Only valid when imageDelivered is true. Created from imagePointer.


urisDelivered

private boolean urisDelivered
Indicates a requestUris() call was made and the corresponding urisAvailable() callback was triggered.


uris

private java.util.List uris
Set as response to a requestURIs() call. Only valid when urisDelivered is true


bytesDelivered

private boolean bytesDelivered
Indicates a requestBytes(String) call was made and the corresponding bytesAvailable() callback was triggered.


bytes

private byte[] bytes
Set as response to a requestBytes(String) call. Only valid when bytesDelivered is true.

Constructor Detail

GtkSelection

GtkSelection(GtkClipboard clipboard)
Should only be created by the GtkClipboard class. The clipboard should be either GtkClipboard.clipboard or GtkClipboard.selection.

Method Detail

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Gets an array of mime-type strings from the gtk+ clipboard and transforms them into an array of DataFlavors.

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

mimeTypesAvailable

private void mimeTypesAvailable(java.lang.String[] mimeTypes)
Callback that sets the available DataFlavors[]. Note that this should not call any code that could need the main gdk lock.


isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Gets the available data flavors for this selection and checks that at least one of them is equal to the given DataFlavor.

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

getText

private java.lang.String getText()
Helper method that tests whether we already have the text for the current gtk+ selection on the clipboard and if not requests it and waits till it is available.


textAvailable

private void textAvailable(java.lang.String text)
Callback that sets the available text on the clipboard. Note that this should not call any code that could need the main gdk lock.


getImage

private java.awt.Image getImage()
Helper method that tests whether we already have an image for the current gtk+ selection on the clipboard and if not requests it and waits till it is available.


imageAvailable

private void imageAvailable(gnu.classpath.Pointer pointer)
Callback that sets the available image on the clipboard. Note that this should not call any code that could need the main gdk lock. Note that we get a Pointer to a GdkPixbuf which we cannot turn into a real GtkImage at this point. That will be done on the "user thread" in getImage().


getURIs

private java.util.List getURIs()
Helper method that test whether we already have a list of URIs/Files and if not requests them and waits till they are available.


urisAvailable

private void urisAvailable(java.lang.String[] uris)
Callback that sets the available File list. Note that this should not call any code that could need the main gdk lock.


getBytes

private byte[] getBytes(java.lang.String target)
Helper method that requests a byte[] for the given target mime-type flavor and waits till it is available. Note that unlike the other get methods this one doesn't cache the result since there are possibly many targets.


bytesAvailable

private void bytesAvailable(byte[] bytes)
Callback that sets the available byte array on the clipboard. Note that this should not call any code that could need the main gdk lock.


getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException
Description copied from interface: java.awt.datatransfer.Transferable
Returns the data in the specified DataFlavor.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable

requestText

private void requestText(boolean clipboard)

requestImage

private void requestImage(boolean clipboard)

requestURIs

private void requestURIs(boolean clipboard)

requestBytes

private void requestBytes(boolean clipboard,
                          java.lang.String target)

requestMimeTypes

private void requestMimeTypes(boolean clipboard)