drop handling
authorClaus Gittinger <cg@exept.de>
Sun, 30 Mar 2003 15:04:24 +0200
changeset 4745 8082c278087d
parent 4744 36dfe96e5d23
child 4746 37dc71547964
drop handling
AbstractDirectoryBrowser.st
AbstractFileBrowser.st
--- a/AbstractDirectoryBrowser.st	Sat Mar 29 16:50:26 2003 +0100
+++ b/AbstractDirectoryBrowser.st	Sun Mar 30 15:04:24 2003 +0200
@@ -46,6 +46,27 @@
     ^ inDropMode and:[canDropItem]
 !
 
+doDrop:aContext 
+    |col destinationPath receiver didDrop|
+
+    self dropLeave:aContext.
+
+    destinationPath := self dropDestinationPath.
+    destinationPath ifNil:[^ self].
+
+    aContext dropSource argument == #archivApplication ifTrue:[
+        receiver := aContext dropSource receiver.
+        receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true.
+        ^ self
+    ].
+
+    col := aContext dropObjects collect:[:obj | obj theObject].
+    didDrop := self copyOrMoveFiles:col to:destinationPath.
+    didDrop ifFalse:[
+        aContext clearHasDroppedToSuppressFeedBack
+    ].
+!
+
 dropEnter:aContext
 
     |dropedObjects|
@@ -161,5 +182,5 @@
 !AbstractDirectoryBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractDirectoryBrowser.st,v 1.2 2003-03-29 13:07:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractDirectoryBrowser.st,v 1.3 2003-03-30 13:04:10 cg Exp $'
 ! !
--- a/AbstractFileBrowser.st	Sat Mar 29 16:50:26 2003 +0100
+++ b/AbstractFileBrowser.st	Sun Mar 30 15:04:24 2003 +0200
@@ -3248,14 +3248,15 @@
     "
     |hdl|
 
-
     hdl := DragAndDropManager new.
 
     hdl disabledCursor:self class disabledCursorImage.
     hdl enabledCursor:self class enabledCursorImage.
     hdl alienCursor:nil.
 
-    hdl startDragFrom:aView dropSource:aDropSource offset:#topLeft
+    hdl startDragFrom:aView dropSource:aDropSource offset:#topLeft.
+
+self halt.
 ! !
 
 !AbstractFileBrowser methodsFor:'file operations'!
@@ -3334,8 +3335,10 @@
 !
 
 copyOrMoveFiles:aColOfSourceFiles to:aDestinationDirectory 
-   "copy aColOfSourceFiles to aDirectory
-   "
+    "copy or move aColOfSourceFiles to aDirectory.
+     Asks the used if a move or a copy is wanted.
+     Returns true if the copyOrMove happened, false if user aborted the operation."
+
     |answer lastOld lastNew|
 
     answer := self copyOrMoveDialog:aColOfSourceFiles for:aDestinationDirectory.
@@ -3351,22 +3354,23 @@
                             goodRenameDefaultForFile:srcBase lastOld:lastOld lastNew:lastNew.
             ].
             dstBase := Dialog request:('Copy %1 as:' bindWith:srcBase) initialAnswer:initial.
-            dstBase isNil ifTrue:[^ self].
+            dstBase isNil ifTrue:[^ false].
             self copyFile:eachSourceFile to:(aDestinationDirectory construct:dstBase).
             lastOld := srcBase.
             lastNew := dstBase.
         ].
 
-        ^ self.
+        ^ true.
     ].
     answer == #copy ifTrue:[
         self copyFiles:aColOfSourceFiles to:aDestinationDirectory.
-        ^ self.
+        ^ true.
     ].
     answer == #move ifTrue:[
         self moveFiles:aColOfSourceFiles to:aDestinationDirectory.
-        ^ self.
+        ^ true.
     ].
+    ^ false.
 !
 
 deleteFile:aFile
@@ -6090,5 +6094,5 @@
 !AbstractFileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.119 2003-03-29 13:08:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.120 2003-03-30 13:04:24 cg Exp $'
 ! !