swt3.l (1656B)
1 # http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet78.java?view=co 2 3 (load "swt.l") 4 5 (setq D (jnew Display) 6 S (jnew Shell D) ) 7 (S 'setLayout (jnew FillLayout)) 8 (setq L1 (jnew Label S (jfield SWT 'BORDER)) 9 L2 (jnew Label S (jfield SWT 'BORDER)) ) 10 (L1 'setText "TEXT") 11 12 (de s (M E) 13 #(println 's M E) 14 (case M 15 ("dragStart" (jfield E 'doit (n0 ((L 'getText) 'length)))) 16 ("dragSetData" (jfield E 'data (L 'getText))) 17 ("dragFinished" 18 (when (jeq (jfield DND 'DROP_MOVE) (jfield E 'detail)) 19 (L 'setText "") ) ) ) ) 20 21 (de z (M E) 22 #(println 'z M E) 23 (case M 24 ("drop" 25 (if (jeq null (jfield E 'data)) 26 (jfield E 'detail (jfield DND 'DROP_NONE)) 27 (L 'setText (jfield E 'data)) ) ) ) ) 28 29 (de handler (K V F) # TODO curry 30 (cons 'quote (list '@ (list 'job (cons 'quote (list (cons K V))) (list 'pass F)))) ) 31 32 (de setDragDrop (L) 33 (let (X ((jvector (TextTransfer 'getInstance)) 'toArray 34 ((jclass 'java.lang.reflect.Array) 'newInstance 35 (jclass 'org.eclipse.swt.dnd.Transfer) 36 1 ) ) 37 O (| (jnum (jfield DND 'DROP_MOVE)) 38 (jnum (jfield DND 'DROP_COPY)) 39 (jnum (jfield DND 'DROP_LINK)) ) 40 S (jnew DragSource L O) 41 Z (jnew DropTarget L O) ) 42 (S 'setTransfer X) 43 (Z 'setTransfer X) 44 (S 'addDragListener (jproxy NIL (handler 'L L 's) DragSourceListener)) 45 (Z 'addDropListener (jproxy NIL (handler 'L L 'z) DropTargetListener)) ) ) 46 47 (setDragDrop L1) 48 (setDragDrop L2) 49 (S 'setSize 200 200) 50 (S 'open) 51 (swtLoop D S)