40 import java.awt.dnd.DropTargetEvent;
41 import java.awt.dnd.DropTargetDragEvent;
42 import java.awt.dnd.DropTargetDropEvent;
43 import java.awt.dnd.InvalidDnDOperationException;
44
45 import java.awt.dnd.peer.DropTargetContextPeer;
46
47 import java.util.HashSet;
48 import java.util.Map;
49 import java.util.Arrays;
50
51 import sun.util.logging.PlatformLogger;
52
53 import java.io.IOException;
54 import java.io.InputStream;
55
56 import sun.awt.AppContext;
57 import sun.awt.SunToolkit;
58 import sun.awt.datatransfer.DataTransferer;
59 import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
60
61 /**
62 * <p>
63 * The SunDropTargetContextPeer class is the generic class responsible for handling
64 * the interaction between a windowing systems DnD system and Java.
65 * </p>
66 *
67 * @since JDK1.3.1
68 *
69 */
70
71 public abstract class SunDropTargetContextPeer implements DropTargetContextPeer, Transferable {
72
73 /*
74 * A boolean constant that requires the peer to wait until the
75 * SunDropTargetEvent is processed and return the status back
76 * to the native code.
77 */
78 public static final boolean DISPATCH_SYNC = true;
79 private DropTarget currentDT;
208 } else {
209 return DataTransferer.getInstance().getFlavorsForFormats
210 (currentT, DataTransferer.adaptFlavorMap
211 (currentDT.getFlavorMap())).
212 containsKey(df);
213 }
214 }
215
216 /**
217 * @return the data
218 */
219
220 public Object getTransferData(DataFlavor df)
221 throws UnsupportedFlavorException, IOException,
222 InvalidDnDOperationException
223 {
224
225 SecurityManager sm = System.getSecurityManager();
226 try {
227 if (!dropInProcess && sm != null) {
228 sm.checkSystemClipboardAccess();
229 }
230 } catch (Exception e) {
231 Thread currentThread = Thread.currentThread();
232 currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, e);
233 return null;
234 }
235
236 Long lFormat = null;
237 Transferable localTransferable = local;
238
239 if (localTransferable != null) {
240 return localTransferable.getTransferData(df);
241 }
242
243 if (dropStatus != STATUS_ACCEPT || dropComplete) {
244 throw new InvalidDnDOperationException("No drop current");
245 }
246
247 Map flavorMap = DataTransferer.getInstance().getFlavorsForFormats
248 (currentT, DataTransferer.adaptFlavorMap
|
40 import java.awt.dnd.DropTargetEvent;
41 import java.awt.dnd.DropTargetDragEvent;
42 import java.awt.dnd.DropTargetDropEvent;
43 import java.awt.dnd.InvalidDnDOperationException;
44
45 import java.awt.dnd.peer.DropTargetContextPeer;
46
47 import java.util.HashSet;
48 import java.util.Map;
49 import java.util.Arrays;
50
51 import sun.util.logging.PlatformLogger;
52
53 import java.io.IOException;
54 import java.io.InputStream;
55
56 import sun.awt.AppContext;
57 import sun.awt.SunToolkit;
58 import sun.awt.datatransfer.DataTransferer;
59 import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
60 import sun.security.util.SecurityConstants;
61
62 /**
63 * <p>
64 * The SunDropTargetContextPeer class is the generic class responsible for handling
65 * the interaction between a windowing systems DnD system and Java.
66 * </p>
67 *
68 * @since JDK1.3.1
69 *
70 */
71
72 public abstract class SunDropTargetContextPeer implements DropTargetContextPeer, Transferable {
73
74 /*
75 * A boolean constant that requires the peer to wait until the
76 * SunDropTargetEvent is processed and return the status back
77 * to the native code.
78 */
79 public static final boolean DISPATCH_SYNC = true;
80 private DropTarget currentDT;
209 } else {
210 return DataTransferer.getInstance().getFlavorsForFormats
211 (currentT, DataTransferer.adaptFlavorMap
212 (currentDT.getFlavorMap())).
213 containsKey(df);
214 }
215 }
216
217 /**
218 * @return the data
219 */
220
221 public Object getTransferData(DataFlavor df)
222 throws UnsupportedFlavorException, IOException,
223 InvalidDnDOperationException
224 {
225
226 SecurityManager sm = System.getSecurityManager();
227 try {
228 if (!dropInProcess && sm != null) {
229 sm.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
230 }
231 } catch (Exception e) {
232 Thread currentThread = Thread.currentThread();
233 currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, e);
234 return null;
235 }
236
237 Long lFormat = null;
238 Transferable localTransferable = local;
239
240 if (localTransferable != null) {
241 return localTransferable.getTransferData(df);
242 }
243
244 if (dropStatus != STATUS_ACCEPT || dropComplete) {
245 throw new InvalidDnDOperationException("No drop current");
246 }
247
248 Map flavorMap = DataTransferer.getInstance().getFlavorsForFormats
249 (currentT, DataTransferer.adaptFlavorMap
|