author | Claus Gittinger <cg@exept.de> |
Tue, 17 Jul 2018 13:40:33 +0200 | |
changeset 18270 | 07b44c3ea287 |
parent 18214 | e7e8fd9c292f |
child 18281 | 906957435fec |
permissions | -rw-r--r-- |
17866 | 1 |
"{ Encoding: utf8 }" |
2 |
||
5139 | 3 |
" |
4 |
COPYRIGHT (c) 2003 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
4712 | 14 |
"{ Package: 'stx:libtool' }" |
15 |
||
16912 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
4712 | 18 |
AbstractFileBrowser subclass:#AbstractDirectoryBrowser |
19 |
instanceVariableNames:'inDropMode canDropItem browser updateToExternFileHolderLock' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Tools-File' |
|
23 |
! |
|
24 |
||
25 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
26 |
||
5139 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2003 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
4712 | 41 |
documentation |
42 |
" |
|
43 |
Abstract class containing the common code from DirectoryTreeBrowser and |
|
44 |
DirectoryContentsBrowser applications. |
|
5967 | 45 |
|
46 |
[Author:] |
|
47 |
Christian Penk |
|
4712 | 48 |
" |
49 |
! ! |
|
50 |
||
17289 | 51 |
!AbstractDirectoryBrowser class methodsFor:'queries'! |
52 |
||
53 |
isAbstract |
|
54 |
^ self == AbstractDirectoryBrowser |
|
55 |
! ! |
|
56 |
||
4712 | 57 |
!AbstractDirectoryBrowser methodsFor:'accessing'! |
58 |
||
59 |
updateToExternFileHolderLock |
|
60 |
updateToExternFileHolderLock isNil ifTrue:[ |
|
61 |
updateToExternFileHolderLock := self class newLock. |
|
62 |
]. |
|
63 |
^ updateToExternFileHolderLock |
|
64 |
! ! |
|
65 |
||
18270 | 66 |
!AbstractDirectoryBrowser methodsFor:'actions'! |
67 |
||
68 |
findFilesMatching:aGLOBPattern |
|
69 |
|matching| |
|
70 |
||
71 |
matching := OrderedCollection new. |
|
72 |
self directory recursiveDirectoryContentsAsFilenamesDo:[:each | |
|
73 |
(aGLOBPattern match:each baseName) ifTrue:[ |
|
74 |
matching add:each |
|
75 |
]. |
|
76 |
]. |
|
77 |
^ matching |
|
78 |
||
79 |
"Created: / 17-07-2018 / 12:53:32 / Claus Gittinger" |
|
80 |
! ! |
|
81 |
||
4712 | 82 |
!AbstractDirectoryBrowser methodsFor:'drag & drop'! |
83 |
||
7402 | 84 |
canDrop:aDropContext |
4712 | 85 |
^ inDropMode and:[canDropItem] |
7402 | 86 |
|
87 |
"Modified: / 13-10-2006 / 11:35:09 / cg" |
|
4712 | 88 |
! |
89 |
||
4745 | 90 |
doDrop:aContext |
91 |
|col destinationPath receiver didDrop| |
|
92 |
||
4754
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
93 |
destinationPath := self dropDestinationPath. |
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
94 |
|
4745 | 95 |
self dropLeave:aContext. |
96 |
||
7586 | 97 |
destinationPath isNil ifTrue:[^ self]. |
4745 | 98 |
|
99 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
100 |
receiver := aContext dropSource receiver. |
|
101 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
|
102 |
^ self |
|
103 |
]. |
|
104 |
||
9362 | 105 |
self withWaitCursorDo:[ |
17866 | 106 |
col := aContext dropObjects collect:#theObject. |
9362 | 107 |
didDrop := self copyOrMoveFiles:col to:destinationPath. |
108 |
didDrop ifFalse:[ |
|
109 |
aContext clearHasDroppedFlagToSuppressFeedBack |
|
110 |
]. |
|
111 |
] |
|
4745 | 112 |
! |
113 |
||
5335 | 114 |
dropDestinationPath |
115 |
self subclassResponsibility |
|
116 |
! |
|
117 |
||
4712 | 118 |
dropEnter:aContext |
6377 | 119 |
|dropObjects| |
4712 | 120 |
|
121 |
self dropTargetItemChangedTo:nil in:aContext. |
|
122 |
inDropMode := false. |
|
123 |
||
124 |
"/ self directory isNil ifTrue:[^ self]. |
|
6377 | 125 |
dropObjects := aContext dropObjects. |
4712 | 126 |
|
17754 | 127 |
dropObjects do:[:eachDropObject| |
15042
f002aba0f9c9
class: AbstractDirectoryBrowser
Claus Gittinger <cg@exept.de>
parents:
12873
diff
changeset
|
128 |
|checkObject| |
4712 | 129 |
|
17754 | 130 |
eachDropObject isFileObject ifFalse:[^ self]. |
4712 | 131 |
|
17754 | 132 |
checkObject := eachDropObject theObject. |
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
5967
diff
changeset
|
133 |
checkObject isFilename ifFalse:[^ self]. |
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
5967
diff
changeset
|
134 |
(aContext dropSource argument == #archivApplication) ifFalse:[ |
4712 | 135 |
checkObject isSpecialFile ifTrue:[^ self]. |
136 |
checkObject isReadable ifFalse:[^ self]. |
|
137 |
]. |
|
138 |
]. |
|
139 |
inDropMode := true. |
|
17754 | 140 |
|
141 |
"Modified (format): / 15-11-2017 / 11:10:16 / cg" |
|
4712 | 142 |
! |
143 |
||
144 |
dropLeave:aDropContext |
|
9328 | 145 |
"called, when leaving the widget" |
146 |
||
4712 | 147 |
inDropMode ifFalse:[ ^ self ]. |
148 |
||
149 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
150 |
self removeExpandItemTimedBlock. |
|
151 |
inDropMode := false. |
|
152 |
! |
|
153 |
||
5330 | 154 |
dropTargetItemChangedTo:anItem in:aContext |
155 |
||
156 |
self subclassResponsibility |
|
157 |
! |
|
158 |
||
4712 | 159 |
getDropObjects:anArgument |
160 |
||
161 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
|
162 |
! |
|
163 |
||
164 |
getLineNumberFor:aDropContext |
|
165 |
| yVisible| |
|
166 |
||
18214 | 167 |
yVisible := (aDropContext targetPointInDeviceCoordinates y). |
4712 | 168 |
^ browser yVisibleToRowNr:yVisible. |
18214 | 169 |
|
170 |
"Modified: / 15-06-2018 / 02:32:03 / Claus Gittinger" |
|
4712 | 171 |
! |
172 |
||
4802 | 173 |
pushUserEvent:selector withArgument:argument |
174 |
self window sensor |
|
175 |
pushUserEvent:selector |
|
176 |
for:self |
|
177 |
withArgument:argument |
|
5796 | 178 |
! |
179 |
||
180 |
removeExpandItemTimedBlock |
|
181 |
"left blank" |
|
4712 | 182 |
! ! |
183 |
||
184 |
!AbstractDirectoryBrowser methodsFor:'file actions'! |
|
185 |
||
186 |
doCopy |
|
6286 | 187 |
"copy the selected files/directories to the clipBoard" |
4712 | 188 |
|
189 |
self copyFilesToClipBoard:(self selectedFiles). |
|
190 |
! |
|
191 |
||
192 |
doCut |
|
6286 | 193 |
"cut the selected files/directories to the clipBoard" |
4712 | 194 |
|
195 |
self cutFilesToClipBoard:(self selectedFiles). |
|
196 |
! |
|
197 |
||
198 |
doDelete |
|
6286 | 199 |
"delete the selected files/directories" |
5967 | 200 |
|
4742
972a9d30ec47
enumerate copies of the selection in delete & rename
Claus Gittinger <cg@exept.de>
parents:
4712
diff
changeset
|
201 |
self deleteFiles:(self selectedFiles copy). |
6286 | 202 |
! |
203 |
||
204 |
doErase |
|
205 |
"erase the selected files" |
|
206 |
||
207 |
self eraseFiles:(self selectedFiles copy). |
|
18270 | 208 |
! |
209 |
||
210 |
findAndSelectFilesMatching:aGLOBPattern |
|
211 |
self selectFiles:(self findFilesMatching:aGLOBPattern). |
|
212 |
||
213 |
"Created: / 17-07-2018 / 12:48:23 / Claus Gittinger" |
|
4712 | 214 |
! ! |
215 |
||
216 |
!AbstractDirectoryBrowser methodsFor:'selection'! |
|
217 |
||
218 |
selectedFiles |
|
219 |
||
17866 | 220 |
^ self selectedItems collect:#fileName. |
16946 | 221 |
! |
222 |
||
223 |
selectedItems |
|
224 |
self subclassResponsibility |
|
4712 | 225 |
! ! |
226 |
||
227 |
!AbstractDirectoryBrowser methodsFor:'startup & release'! |
|
228 |
||
229 |
initialize |
|
230 |
||
231 |
inDropMode := false. |
|
232 |
^ super initialize. |
|
233 |
! |
|
234 |
||
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
235 |
postOpenAsSubcanvasWith:aBuilder |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
236 |
"this is sent after the applications window is opened inside another application. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
237 |
Can be redefined in subclasses for actions after showing the canvas view." |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
238 |
|
18142 | 239 |
"/ cg: used to be unconditionally true here; |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
240 |
"/ but then, when a FileDialog (which is not an AbstractFileBrowser) is opened, |
16912 | 241 |
"/ the commonPostBuild will not properly update its enable channels; |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
242 |
"/ especially the enableDirectoryUp is false. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
243 |
"/ This whole FileBrowser is so complicated that it became almost unusable. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
244 |
"/ (too much inheritance and knowledge - DirTree and DirContents should each only do |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
245 |
"/ what it should and not depend on shared functionality from their superclass) |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
246 |
self postOpenFromMaster:(self masterApplication class includesBehavior:AbstractFileBrowser). |
18142 | 247 |
|
248 |
"Modified (comment): / 22-05-2018 / 18:48:22 / Claus Gittinger" |
|
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
249 |
! |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
250 |
|
5444 | 251 |
postOpenFromMaster:fromMaster |
5442 | 252 |
self subclassResponsibility |
4712 | 253 |
! |
254 |
||
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
255 |
postOpenWith:aBuilder |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
256 |
"this is sent after the applications main window is opened. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
257 |
Can be redefined in subclasses for actions after opening the view." |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
258 |
|
17578 | 259 |
super postOpenWith:aBuilder. |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
260 |
self postOpenFromMaster:false. |
17578 | 261 |
|
262 |
"Modified: / 16-07-2017 / 12:19:48 / cg" |
|
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
263 |
! |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
264 |
|
4712 | 265 |
preBuildWith:aBuilder |
266 |
||
267 |
self masterApplication isNil ifTrue:[ |
|
268 |
self masterApplication:nil. |
|
269 |
]. |
|
270 |
^ super preBuildWith:aBuilder. |
|
271 |
! ! |
|
272 |
||
273 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
274 |
||
275 |
version |
|
16912 | 276 |
^ '$Header$' |
9328 | 277 |
! |
278 |
||
279 |
version_CVS |
|
16912 | 280 |
^ '$Header$' |
4712 | 281 |
! ! |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
282 |