summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--javax/swing/TransferHandler.java45
2 files changed, 49 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 4db82d7ce..2b89ab850 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/TransferHandler.java
+ (importData): Implemented stub method. Added API docs.
+
2006-10-26 Christian Elias Naur <elias@oddlabs.com>
* native/jni/gtk-peer/gtk_jawt.c (classpath_jawt_get_depth): New
@@ -226,7 +231,7 @@
(argb32): Updated field to match default in BufferedImage.
2006-10-18 Roman Kennke <kennke@aicas.com>
-\
+
PR 29419
* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(copyArea): Changed size comparison to return when size == 0
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index 46a90897b..d594a8244 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -407,10 +407,51 @@ public class TransferHandler implements Serializable
return visualRepresentation;
}
+ /**
+ * Imports the transfer data represented by <code>t</code> into the specified
+ * component <code>c</code> by setting the property of this TransferHandler
+ * on that component. If this succeeds, this method returns
+ * <code>true</code>, otherwise <code>false</code>.
+ *
+ *
+ * @param c the component to import into
+ * @param t the transfer data to import
+ *
+ * @return <code>true</code> if the transfer succeeds, <code>false</code>
+ * otherwise
+ */
public boolean importData(JComponent c, Transferable t)
- throws NotImplementedException
{
- return false;
+ boolean ok = false;
+ PropertyDescriptor prop = getPropertyDescriptor(c);
+ if (prop != null)
+ {
+ Method writer = prop.getWriteMethod();
+ if (writer != null)
+ {
+ Class[] params = writer.getParameterTypes();
+ if (params.length == 1)
+ {
+ DataFlavor flavor = getPropertyDataFlavor(params[0],
+ t.getTransferDataFlavors());
+ if (flavor != null)
+ {
+ try
+ {
+ Object value = t.getTransferData(flavor);
+ writer.invoke(c, new Object[]{ value });
+ ok = true;
+ }
+ catch (Exception ex)
+ {
+ // If anything goes wrong here, do nothing and return
+ // false;
+ }
+ }
+ }
+ }
+ }
+ return ok;
}
/**