author | Claus Gittinger <cg@exept.de> |
Tue, 01 Apr 2003 16:46:26 +0200 | |
changeset 4754 | e8ff80bb18ea |
parent 4745 | 8082c278087d |
child 4770 | c5c5e793bf3f |
permissions | -rw-r--r-- |
4712 | 1 |
"{ Package: 'stx:libtool' }" |
2 |
||
3 |
AbstractFileBrowser subclass:#AbstractDirectoryBrowser |
|
4 |
instanceVariableNames:'inDropMode canDropItem browser updateToExternFileHolderLock' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'Interface-Tools-File' |
|
8 |
! |
|
9 |
||
10 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
11 |
||
12 |
documentation |
|
13 |
" |
|
14 |
Abstract class containing the common code from DirectoryTreeBrowser and |
|
15 |
DirectoryContentsBrowser applications. |
|
16 |
" |
|
17 |
! ! |
|
18 |
||
19 |
!AbstractDirectoryBrowser methodsFor:'accessing'! |
|
20 |
||
21 |
updateToExternFileHolderLock |
|
22 |
"return the value of the instance variable 'updateToExternFileHolder' (automatically generated)" |
|
23 |
||
24 |
updateToExternFileHolderLock isNil ifTrue:[ |
|
25 |
updateToExternFileHolderLock := self class newLock. |
|
26 |
]. |
|
27 |
^ updateToExternFileHolderLock |
|
28 |
! ! |
|
29 |
||
30 |
!AbstractDirectoryBrowser methodsFor:'drag & drop'! |
|
31 |
||
32 |
autoScrollDownForDrop:aDropContext |
|
33 |
aDropContext saveDraw:[ |
|
34 |
browser scrollDown |
|
35 |
] |
|
36 |
! |
|
37 |
||
38 |
autoScrollUpForDrop:aDropContext |
|
39 |
aDropContext saveDraw:[ |
|
40 |
browser scrollUp |
|
41 |
] |
|
42 |
! |
|
43 |
||
44 |
canDrop:aContext |
|
45 |
||
46 |
^ inDropMode and:[canDropItem] |
|
47 |
! |
|
48 |
||
4745 | 49 |
doDrop:aContext |
50 |
|col destinationPath receiver didDrop| |
|
51 |
||
4754
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
52 |
destinationPath := self dropDestinationPath. |
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
53 |
|
4745 | 54 |
self dropLeave:aContext. |
55 |
||
56 |
destinationPath ifNil:[^ self]. |
|
57 |
||
58 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
59 |
receiver := aContext dropSource receiver. |
|
60 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
|
61 |
^ self |
|
62 |
]. |
|
63 |
||
64 |
col := aContext dropObjects collect:[:obj | obj theObject]. |
|
65 |
didDrop := self copyOrMoveFiles:col to:destinationPath. |
|
66 |
didDrop ifFalse:[ |
|
67 |
aContext clearHasDroppedToSuppressFeedBack |
|
68 |
]. |
|
69 |
! |
|
70 |
||
4712 | 71 |
dropEnter:aContext |
72 |
||
73 |
|dropedObjects| |
|
74 |
||
75 |
self dropTargetItemChangedTo:nil in:aContext. |
|
76 |
inDropMode := false. |
|
77 |
||
78 |
"/ self directory isNil ifTrue:[^ self]. |
|
79 |
dropedObjects := aContext dropObjects. |
|
80 |
||
81 |
dropedObjects do:[:aObject| |
|
82 |
|checkObject checkObjectString| |
|
83 |
||
84 |
aObject isFileObject ifFalse:[^ self]. |
|
85 |
||
86 |
checkObject := aObject theObject. |
|
87 |
checkObject isFilename not ifTrue:[^ self]. |
|
88 |
((aContext dropSource argument == #archivApplication) not) ifTrue:[ |
|
89 |
checkObject isSpecialFile ifTrue:[^ self]. |
|
90 |
checkObject isReadable ifFalse:[^ self]. |
|
91 |
]. |
|
92 |
]. |
|
93 |
inDropMode := true. |
|
94 |
! |
|
95 |
||
96 |
dropLeave:aDropContext |
|
97 |
"send the last time, when leaving the widget |
|
98 |
" |
|
99 |
inDropMode ifFalse:[ ^ self ]. |
|
100 |
||
101 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
102 |
self removeExpandItemTimedBlock. |
|
103 |
inDropMode := false. |
|
104 |
! |
|
105 |
||
106 |
getDropObjects:anArgument |
|
107 |
||
108 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
|
109 |
! |
|
110 |
||
111 |
getLineNumberFor:aDropContext |
|
112 |
| yVisible| |
|
113 |
||
114 |
yVisible := (aDropContext targetPoint y). |
|
115 |
^ browser yVisibleToRowNr:yVisible. |
|
116 |
! |
|
117 |
||
118 |
initiateAutoScrollDownFor:aDropContext |
|
119 |
self window sensor pushUserEvent:#autoScrollDownForDrop: for:self withArgument:aDropContext. |
|
120 |
! |
|
121 |
||
122 |
initiateAutoScrollUpFor:aDropContext |
|
123 |
self window sensor pushUserEvent:#autoScrollUpForDrop: for:self withArgument:aDropContext |
|
124 |
! ! |
|
125 |
||
126 |
!AbstractDirectoryBrowser methodsFor:'file actions'! |
|
127 |
||
128 |
doCopy |
|
129 |
"copy current selected files/directories |
|
130 |
" |
|
131 |
||
132 |
self copyFilesToClipBoard:(self selectedFiles). |
|
133 |
! |
|
134 |
||
135 |
doCut |
|
136 |
"cut current selected files/directories" |
|
137 |
||
138 |
self cutFilesToClipBoard:(self selectedFiles). |
|
139 |
! |
|
140 |
||
141 |
doDelete |
|
142 |
"delete current selected files/directories |
|
143 |
" |
|
4742
972a9d30ec47
enumerate copies of the selection in delete & rename
Claus Gittinger <cg@exept.de>
parents:
4712
diff
changeset
|
144 |
self deleteFiles:(self selectedFiles copy). |
4712 | 145 |
! ! |
146 |
||
147 |
!AbstractDirectoryBrowser methodsFor:'selection'! |
|
148 |
||
149 |
selectedFiles |
|
150 |
||
151 |
^ self selectedItems collect:[:item| item fileName]. |
|
152 |
! ! |
|
153 |
||
154 |
!AbstractDirectoryBrowser methodsFor:'startup & release'! |
|
155 |
||
156 |
initialize |
|
157 |
||
158 |
inDropMode := false. |
|
159 |
^ super initialize. |
|
160 |
! |
|
161 |
||
162 |
postOpenAsSubcanvasWith:aBuilder |
|
163 |
||
164 |
super postOpenAsSubcanvasWith:aBuilder. |
|
165 |
self postOpen. |
|
166 |
! |
|
167 |
||
168 |
postOpenWith:aBuilder |
|
169 |
"only invoked if the application not started from a master" |
|
170 |
||
171 |
super postOpenWith:aBuilder. |
|
172 |
self postOpen. |
|
173 |
! |
|
174 |
||
175 |
preBuildWith:aBuilder |
|
176 |
||
177 |
self masterApplication isNil ifTrue:[ |
|
178 |
self masterApplication:nil. |
|
179 |
]. |
|
180 |
^ super preBuildWith:aBuilder. |
|
181 |
! ! |
|
182 |
||
183 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
184 |
||
185 |
version |
|
4754
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
186 |
^ '$Header: /cvs/stx/stx/libtool/AbstractDirectoryBrowser.st,v 1.4 2003-04-01 14:46:26 cg Exp $' |
4712 | 187 |
! ! |