support drag&drop from the find-file resultlist
authorClaus Gittinger <cg@exept.de>
Tue, 02 Feb 2010 15:19:26 +0100
changeset 9357 e257439bdea5
parent 9356 926b7fe3db6a
child 9358 cb6f7757c128
support drag&drop from the find-file resultlist
FindFileApplication.st
--- a/FindFileApplication.st	Tue Feb 02 14:15:13 2010 +0100
+++ b/FindFileApplication.st	Tue Feb 02 15:19:26 2010 +0100
@@ -386,6 +386,13 @@
               valueChangeSelector: fileSelected:
               useIndex: true
               sequenceList: shownListHolder
+              properties: 
+             (PropertyListDictionary
+                startDragSelector: doStartDrag:in:
+                dragArgument: findFileList
+                displayObjectSelector: getDisplayObjects:
+                dropObjectSelector: getDropObjects:
+              )
             )
            )
          
@@ -1200,6 +1207,48 @@
     super update:something with:aParameter from:changedObject
 ! !
 
+!FindFileApplication methodsFor:'drag & drop'!
+
+getDisplayObjects:anArgument
+    "retrieve the objects displayed during a drag"
+
+    | sel string size fnName stream|
+
+    sel := self selectionHolder value.
+    size := sel size.
+    size == 0  ifTrue:[^ ''].
+
+    stream := WriteStream on:''.
+    stream nextPutAll:((resultList at:sel first) asFilename baseName asString).
+    size == 1 ifTrue:[
+        fnName := 'ui_menuitem.xpm'.
+    ] ifFalse:[
+        fnName := 'ui_submenu_open.xpm'.
+        stream nextPutAll:' ... '.
+        stream nextPutAll:((resultList at:sel last) asFilename baseName asString).
+    ].
+    string := stream contents.
+
+    ^ Array with:(LabelAndIcon 
+                    icon:(Image fromFile:fnName)
+                    string:(Text string:string emphasis:#bold))
+!
+
+getDropObjects:anArgument
+    "common code, used in subclasses"
+
+    |sel|
+
+    sel := self selectionHolder value.
+    ^ sel 
+        collect:[:idx|
+            |el|
+
+            el := resultList at:idx.
+            DropObject newFile:(el asFilename) 
+        ].
+! !
+
 !FindFileApplication methodsFor:'event handling'!
 
 fileDoubleClick:entries
@@ -1813,9 +1862,9 @@
 !FindFileApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.87 2009-10-22 12:41:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.88 2010-02-02 14:19:26 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.87 2009-10-22 12:41:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.88 2010-02-02 14:19:26 cg Exp $'
 ! !