summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-10-17 20:15:43 +0000
committerRoman Kennke <roman@kennke.org>2006-10-17 20:15:43 +0000
commita86ca2a463e3e5e7dc970235836e9158cda50e22 (patch)
tree5100cfa8de7d3b71fc6eb57cae0a0bd4aad9fdbc
parent74407d1c20ed940cfbf10b3221eb32a096819fa8 (diff)
downloadclasspath-a86ca2a463e3e5e7dc970235836e9158cda50e22.tar.gz
2006-10-17 Roman Kennke <kennke@aicas.com>
* javax/swing/TransferHandler.java (exportToClipboard): Implemented.
-rw-r--r--ChangeLog5
-rw-r--r--javax/swing/TransferHandler.java41
2 files changed, 44 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 28b027344..319310c9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/TransferHandler.java
+ (exportToClipboard): Implemented.
+
2006-10-17 Francis Kung <fkung@redhat.com>
* gnu/java/awt/peer/gtk/BufferedImageGraphics.java (draw): Extend updated
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index c9cb0856b..46a90897b 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -354,10 +354,47 @@ public class TransferHandler implements Serializable
// Nothing to do in the default implementation.
}
+ /**
+ * Exports the property of the component <code>c</code> that was
+ * specified for this TransferHandler to the clipboard, performing
+ * the specified action.
+ *
+ * This will check if the action is allowed by calling
+ * {@link #getSourceActions(JComponent)}. If the action is not allowed,
+ * then no export is performed.
+ *
+ * In either case the method {@link #exportDone} will be called with
+ * the action that has been performed, or {@link #NONE} if the action
+ * was not allowed or could otherwise not be completed.
+ * Any IllegalStateException that is thrown by the Clipboard due to
+ * beeing unavailable will be propagated through this method.
+ *
+ * @param c the component from which to export
+ * @param clip the clipboard to which the data will be exported
+ * @param action the action to perform
+ *
+ * @throws IllegalStateException when the clipboard is not available
+ */
public void exportToClipboard(JComponent c, Clipboard clip, int action)
- throws NotImplementedException
+ throws IllegalStateException
{
- // TODO: Implement this properly
+ action &= getSourceActions(c);
+ Transferable transferable = createTransferable(c);
+ if (transferable != null && action != NONE)
+ {
+ try
+ {
+ clip.setContents(transferable, null);
+ exportDone(c, transferable, action);
+ }
+ catch (IllegalStateException ex)
+ {
+ exportDone(c, transferable, NONE);
+ throw ex;
+ }
+ }
+ else
+ exportDone(c, null, NONE);
}
public int getSourceActions(JComponent c)