1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54:
55:
58: public class DragSource implements Serializable
59: {
60:
63: private static final long serialVersionUID = 6236096958971414066L;
64:
65: public static final Cursor DefaultCopyDrop = null;
66: public static final Cursor DefaultMoveDrop = null;
67: public static final Cursor DefaultLinkDrop = null;
68: public static final Cursor DefaultCopyNoDrop = null;
69: public static final Cursor DefaultMoveNoDrop = null;
70: public static final Cursor DefaultLinkNoDrop = null;
71:
72: private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap ();
73:
74: private transient DragSourceListener dragSourceListener;
75: private transient DragSourceMotionListener dragSourceMotionListener;
76:
77:
82: public DragSource()
83: {
84: if (GraphicsEnvironment.isHeadless())
85: throw new HeadlessException ();
86: }
87:
88:
91: public static DragSource getDefaultDragSource()
92: {
93: return new DragSource();
94: }
95:
96: public static boolean isDragImageSupported()
97: {
98: return false;
99: }
100:
101:
108: public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
109: Image dragImage, Point imageOffset,
110: Transferable trans, DragSourceListener dsl,
111: FlavorMap map)
112: {
113: }
114:
115:
122: public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
123: Transferable trans, DragSourceListener dsl,
124: FlavorMap map)
125: {
126: startDrag(trigger, dragCursor, null, null, trans, dsl, map);
127: }
128:
129:
136: public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
137: Image dragImage, Point imageOffset,
138: Transferable trans, DragSourceListener dsl)
139: {
140: startDrag(trigger, dragCursor, dragImage, imageOffset, trans, dsl, null);
141: }
142:
143:
150: public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
151: Transferable trans, DragSourceListener dsl)
152: {
153: startDrag(trigger, dragCursor, null, null, trans, dsl, null);
154: }
155:
156:
162: protected DragSourceContext
163: createDragSourceContext(DragSourceContextPeer peer, DragGestureEvent dge,
164: Cursor cursor, Image image, Point offset,
165: Transferable t, DragSourceListener dsl)
166: {
167: return null;
168: }
169:
170: public FlavorMap getFlavorMap()
171: {
172: return flavorMap;
173: }
174:
175:
178: static class NoDragGestureRecognizer extends DragGestureRecognizer
179: {
180: NoDragGestureRecognizer(DragSource ds, Component c, int actions,
181: DragGestureListener dgl)
182: {
183: super(ds, c, actions, dgl);
184: }
185:
186: protected void registerListeners() { }
187: protected void unregisterListeners() { }
188: }
189:
190: public DragGestureRecognizer
191: createDragGestureRecognizer(Class recognizer, Component c, int actions,
192: DragGestureListener dgl)
193: {
194: DragGestureRecognizer dgr;
195: dgr = Toolkit.getDefaultToolkit ()
196: .createDragGestureRecognizer (recognizer, this, c, actions,
197: dgl);
198:
199: if (dgr == null)
200: dgr = new NoDragGestureRecognizer(this, c, actions, dgl);
201:
202: return dgr;
203: }
204:
205: public DragGestureRecognizer
206: createDefaultDragGestureRecognizer(Component c, int actions,
207: DragGestureListener dgl)
208: {
209: return createDragGestureRecognizer (MouseDragGestureRecognizer.class, c,
210: actions, dgl);
211: }
212:
213:
216: public void addDragSourceListener(DragSourceListener l)
217: {
218: DnDEventMulticaster.add (dragSourceListener, l);
219: }
220:
221:
224: public void removeDragSourceListener(DragSourceListener l)
225: {
226: DnDEventMulticaster.remove (dragSourceListener, l);
227: }
228:
229:
232: public DragSourceListener[] getDragSourceListeners()
233: {
234: return (DragSourceListener[]) getListeners (DragSourceListener.class);
235: }
236:
237:
240: public void addDragSourceMotionListener(DragSourceMotionListener l)
241: {
242: DnDEventMulticaster.add (dragSourceMotionListener, l);
243: }
244:
245:
248: public void removeDragSourceMotionListener(DragSourceMotionListener l)
249: {
250: DnDEventMulticaster.remove (dragSourceMotionListener, l);
251: }
252:
253:
256: public DragSourceMotionListener[] getDragSourceMotionListeners ()
257: {
258: return (DragSourceMotionListener[]) getListeners
259: (DragSourceMotionListener.class);
260: }
261:
262:
265: public EventListener[] getListeners (Class listenerType)
266: {
267: if (listenerType == DragSourceListener.class)
268: return DnDEventMulticaster.getListeners (dragSourceListener,
269: listenerType);
270:
271: if (listenerType == DragSourceMotionListener.class)
272: return DnDEventMulticaster.getListeners (dragSourceMotionListener,
273: listenerType);
274:
275:
276: return new EventListener [0];
277: }
278: }