author | penk |
Thu, 09 Jan 2003 15:42:09 +0100 | |
changeset 4422 | 98ccae19310a |
parent 4410 | b1972ecceb2a |
child 4437 | 3beb6a9ad203 |
permissions | -rw-r--r-- |
3892 | 1 |
"{ Package: 'stx:libtool' }" |
2 |
||
3 |
AbstractFileBrowser subclass:#DirectoryTreeBrowser |
|
4071 | 4 |
instanceVariableNames:'dirBrowser updateToExternFileHolderLock oldDropItem |
3995
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
5 |
expandItemTimedBlock updateTreeSelection inDropMode canDropItem |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
6 |
doubleClickAction newVisibilityHolder allowFileOperations |
4151 | 7 |
multipleSelect treeSelectionHolder sortInTreeVisibilityHolder |
8 |
sortPropertyInTree sortCaselessInTreeBrowser' |
|
3995
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
9 |
classVariableNames:'' |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
10 |
poolDictionaries:'' |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
11 |
category:'Interface-Tools-File' |
3892 | 12 |
! |
13 |
||
14 |
HierarchicalFileList subclass:#DirTreeBrowserHFL |
|
3995
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
15 |
instanceVariableNames:'draggedItem grayDirectoryIcon' |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
16 |
classVariableNames:'' |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
17 |
poolDictionaries:'' |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
18 |
privateIn:DirectoryTreeBrowser |
3892 | 19 |
! |
20 |
||
21 |
!DirectoryTreeBrowser class methodsFor:'documentation'! |
|
22 |
||
23 |
documentation |
|
24 |
" |
|
25 |
documentation to be added. |
|
26 |
||
27 |
[author:] |
|
28 |
Christian Penk (penk@bierfix) |
|
29 |
||
30 |
[see also:] |
|
31 |
||
32 |
[instance variables:] |
|
33 |
||
34 |
[class variables:] |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
examples |
|
39 |
" |
|
40 |
Starting the application: |
|
41 |
[exBegin] |
|
42 |
DirectoryTreeBrowser open |
|
43 |
||
44 |
[exEnd] |
|
45 |
||
46 |
more examples to be added: |
|
47 |
[exBegin] |
|
48 |
... add code fragment for |
|
49 |
... executable example here ... |
|
50 |
[exEnd] |
|
51 |
" |
|
52 |
! ! |
|
53 |
||
54 |
!DirectoryTreeBrowser class methodsFor:'instance creation'! |
|
55 |
||
56 |
open |
|
57 |
||
58 |
^ super open |
|
59 |
" |
|
60 |
DirectoryTreeBrowser open |
|
61 |
" |
|
62 |
! |
|
63 |
||
64 |
openOn:aFileName |
|
65 |
||
66 |
| file | |
|
67 |
file := aFileName asFilename. |
|
68 |
file exists ifTrue:[ |
|
69 |
self openOn:aFileName withFiles:(file isDirectory not) |
|
70 |
] |
|
71 |
||
72 |
" |
|
73 |
DirectoryTreeBrowser openOn:Filename homeDirectory |
|
74 |
DirectoryTreeBrowser openOn:(Filename homeDirectory construct:'.bashrc') |
|
75 |
" |
|
76 |
! |
|
77 |
||
78 |
openOn:aFileName withFiles:aBoolean |
|
79 |
||
80 |
| instance| |
|
81 |
||
82 |
instance := DirectoryTreeBrowser new. |
|
83 |
instance open. |
|
84 |
instance viewFilesInDirectoryTree value:aBoolean. |
|
85 |
instance currentFileNameHolder value:(OrderedCollection with:aFileName). |
|
86 |
" |
|
87 |
DirectoryTreeBrowser openOn:Filename homeDirectory |
|
88 |
DirectoryTreeBrowser openOn:(Filename homeDirectory construct:'.bashrc') withFiles:false |
|
89 |
" |
|
90 |
! ! |
|
91 |
||
92 |
!DirectoryTreeBrowser class methodsFor:'defaults'! |
|
93 |
||
94 |
timeForExpandOnDropInMilliseconds |
|
95 |
||
96 |
^ 1500 |
|
97 |
! ! |
|
98 |
||
99 |
!DirectoryTreeBrowser class methodsFor:'interface specs'! |
|
100 |
||
101 |
windowSpec |
|
102 |
"This resource specification was automatically generated |
|
103 |
by the UIPainter of ST/X." |
|
104 |
||
105 |
"Do not manually edit this!! If it is corrupted, |
|
106 |
the UIPainter may not be able to read the specification." |
|
107 |
||
108 |
" |
|
109 |
UIPainter new openOnClass:DirectoryTreeBrowser andSelector:#windowSpec |
|
110 |
DirectoryTreeBrowser new openInterface:#windowSpec |
|
111 |
DirectoryTreeBrowser open |
|
112 |
" |
|
113 |
||
114 |
<resource: #canvas> |
|
115 |
||
116 |
^ |
|
117 |
#(#FullSpec |
|
118 |
#name: #windowSpec |
|
119 |
#window: |
|
120 |
#(#WindowSpec |
|
121 |
#label: 'DirectoryTreeBrowser' |
|
122 |
#name: 'DirectoryTreeBrowser' |
|
123 |
#min: #(#Point 10 10) |
|
124 |
#max: #(#Point 1024 768) |
|
125 |
#bounds: #(#Rectangle 16 42 316 342) |
|
126 |
#menu: #mainMenu |
|
127 |
) |
|
128 |
#component: |
|
129 |
#(#SpecCollection |
|
130 |
#collection: #( |
|
131 |
#(#HierarchicalListViewSpec |
|
132 |
#name: 'HierarchicalListView' |
|
133 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
134 |
#model: #treeSelectionHolder |
|
135 |
#menu: #menu |
|
136 |
#hasHorizontalScrollBar: true |
|
137 |
#hasVerticalScrollBar: true |
|
138 |
#miniScrollerHorizontal: false |
|
139 |
#miniScrollerVertical: false |
|
140 |
#listModel: #fileList |
|
141 |
#multipleSelectOk: true |
|
3982 | 142 |
#useIndex: false |
3906 | 143 |
#highlightMode: #label |
3892 | 144 |
#doubleClickSelector: #doDoubleClick: |
145 |
#indicatorSelector: #doIndicatorClick: |
|
146 |
#postBuildCallback: #postBuildDirBrowser: |
|
147 |
#properties: |
|
148 |
#(#PropertyListDictionary |
|
3982 | 149 |
#overSelector: #dropOver: |
3892 | 150 |
#dragArgument: #directoryTreeBrowser |
151 |
#startDragSelector: #doStartDrag:in: |
|
152 |
#displayObjectSelector: #getDisplayObjects: |
|
153 |
#dropObjectSelector: #getDropObjects: |
|
154 |
#dropArgument: #directoryTreeBrowser |
|
3952 | 155 |
#canDropSelector: #canDrop: |
3892 | 156 |
#leaveSelector: #dropLeave: |
3952 | 157 |
#enterSelector: #dropEnter: |
3982 | 158 |
#dropSelector: #doDrop: |
3892 | 159 |
) |
160 |
) |
|
161 |
) |
|
162 |
||
163 |
) |
|
164 |
) |
|
165 |
! ! |
|
166 |
||
167 |
!DirectoryTreeBrowser class methodsFor:'menu specs'! |
|
168 |
||
169 |
menu |
|
170 |
"This resource specification was automatically generated |
|
171 |
by the MenuEditor of ST/X." |
|
172 |
||
173 |
"Do not manually edit this!! If it is corrupted, |
|
174 |
the MenuEditor may not be able to read the specification." |
|
175 |
||
176 |
" |
|
177 |
MenuEditor new openOnClass:DirectoryTreeBrowser andSelector:#menu |
|
178 |
(Menu new fromLiteralArrayEncoding:(DirectoryTreeBrowser menu)) startUp |
|
179 |
" |
|
180 |
||
181 |
<resource: #menu> |
|
182 |
||
183 |
^ |
|
184 |
#(#Menu |
|
185 |
#( |
|
186 |
#(#MenuItem |
|
187 |
#label: 'Copy' |
|
4080 | 188 |
#itemValue: #doCopy |
3892 | 189 |
#translateLabel: true |
3956 | 190 |
#isVisible: #allowFileOperations |
4162 | 191 |
#shortcutKey: #Copy |
3892 | 192 |
) |
193 |
#(#MenuItem |
|
194 |
#label: 'Cut' |
|
4080 | 195 |
#itemValue: #doCut |
3892 | 196 |
#translateLabel: true |
3956 | 197 |
#isVisible: #allowFileOperations |
4162 | 198 |
#shortcutKey: #Cut |
3892 | 199 |
) |
200 |
#(#MenuItem |
|
4080 | 201 |
#enabled: #canPaste |
3892 | 202 |
#label: 'Paste' |
4080 | 203 |
#itemValue: #pasteFiles |
3892 | 204 |
#translateLabel: true |
3956 | 205 |
#isVisible: #allowFileOperations |
4162 | 206 |
#shortcutKey: #Paste |
3892 | 207 |
) |
208 |
#(#MenuItem |
|
209 |
#label: 'Delete' |
|
4080 | 210 |
#itemValue: #doDelete |
211 |
#nameKey: #delete |
|
3892 | 212 |
#translateLabel: true |
3956 | 213 |
#isVisible: #allowFileOperations |
4162 | 214 |
#shortcutKey: #Delete |
3892 | 215 |
) |
216 |
#(#MenuItem |
|
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
217 |
#label: '-' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
218 |
#isVisible: #allowFileOperations |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
219 |
) |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
220 |
#(#MenuItem |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
221 |
#enabled: #hasSelection |
3907 | 222 |
#label: 'Rename' |
4080 | 223 |
#itemValue: #treeViewFileRename |
3907 | 224 |
#translateLabel: true |
3956 | 225 |
#isVisible: #allowFileOperations |
4162 | 226 |
#shortcutKey: #Rename |
3907 | 227 |
) |
228 |
#(#MenuItem |
|
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
229 |
#enabled: #hasSelection |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
230 |
#label: 'Properties...' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
231 |
#itemValue: #doShowProperties |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
232 |
#translateLabel: true |
3892 | 233 |
) |
234 |
#(#MenuItem |
|
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
235 |
#label: '-' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
236 |
#isVisible: #allowFileOperations |
3892 | 237 |
) |
238 |
#(#MenuItem |
|
4080 | 239 |
#enabled: #selectedFilesIncludesNonRootDirectory |
4151 | 240 |
#label: 'Set Root to Selection' |
4080 | 241 |
#itemValue: #doSetSelectionToRoot |
3892 | 242 |
#translateLabel: true |
243 |
) |
|
244 |
#(#MenuItem |
|
245 |
#label: '-' |
|
246 |
) |
|
247 |
#(#MenuItem |
|
248 |
#label: 'New' |
|
249 |
#translateLabel: true |
|
3956 | 250 |
#isVisible: #newVisibilityHolder |
3892 | 251 |
#submenuChannel: #newMenu |
252 |
) |
|
253 |
#(#MenuItem |
|
4080 | 254 |
#label: 'More' |
255 |
#translateLabel: true |
|
3907 | 256 |
#submenu: |
257 |
#(#Menu |
|
258 |
#( |
|
259 |
#(#MenuItem |
|
4080 | 260 |
#enabled: #enableDirectoryUp |
3907 | 261 |
#label: 'Directory Up' |
4080 | 262 |
#itemValue: #doGoDirectoryUp |
3907 | 263 |
#translateLabel: true |
264 |
) |
|
265 |
#(#MenuItem |
|
266 |
#label: 'Re-/ Expand Directory' |
|
4080 | 267 |
#itemValue: #toggleExpandSelectedItem |
3907 | 268 |
#translateLabel: true |
269 |
) |
|
270 |
) |
|
271 |
nil |
|
272 |
nil |
|
273 |
) |
|
3892 | 274 |
) |
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
275 |
#(#MenuItem |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
276 |
#label: '-' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
277 |
) |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
278 |
#(#MenuItem |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
279 |
#label: 'View' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
280 |
#translateLabel: true |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
281 |
#submenu: |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
282 |
#(#Menu |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
283 |
#( |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
284 |
#(#MenuItem |
4410 | 285 |
#enabled: #sortInTreeVisibilityHolder |
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
286 |
#label: 'Sort' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
287 |
#nameKey: #Sort |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
288 |
#translateLabel: true |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
289 |
#submenuChannel: #sortInTreeMenu |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
290 |
) |
4410 | 291 |
#(#MenuItem |
292 |
#label: 'Show' |
|
293 |
#translateLabel: true |
|
294 |
#submenu: |
|
295 |
#(#Menu |
|
296 |
#( |
|
297 |
#(#MenuItem |
|
298 |
#label: 'Files' |
|
299 |
#translateLabel: true |
|
300 |
#indication: #viewFilesInDirectoryTree |
|
301 |
) |
|
302 |
) |
|
303 |
nil |
|
304 |
nil |
|
305 |
) |
|
306 |
) |
|
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
307 |
) |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
308 |
nil |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
309 |
nil |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
310 |
) |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
311 |
) |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
312 |
#(#MenuItem |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
313 |
#label: '-' |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
314 |
) |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
315 |
#(#MenuItem |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
316 |
#label: 'Update' |
4422 | 317 |
#itemValue: #updateCurrentDirectory |
4383
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
318 |
#translateLabel: true |
2fc564ad0f70
same menu order as on the right side
Claus Gittinger <cg@exept.de>
parents:
4333
diff
changeset
|
319 |
) |
3892 | 320 |
) |
321 |
nil |
|
322 |
nil |
|
323 |
) |
|
4151 | 324 |
! |
325 |
||
326 |
sortInTreeMenu |
|
327 |
"This resource specification was automatically generated |
|
328 |
by the MenuEditor of ST/X." |
|
329 |
||
330 |
"Do not manually edit this!! If it is corrupted, |
|
331 |
the MenuEditor may not be able to read the specification." |
|
332 |
||
333 |
" |
|
334 |
MenuEditor new openOnClass:DirectoryTreeBrowser andSelector:#sortInTreeMenu |
|
335 |
(Menu new fromLiteralArrayEncoding:(DirectoryTreeBrowser sortInTreeMenu)) startUp |
|
336 |
" |
|
337 |
||
338 |
<resource: #menu> |
|
339 |
||
340 |
^ |
|
341 |
#(#Menu |
|
342 |
#( |
|
343 |
#(#MenuItem |
|
344 |
#label: 'By Filename' |
|
345 |
#translateLabel: true |
|
346 |
#hideMenuOnActivated: false |
|
347 |
#choice: #sortPropertyInTree |
|
348 |
#choiceValue: #baseName |
|
349 |
) |
|
350 |
#(#MenuItem |
|
351 |
#label: 'By Type' |
|
352 |
#translateLabel: true |
|
353 |
#hideMenuOnActivated: false |
|
354 |
#choice: #sortPropertyInTree |
|
355 |
#choiceValue: #suffix |
|
356 |
) |
|
357 |
#(#MenuItem |
|
358 |
#label: 'By Size' |
|
359 |
#translateLabel: true |
|
360 |
#hideMenuOnActivated: false |
|
361 |
#choice: #sortPropertyInTree |
|
362 |
#choiceValue: #fileSize |
|
363 |
) |
|
364 |
#(#MenuItem |
|
365 |
#label: 'By Date && Time' |
|
366 |
#translateLabel: true |
|
367 |
#hideMenuOnActivated: false |
|
368 |
#choice: #sortPropertyInTree |
|
369 |
#choiceValue: #modificationTime |
|
370 |
) |
|
371 |
#(#MenuItem |
|
372 |
#label: '-' |
|
373 |
) |
|
374 |
#(#MenuItem |
|
375 |
#label: 'Ignore Case in Sort' |
|
376 |
#translateLabel: true |
|
377 |
#hideMenuOnActivated: false |
|
378 |
#indication: #sortCaselessInTreeBrowser |
|
379 |
) |
|
380 |
) |
|
381 |
nil |
|
382 |
nil |
|
383 |
) |
|
3892 | 384 |
! ! |
385 |
||
386 |
!DirectoryTreeBrowser class methodsFor:'plugIn spec'! |
|
387 |
||
388 |
aspectSelectors |
|
389 |
"This resource specification was automatically generated |
|
390 |
by the UIPainter of ST/X." |
|
391 |
||
392 |
"Do not manually edit this. If it is corrupted, |
|
393 |
the UIPainter may not be able to read the specification." |
|
394 |
||
395 |
"Return a description of exported aspects; |
|
396 |
these can be connected to aspects of an embedding application |
|
397 |
(if this app is embedded in a subCanvas)." |
|
398 |
||
399 |
^ #( |
|
400 |
#selectedDirectoryModel |
|
401 |
). |
|
402 |
||
403 |
! ! |
|
404 |
||
405 |
!DirectoryTreeBrowser methodsFor:'accessing'! |
|
406 |
||
3952 | 407 |
doubleClickAction |
408 |
||
409 |
^ doubleClickAction |
|
410 |
! |
|
411 |
||
412 |
doubleClickAction:aBlock |
|
413 |
||
414 |
" aBlock is a one arg block with selected index as argument " |
|
415 |
||
416 |
doubleClickAction := aBlock |
|
417 |
! |
|
418 |
||
3892 | 419 |
updateToExternFileHolderLock |
420 |
"return the value of the instance variable 'updateToExternFileHolder' (automatically generated)" |
|
421 |
||
422 |
updateToExternFileHolderLock isNil ifTrue:[ |
|
423 |
updateToExternFileHolderLock := self class newLock. |
|
424 |
]. |
|
425 |
^ updateToExternFileHolderLock |
|
426 |
! |
|
427 |
||
428 |
updateTreeSelection |
|
429 |
"return the value of the instance variable 'updateToExternFileHolder' (automatically generated)" |
|
430 |
||
431 |
updateTreeSelection isNil ifTrue:[ |
|
432 |
updateTreeSelection := self class newLock. |
|
433 |
]. |
|
434 |
^ updateTreeSelection |
|
435 |
! ! |
|
436 |
||
437 |
!DirectoryTreeBrowser methodsFor:'actions'! |
|
438 |
||
439 |
doDoubleClick:anIndex |
|
440 |
"handle a doubleClick on a directory |
|
441 |
" |
|
3952 | 442 |
| item file isDirectory| |
3892 | 443 |
|
3952 | 444 |
self doubleClickAction notNil ifTrue:[ |
445 |
self doubleClickAction value:anIndex. |
|
446 |
]. |
|
3892 | 447 |
item := self fileList at:anIndex ifAbsent:nil. |
448 |
item notNil ifTrue:[ |
|
449 |
isDirectory := item isDirectory. |
|
450 |
file := item fileName. |
|
451 |
isDirectory ifTrue:[ |
|
452 |
(file isReadable and:[file isExecutable]) ifTrue:[ |
|
453 |
self doExpand:item. |
|
454 |
] |
|
455 |
] ifFalse:[ |
|
3952 | 456 |
"/ self openApplByFileItem:item. |
3892 | 457 |
] |
458 |
] |
|
459 |
! |
|
460 |
||
461 |
doExpand:anItem |
|
462 |
" expand the item; return true the item have expanded " |
|
463 |
||
464 |
(anItem notNil and:[anItem isDirectory and:[anItem isExpanded not]]) ifTrue:[ |
|
465 |
anItem toggleExpand. |
|
466 |
^ true. |
|
467 |
]. |
|
468 |
^ false |
|
469 |
! |
|
470 |
||
471 |
doIndicatorClick:anIndex |
|
472 |
"handle a click on the indicator |
|
473 |
" |
|
474 |
||
475 |
|item| |
|
476 |
||
477 |
item := self fileList at:anIndex ifAbsent:nil. |
|
478 |
self toggleExpand:item |
|
479 |
! |
|
480 |
||
4010 | 481 |
doSetSelectionToRoot |
3982 | 482 |
| selDir| |
483 |
||
484 |
selDir := self firstSelectedDirectory. |
|
485 |
selDir notNil ifTrue:[ |
|
486 |
self rootHolder value asFilename = selDir ifTrue:[ ^ self]. |
|
487 |
self rootHolder value:selDir. |
|
488 |
self currentFileNameHolder value:(OrderedCollection with:selDir). |
|
489 |
]. |
|
490 |
! |
|
491 |
||
3892 | 492 |
doUpdate |
4422 | 493 |
"/ DirectoryContents flushCache. |
494 |
self fileList updateList. |
|
3892 | 495 |
"/ self updateSelectedItem |
496 |
! |
|
497 |
||
4151 | 498 |
evaluateSortBlockWith:aBlock |
3989 | 499 |
|
4085
9e58ddfa6969
sort will be triggered from the FileBrowserV2 instance not from AbstractFileBrowser anymore
penk
parents:
4080
diff
changeset
|
500 |
| sel model| |
9e58ddfa6969
sort will be triggered from the FileBrowserV2 instance not from AbstractFileBrowser anymore
penk
parents:
4080
diff
changeset
|
501 |
|
9e58ddfa6969
sort will be triggered from the FileBrowserV2 instance not from AbstractFileBrowser anymore
penk
parents:
4080
diff
changeset
|
502 |
model := self treeSelectionHolder. |
9e58ddfa6969
sort will be triggered from the FileBrowserV2 instance not from AbstractFileBrowser anymore
penk
parents:
4080
diff
changeset
|
503 |
sel := model value. |
9e58ddfa6969
sort will be triggered from the FileBrowserV2 instance not from AbstractFileBrowser anymore
penk
parents:
4080
diff
changeset
|
504 |
model setValue:nil. |
4151 | 505 |
self fileList sortBlock:aBlock. |
4085
9e58ddfa6969
sort will be triggered from the FileBrowserV2 instance not from AbstractFileBrowser anymore
penk
parents:
4080
diff
changeset
|
506 |
model value:sel withoutNotifying:self. |
3989 | 507 |
! |
508 |
||
3892 | 509 |
setMatchBlockForList:list |
510 |
||
4021 | 511 |
| selection matchBlock filterBlock viewFiles| |
3982 | 512 |
|
513 |
selection := self selectedItems. |
|
4011 | 514 |
filterBlock := self filterBlockHolder value. |
515 |
viewFiles := self viewFilesInDirectoryTree value. |
|
516 |
matchBlock := [:fileName :isDir| |
|
517 |
(isDir |
|
518 |
or:[viewFiles |
|
519 |
and:[filterBlock value:fileName baseName]]) |
|
3892 | 520 |
]. |
4011 | 521 |
list matchBlock:matchBlock. |
3892 | 522 |
! |
523 |
||
4151 | 524 |
sortFileListsBy:instanceName |
525 |
||
526 |
| aSymbol cmpOp instanceSortBlock treeSortBlock| |
|
527 |
||
528 |
aSymbol := instanceName asSymbol. |
|
529 |
cmpOp := #'<'. |
|
530 |
instanceSortBlock := [:a :b | |
|
531 |
|entry1 entry2| |
|
532 |
||
533 |
entry1 := (a perform:aSymbol). |
|
534 |
entry2 := (b perform:aSymbol). |
|
535 |
((entry1 isNil) or:[entry2 isNil]) ifTrue:[ |
|
536 |
true |
|
537 |
] ifFalse:[ |
|
538 |
(aSymbol = #baseName) ifTrue:[ |
|
539 |
self sortCaselessInTreeBrowser value ifTrue:[ |
|
540 |
entry1 := entry1 asString asLowercase. |
|
541 |
entry2 := entry2 asString asLowercase. |
|
542 |
] ifFalse:[ |
|
543 |
entry1 := entry1 asString. |
|
544 |
entry2 := entry2 asString. |
|
545 |
]. |
|
546 |
]. |
|
547 |
entry1 perform:cmpOp with:entry2 |
|
548 |
] |
|
549 |
]. |
|
550 |
treeSortBlock := [ :a :b | |
|
551 |
|aIsDir bIsDir res| |
|
552 |
||
553 |
aIsDir := a isDirectory. |
|
554 |
bIsDir := b isDirectory. |
|
555 |
(aIsDir and:[bIsDir]) ifTrue:[ |
|
556 |
| entry1 entry2 | |
|
557 |
entry1 := a baseName. |
|
558 |
entry2 := b baseName. |
|
559 |
res := entry1 < entry2. |
|
560 |
] ifFalse:[ |
|
561 |
(aIsDir or:[bIsDir]) ifTrue:[ |
|
562 |
res := aIsDir |
|
563 |
] ifFalse:[ |
|
564 |
res := instanceSortBlock value:a value:b. |
|
565 |
] |
|
566 |
]. |
|
567 |
res |
|
568 |
]. |
|
569 |
self evaluateSortBlockWith:treeSortBlock. |
|
570 |
! |
|
571 |
||
3892 | 572 |
toggleExpand:anItem |
573 |
||
574 |
(anItem notNil and:[anItem isDirectory]) ifTrue:[ |
|
575 |
anItem toggleExpand |
|
576 |
]. |
|
577 |
! |
|
578 |
||
3982 | 579 |
toggleExpandSelectedItem |
580 |
||
581 |
|selDir| |
|
582 |
||
583 |
selDir := self selectedDirectoryItems. |
|
584 |
selDir do:[:item| |
|
585 |
self toggleExpand:item. |
|
586 |
]. |
|
587 |
! |
|
588 |
||
3892 | 589 |
treeViewFileRename |
3982 | 590 |
|
3906 | 591 |
dirBrowser openEditor. |
3892 | 592 |
! |
593 |
||
594 |
updateSelectedItem |
|
595 |
||
596 |
| sel | |
|
597 |
||
3982 | 598 |
sel := self selectedItems. |
3892 | 599 |
sel isEmpty ifTrue:[ ^ self]. |
600 |
sel do:[:item| |
|
601 |
item invalidateRepairNow:true. |
|
602 |
] |
|
603 |
! ! |
|
604 |
||
605 |
!DirectoryTreeBrowser methodsFor:'aspects'! |
|
606 |
||
3956 | 607 |
allowFileOperations |
608 |
"allowFileOperations |
|
609 |
" |
|
610 |
allowFileOperations isNil ifTrue:[ |
|
611 |
allowFileOperations := true asValue. |
|
612 |
]. |
|
613 |
^ allowFileOperations. |
|
614 |
! |
|
615 |
||
3892 | 616 |
fileList |
617 |
"holder, which keeps the current list of file entries shown by the directory-browser |
|
618 |
" |
|
619 |
||
620 |
|list| |
|
621 |
||
622 |
(list := builder bindingAt:#fileList) isNil ifTrue:[ |
|
623 |
list := DirTreeBrowserHFL new. |
|
624 |
list application:self. |
|
625 |
list showRoot:true. |
|
626 |
self setMatchBlockForList:list. |
|
627 |
list directory:(self rootHolder value). |
|
628 |
builder aspectAt:#fileList put:list. |
|
629 |
list monitoringTaskDelay:2 |
|
630 |
]. |
|
631 |
^ list |
|
632 |
! |
|
633 |
||
3958 | 634 |
multipleSelect |
635 |
||
636 |
multipleSelect isNil ifTrue:[ |
|
637 |
multipleSelect := true. |
|
638 |
]. |
|
639 |
^ multipleSelect |
|
640 |
! |
|
641 |
||
642 |
multipleSelect:aBoolean |
|
643 |
||
644 |
multipleSelect := aBoolean. |
|
645 |
dirBrowser multipleSelectOk:aBoolean. |
|
646 |
! |
|
647 |
||
3956 | 648 |
newVisibilityHolder |
649 |
"newVisibilityHolder |
|
650 |
" |
|
651 |
newVisibilityHolder isNil ifTrue:[ |
|
652 |
newVisibilityHolder := true asValue. |
|
653 |
]. |
|
654 |
^ newVisibilityHolder. |
|
655 |
! |
|
656 |
||
4151 | 657 |
sortCaselessInTreeBrowser |
658 |
||
659 |
sortCaselessInTreeBrowser isNil ifTrue:[ |
|
660 |
sortCaselessInTreeBrowser := (Filename isCaseSensitive not) asValue. |
|
661 |
sortCaselessInTreeBrowser addDependent:self. |
|
662 |
]. |
|
663 |
^ sortCaselessInTreeBrowser. |
|
664 |
! |
|
665 |
||
666 |
sortInTreeVisibilityHolder |
|
667 |
"newVisibilityHolder |
|
668 |
" |
|
669 |
sortInTreeVisibilityHolder isNil ifTrue:[ |
|
670 |
sortInTreeVisibilityHolder := self viewFilesInDirectoryTree value asValue. |
|
671 |
]. |
|
672 |
^ sortInTreeVisibilityHolder. |
|
673 |
! |
|
674 |
||
675 |
sortPropertyInTree |
|
676 |
||
677 |
sortPropertyInTree isNil ifTrue:[ |
|
678 |
sortPropertyInTree := #baseName asValue. |
|
679 |
sortPropertyInTree addDependent:self. |
|
680 |
]. |
|
681 |
^ sortPropertyInTree. |
|
682 |
! |
|
683 |
||
3982 | 684 |
treeSelectionHolder |
685 |
||
686 |
treeSelectionHolder isNil ifTrue:[ |
|
687 |
treeSelectionHolder := ValueHolder new. |
|
688 |
treeSelectionHolder addDependent:self. |
|
689 |
]. |
|
690 |
^ treeSelectionHolder |
|
3892 | 691 |
! ! |
692 |
||
693 |
!DirectoryTreeBrowser methodsFor:'change & update'! |
|
694 |
||
3982 | 695 |
changeMatchBlock |
696 |
||
697 |
|list| |
|
698 |
||
699 |
list := self fileList. |
|
4021 | 700 |
self setMatchBlockForList:list. |
701 |
self currentFileNameHolderChanged. |
|
3982 | 702 |
! |
3892 | 703 |
|
3982 | 704 |
currentFileNameHolderChanged |
705 |
||
706 |
| selectFiles viewFiles| |
|
3892 | 707 |
|
3982 | 708 |
viewFiles:= self viewFilesInDirectoryTree value. |
709 |
viewFiles ifTrue:[ |
|
710 |
selectFiles := self currentFileNameHolder value. |
|
711 |
] ifFalse:[ |
|
712 |
selectFiles := self currentDirectories value. |
|
713 |
]. |
|
4018 | 714 |
self rootHolder notNil ifTrue:[ |
3982 | 715 |
self selectFiles:selectFiles. |
4333 | 716 |
self selectedItems do:[:item| |
717 |
(item isDirectory and:[item isExpanded not]) ifTrue:[ |
|
718 |
item expand. |
|
719 |
] |
|
720 |
]. |
|
721 |
^ self |
|
3982 | 722 |
]. |
723 |
! |
|
724 |
||
4011 | 725 |
rootHolderChanged |
726 |
||
727 |
|list file rootHolder| |
|
728 |
list := self fileList. |
|
729 |
rootHolder := self rootHolder. |
|
730 |
file := rootHolder value. |
|
731 |
file notNil ifTrue:[ |
|
732 |
file := Filename named:(file asString). |
|
733 |
file isDirectory ifTrue:[ |
|
734 |
list directory:file |
|
735 |
] |
|
736 |
]. |
|
4071 | 737 |
self rootHolder value:(list directory asString) withoutNotifying:self. |
4011 | 738 |
! |
739 |
||
3982 | 740 |
selectionChanged |
741 |
||
3995
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
742 |
|sel currentFileDir| |
3982 | 743 |
|
3995
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
744 |
" if viewFiles is false i can't take my |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
745 |
selection to overwrite currentFileNameHolder" |
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
746 |
|
3982 | 747 |
sel := self selectedFiles. |
748 |
(self viewFilesInDirectoryTree value not) ifTrue:[ |
|
3892 | 749 |
(self currentFilesAreInSameDirectory and:[sel size == 1]) ifTrue:[ |
750 |
currentFileDir := self getDirWithoutFileName:(self currentFileNameHolder value first). |
|
751 |
(sel first = currentFileDir) ifTrue:[ |
|
752 |
^ self. |
|
753 |
]. |
|
754 |
]. |
|
755 |
]. |
|
756 |
self currentFileNameHolder value:sel. |
|
757 |
! |
|
758 |
||
759 |
update:something with:aParameter from:aModel |
|
760 |
"one of my models changed |
|
761 |
" |
|
762 |
||
763 |
||
3982 | 764 |
" the execution of selectionChanged and currentFileNameHolderChanged must |
3892 | 765 |
lock against each other because values dont must be the same (e.g. no files |
766 |
in tree view) |
|
767 |
" |
|
768 |
||
769 |
aModel == self currentFileNameHolder ifTrue:[ |
|
4003 | 770 |
super update:something with:aParameter from:aModel. |
3892 | 771 |
self updateTreeSelection doIfUnLocked:[ |
772 |
self updateToExternFileHolderLock doLocked:[ |
|
3982 | 773 |
self currentFileNameHolderChanged. |
3892 | 774 |
]. |
775 |
]. |
|
4003 | 776 |
^ self. |
3892 | 777 |
]. |
778 |
aModel == self treeSelectionHolder ifTrue:[ |
|
779 |
self updateToExternFileHolderLock doIfUnLocked:[ |
|
780 |
self updateTreeSelection doLocked:[ |
|
3982 | 781 |
self selectionChanged. |
3892 | 782 |
] |
783 |
]. |
|
784 |
^ self |
|
785 |
]. |
|
3982 | 786 |
aModel == self rootHolder ifTrue:[ |
4011 | 787 |
self rootHolderChanged. |
3892 | 788 |
^ self. |
789 |
]. |
|
790 |
aModel == self viewFilesInDirectoryTree ifTrue:[ |
|
4151 | 791 |
self sortInTreeVisibilityHolder value:(aModel value). |
3982 | 792 |
self updateToExternFileHolderLock doLocked:[ |
793 |
self changeMatchBlock. |
|
3892 | 794 |
]. |
795 |
^ self. |
|
796 |
]. |
|
4151 | 797 |
aModel == self sortPropertyInTree ifTrue:[ |
798 |
self sortFileListsBy:aModel value. |
|
3989 | 799 |
^ self. |
4151 | 800 |
]. |
801 |
aModel == self sortCaselessInTreeBrowser ifTrue:[ |
|
802 |
self sortPropertyInTree setValue:#baseName. |
|
803 |
self sortPropertyInTree changed. |
|
804 |
]. |
|
4011 | 805 |
aModel == self filterBlockHolder ifTrue:[ |
3982 | 806 |
" filter goes only on fileNames not on directories |
807 |
have to change the matchBlock only if files are shown" |
|
808 |
self viewFilesInDirectoryTree value ifTrue:[ |
|
4018 | 809 |
self changeMatchBlock. |
3982 | 810 |
]. |
811 |
^ self |
|
3892 | 812 |
]. |
813 |
super update:something with:aParameter from:aModel. |
|
814 |
^ self |
|
815 |
! ! |
|
816 |
||
817 |
!DirectoryTreeBrowser methodsFor:'drag & drop'! |
|
818 |
||
3952 | 819 |
canDrop:aContext |
3892 | 820 |
|
3952 | 821 |
^ canDropItem |
3892 | 822 |
! |
823 |
||
824 |
doDrop:aContext |
|
3952 | 825 |
|col destination destinationPath receiver| |
3892 | 826 |
|
3952 | 827 |
destination := self fileList draggedItem. |
828 |
self dropLeave:aContext. |
|
829 |
destination ifNil:[^ false]. |
|
830 |
||
3892 | 831 |
destinationPath := destination fileName. |
3952 | 832 |
|
833 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
834 |
receiver := aContext dropSource receiver. |
|
3892 | 835 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
836 |
^ true |
|
837 |
]. |
|
838 |
col := OrderedCollection new. |
|
839 |
aContext dropObjects do:[:obj | |
|
840 |
col add:(obj theObject) |
|
841 |
]. |
|
3952 | 842 |
self copyOrMoveFiles:col to:destinationPath. |
3892 | 843 |
^ true |
844 |
! |
|
845 |
||
3952 | 846 |
dropEnter:aContext |
847 |
||
848 |
|dropedObjects| |
|
3892 | 849 |
|
3952 | 850 |
self dropTargetItemChangedTo:nil in:aContext. |
851 |
inDropMode := false. |
|
852 |
||
853 |
dropedObjects := aContext dropObjects. |
|
3892 | 854 |
|
3952 | 855 |
dropedObjects do:[:aObject| |checkObject checkObjectString| |
856 |
aObject isFileObject ifFalse:[^ self]. |
|
857 |
checkObject := aObject theObject. |
|
858 |
checkObject isFilename not ifTrue:[^ self]. |
|
859 |
((aContext dropSource argument == #archivApplication) not) ifTrue:[ |
|
860 |
checkObject isSpecialFile ifTrue:[^ self]. |
|
861 |
checkObject isReadable ifFalse:[^ self]. |
|
862 |
]. |
|
863 |
]. |
|
864 |
inDropMode := true. |
|
3892 | 865 |
! |
866 |
||
867 |
dropLeave:aDropContext |
|
868 |
"send the last time, when leaving the widget |
|
869 |
" |
|
3952 | 870 |
inDropMode ifTrue:[ |
871 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
872 |
self removeExpandItemTimedBlock. |
|
873 |
inDropMode := false. |
|
874 |
]. |
|
3892 | 875 |
! |
876 |
||
3952 | 877 |
dropOver:aContext |
878 |
"send the last time, when leaving the widget |
|
879 |
" |
|
880 |
|lineNr newDest| |
|
881 |
||
882 |
inDropMode ifFalse:[^ self]. |
|
883 |
||
884 |
lineNr := self getLineNumberFor:aContext. |
|
3892 | 885 |
|
3952 | 886 |
lineNr notNil ifTrue:[ |
887 |
newDest := self fileList at:lineNr ifAbsent:nil. |
|
888 |
]. |
|
4018 | 889 |
(newDest isNil or:[newDest == self fileList draggedItem]) ifTrue:[ |
3952 | 890 |
^ self |
891 |
]. |
|
892 |
newDest isDirectory not ifTrue:[ |
|
893 |
newDest := nil. |
|
894 |
canDropItem := false. |
|
895 |
]. |
|
896 |
self dropTargetItemChangedTo:newDest in:aContext. |
|
897 |
||
898 |
newDest notNil ifTrue:[ |
|
899 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
900 |
canDropItem := true. |
|
901 |
] ifFalse:[ |
|
902 |
canDropItem := self canDropFiles:(aContext dropObjects) for:newDest fileName. |
|
903 |
]. |
|
904 |
]. |
|
3892 | 905 |
! |
906 |
||
3952 | 907 |
dropTargetItemChangedTo:anItem in:aDropContext |
908 |
|current| |
|
909 |
||
910 |
current := self fileList draggedItem. |
|
911 |
current == anItem ifTrue:[^ self]. |
|
912 |
||
913 |
self fileList draggedItem:anItem. |
|
914 |
||
915 |
aDropContext contentsWillChange. |
|
916 |
current ifNotNil:[ |
|
917 |
current isDirectory ifTrue:[ |
|
918 |
self removeExpandItemTimedBlock. |
|
919 |
current changed:#icon. |
|
920 |
] |
|
921 |
]. |
|
3892 | 922 |
|
3952 | 923 |
anItem ifNotNil:[ |
924 |
anItem isDirectory ifTrue:[ |
|
925 |
anItem changed:#icon. |
|
926 |
(anItem notNil and:[anItem isDirectory and:[anItem fileName isWritable]]) ifTrue:[ |
|
927 |
expandItemTimedBlock := [ |
|
928 |
self expandForDrop:anItem with:aDropContext. |
|
929 |
]. |
|
930 |
Processor addTimedBlock:expandItemTimedBlock |
|
931 |
afterMilliseconds:(self class timeForExpandOnDropInMilliseconds). |
|
932 |
] |
|
933 |
]. |
|
934 |
]. |
|
935 |
dirBrowser shown ifTrue:[ |
|
936 |
dirBrowser repairDamage. |
|
937 |
]. |
|
3892 | 938 |
! |
939 |
||
940 |
expandForDrop:item with:aDropContext |
|
941 |
||
942 |
aDropContext saveDraw:[ |
|
943 |
(self doExpand:item) ifTrue:[ |
|
944 |
self windowGroup processExposeEvents |
|
945 |
]. |
|
946 |
] |
|
947 |
! |
|
948 |
||
949 |
getDisplayObjects:anArgument |
|
950 |
||
951 |
| string fnName sel size stream| |
|
3982 | 952 |
sel := self selectedItems. |
3892 | 953 |
size := sel size. |
954 |
size == 0 ifTrue:[^ '']. |
|
955 |
stream := WriteStream on:''. |
|
956 |
stream nextPutAll:sel first baseName. |
|
957 |
size == 1 ifTrue:[ |
|
958 |
fnName := 'ui_menuitem.xpm'. |
|
959 |
] ifFalse:[ |
|
960 |
fnName := 'ui_submenu_open.xpm'. |
|
961 |
stream nextPutAll:' ... '. |
|
962 |
stream nextPutAll:sel last baseName. |
|
963 |
]. |
|
964 |
string := stream contents. |
|
965 |
stream close. |
|
966 |
||
967 |
fnName := 'ui_menuitem.xpm'. |
|
968 |
^ Array with:(LabelAndIcon icon:(Image fromFile:fnName) |
|
969 |
string:(Text string:string emphasis:#bold) |
|
970 |
) |
|
971 |
! |
|
972 |
||
973 |
getDropObjects:anArgument |
|
974 |
||
975 |
| sel ret| |
|
976 |
||
3982 | 977 |
sel := self selectedFiles. |
3892 | 978 |
sel isEmpty ifTrue:[ ^ self ]. |
979 |
ret := sel collect:[:file| |
|
980 |
DropObject newFile:file |
|
981 |
]. |
|
982 |
^ ret |
|
983 |
! |
|
984 |
||
985 |
getLineNumberFor:aDropContext |
|
986 |
| yVisible| |
|
987 |
||
988 |
yVisible := (aDropContext targetPoint y). |
|
989 |
^ dirBrowser yVisibleToLineNr:yVisible. |
|
990 |
! |
|
991 |
||
992 |
removeExpandItemTimedBlock |
|
3952 | 993 |
|
3892 | 994 |
expandItemTimedBlock notNil ifTrue:[ |
995 |
Processor removeTimedBlock:expandItemTimedBlock. |
|
996 |
expandItemTimedBlock := nil |
|
997 |
] |
|
998 |
! ! |
|
999 |
||
1000 |
!DirectoryTreeBrowser methodsFor:'event handling'! |
|
1001 |
||
1002 |
processEvent:anEvent |
|
1003 |
"filter keyboard events. |
|
1004 |
Return true, if I have eaten the event" |
|
1005 |
||
4009 | 1006 |
|evView key rawKey| |
3892 | 1007 |
|
1008 |
anEvent isKeyPressEvent ifTrue:[ |
|
4009 | 1009 |
evView := anEvent targetView. |
1010 |
evView isNil ifTrue:[ ^ false]. |
|
1011 |
evView == dirBrowser ifFalse:[ ^ false]. |
|
1012 |
key := anEvent key. |
|
3892 | 1013 |
rawKey := anEvent rawKey. |
1014 |
||
3906 | 1015 |
|
4009 | 1016 |
(key == #CursorLeft) ifTrue:[ |
1017 |
"go to last selection in selection history" |
|
1018 |
(self rootSelected and:[(self fileList at:1) isExpanded not]) ifTrue:[ |
|
1019 |
self doGoDirectoryUp. |
|
3892 | 1020 |
^ true |
4009 | 1021 |
] ifFalse:[ |
1022 |
^ false |
|
1023 |
] |
|
1024 |
]. |
|
1025 |
(key == #FocusPrevious) ifTrue:[ |
|
1026 |
"go to last selection in selection history" |
|
1027 |
self doBack. |
|
1028 |
^ true |
|
1029 |
]. |
|
1030 |
(key == #FocusNext) ifTrue:[ |
|
1031 |
"go to next selection in selection history" |
|
1032 |
self doForward. |
|
1033 |
^ true |
|
1034 |
]. |
|
1035 |
(key == #Replace) ifTrue:[ |
|
1036 |
self treeViewFileRename. |
|
1037 |
^ true |
|
1038 |
]. |
|
1039 |
(key == #Delete) ifTrue:[ |
|
1040 |
self doDelete. |
|
1041 |
^ true |
|
1042 |
]. |
|
1043 |
(key == #Cut) ifTrue:[ |
|
1044 |
self doCut. |
|
1045 |
^ true |
|
1046 |
]. |
|
1047 |
(key == #Paste) ifTrue:[ |
|
1048 |
self pasteFiles. |
|
1049 |
^ true |
|
1050 |
]. |
|
1051 |
(key == #Copy) ifTrue:[ |
|
1052 |
self doCopy. |
|
1053 |
^ true |
|
1054 |
]. |
|
3892 | 1055 |
]. |
1056 |
^ false |
|
1057 |
! ! |
|
1058 |
||
3982 | 1059 |
!DirectoryTreeBrowser methodsFor:'file actions'! |
3892 | 1060 |
|
3982 | 1061 |
doCopy |
1062 |
"copy current selected files/directories |
|
1063 |
" |
|
1064 |
||
1065 |
self copyFilesToClipBoard:self selectedItems. |
|
1066 |
! |
|
3892 | 1067 |
|
3982 | 1068 |
doCut |
1069 |
"cut current selected files/directories |
|
1070 |
" |
|
1071 |
self cutFilesToClipBoard:self selectedItems. |
|
1072 |
! |
|
1073 |
||
1074 |
doDelete |
|
1075 |
"delete current selected files/directories |
|
1076 |
" |
|
1077 |
||
1078 |
self deleteFiles:self selectedFiles. |
|
3892 | 1079 |
! ! |
1080 |
||
1081 |
!DirectoryTreeBrowser methodsFor:'queries'! |
|
1082 |
||
1083 |
masterIsFileBrowser |
|
1084 |
||
1085 |
^ self masterApplication class = FileBrowserV2 |
|
1086 |
! |
|
1087 |
||
3982 | 1088 |
selectedFilesIncludesNonRootDirectory |
1089 |
||
1090 |
| directories| |
|
1091 |
||
1092 |
directories := self selectedDirectories. |
|
1093 |
directories isEmpty ifTrue:[^ false]. |
|
1094 |
directories do:[:aDir| |
|
1095 |
(aDir asString) ~= (self rootHolder value) ifTrue:[ |
|
1096 |
^ true |
|
1097 |
] |
|
1098 |
]. |
|
1099 |
^ false |
|
1100 |
! ! |
|
1101 |
||
1102 |
!DirectoryTreeBrowser methodsFor:'selection'! |
|
1103 |
||
1104 |
firstSelectedDirectory |
|
1105 |
||
1106 |
| selection dirs dirIndices| |
|
1107 |
||
1108 |
selection := self selectedItems. |
|
1109 |
selection isEmpty ifTrue:[ ^ nil ]. |
|
3892 | 1110 |
|
3982 | 1111 |
dirs := selection collect:[:item| item isDirectory]. |
1112 |
dirs isEmpty ifTrue:[^ nil]. |
|
1113 |
dirIndices := selection collect:[:item | |
|
4008 | 1114 |
self fileList identityIndexOf:item. |
3982 | 1115 |
]. |
1116 |
^ (self fileList at:(dirIndices min)) fileName. |
|
1117 |
! |
|
1118 |
||
1119 |
rootSelected |
|
1120 |
||
1121 |
| selectedItems | |
|
1122 |
selectedItems := self selectedItems. |
|
1123 |
selectedItems isEmpty ifTrue:[^ false]. |
|
1124 |
^ selectedItems includesIdentical:self fileList root |
|
1125 |
! |
|
1126 |
||
1127 |
selectFiles:aColOfFileOrDirectory |
|
1128 |
"selects a file; if the file is not included in my |
|
1129 |
root directory, the root will be changed |
|
1130 |
" |
|
1131 |
|items directory item newRoot| |
|
1132 |
||
1133 |
aColOfFileOrDirectory isEmpty ifTrue:[ self selectItems:#()]. |
|
1134 |
||
1135 |
items := OrderedCollection new. |
|
1136 |
aColOfFileOrDirectory do:[:file| |
|
1137 |
file exists ifTrue:[ |
|
1138 |
item := self fileList findLastForFile:file. |
|
1139 |
item isNil ifTrue:[ |
|
1140 |
newRoot := self getCommonForCurrentFiles. |
|
1141 |
newRoot := self getDirWithoutFileName:newRoot. |
|
1142 |
self rootHolder value:newRoot. |
|
1143 |
item := self fileList root. |
|
3892 | 1144 |
|
3982 | 1145 |
file isDirectory ifTrue:[ directory := file ] |
1146 |
ifFalse:[ directory := file directory ] |
|
1147 |
. |
|
1148 |
directory == file ifFalse:[ |
|
1149 |
item := item detect:[:el| el fileName = file ] ifNone:item. |
|
1150 |
]. |
|
1151 |
]. |
|
1152 |
"/ set a new root directory |
|
1153 |
items add:item. |
|
1154 |
]. |
|
1155 |
]. |
|
1156 |
self selectItems:items |
|
1157 |
! |
|
1158 |
||
1159 |
selectItems:aColOfItems |
|
1160 |
||
4011 | 1161 |
|currentSelection newSelection| |
3982 | 1162 |
|
4011 | 1163 |
currentSelection := self selectedItems. |
1164 |
self multipleSelect ifTrue:[ |
|
1165 |
currentSelection notNil ifTrue:[ |
|
1166 |
aColOfItems size == currentSelection size ifTrue:[ |
|
1167 |
(aColOfItems findFirst:[:item | (currentSelection includesIdentical:item) not ]) ~~ 0 ifFalse:[ |
|
1168 |
^ self |
|
1169 |
]. |
|
1170 |
] |
|
1171 |
]. |
|
1172 |
newSelection := aColOfItems. |
|
1173 |
] ifFalse:[ |
|
1174 |
newSelection := aColOfItems isEmpty ifTrue:[nil] ifFalse:[aColOfItems first]. |
|
1175 |
newSelection == currentSelection ifTrue:[ |
|
1176 |
^ self |
|
1177 |
] |
|
1178 |
]. |
|
1179 |
||
3982 | 1180 |
aColOfItems notEmpty ifTrue:[ |
1181 |
aColOfItems first makeVisible. |
|
1182 |
]. |
|
4011 | 1183 |
self updateToExternFileHolderLock doLocked:[ |
1184 |
self treeSelectionHolder value:newSelection. |
|
3989 | 1185 |
]. |
3982 | 1186 |
! |
1187 |
||
1188 |
selectedDirectories |
|
1189 |
||
1190 |
| selItems | |
|
1191 |
||
1192 |
selItems := self selectedDirectoryItems. |
|
1193 |
^ selItems collect:[: el | el fileName ]. |
|
1194 |
! |
|
1195 |
||
1196 |
selectedDirectoryItems |
|
1197 |
||
1198 |
| sel | |
|
1199 |
sel := self selectedItems. |
|
1200 |
^ sel select:[: el | el isDirectory ]. |
|
1201 |
! |
|
1202 |
||
1203 |
selectedFilenameDirectories |
|
1204 |
||
1205 |
| selectedItems setOfDirectories| |
|
1206 |
selectedItems := self selectedItems. |
|
1207 |
setOfDirectories := Set new. |
|
1208 |
selectedItems do:[:item| |
|
1209 |
| filename| |
|
1210 |
filename := self getDirWithoutFileName:(item fileName). |
|
1211 |
setOfDirectories add:filename. |
|
1212 |
]. |
|
1213 |
^ setOfDirectories. |
|
1214 |
! |
|
1215 |
||
1216 |
selectedFiles |
|
1217 |
||
1218 |
^ self selectedItems collect:[:item| item fileName]. |
|
1219 |
! |
|
1220 |
||
1221 |
selectedItems |
|
1222 |
||
1223 |
| selection | |
|
1224 |
||
1225 |
selection := self treeSelectionHolder value. |
|
1226 |
selection isNil ifTrue:[ ^ #() ]. |
|
4002 | 1227 |
multipleSelect ifTrue:[^ selection ]. |
1228 |
^ Array with:selection. "Wrap single value into Array" |
|
3892 | 1229 |
! ! |
1230 |
||
1231 |
!DirectoryTreeBrowser methodsFor:'startup & release'! |
|
1232 |
||
3952 | 1233 |
initialize |
1234 |
||
1235 |
inDropMode := false. |
|
3961 | 1236 |
^ super initialize. |
3952 | 1237 |
! |
1238 |
||
3892 | 1239 |
makeDependent |
1240 |
||
4008 | 1241 |
super makeDependent. |
3892 | 1242 |
self currentFileNameHolder addDependent:self. |
4071 | 1243 |
self rootHolder addDependent:self. |
3892 | 1244 |
self viewFilesInDirectoryTree addDependent:self. |
4011 | 1245 |
self filterBlockHolder addDependent:self. |
3892 | 1246 |
! |
1247 |
||
1248 |
postBuildAsSubcanvasWith:aBuilder |
|
1249 |
||
1250 |
super postBuildAsSubcanvasWith:aBuilder. |
|
1251 |
! |
|
1252 |
||
1253 |
postBuildDirBrowser:aWidget |
|
1254 |
||
1255 |
dirBrowser := aWidget scrolledView. |
|
3968 | 1256 |
dirBrowser hasConstantHeight:true. |
1257 |
||
3892 | 1258 |
dirBrowser openEditorAction:[:ln :aGC| |field item filename newFileString rename newFilename| |
3957 | 1259 |
self allowFileOperations value ifTrue:[ |
1260 |
item := self fileList at:ln. |
|
3892 | 1261 |
|
3957 | 1262 |
item label isString ifFalse:[ |
1263 |
field := nil |
|
1264 |
] ifTrue:[ |
|
1265 |
field := EditField new. |
|
1266 |
field level:0. |
|
1267 |
field acceptOnReturn:true. |
|
4009 | 1268 |
field acceptOnLeave:false. |
3957 | 1269 |
field acceptAction:[:x| |
1270 |
filename := item fileName. |
|
1271 |
newFileString := x at:1. |
|
1272 |
filename baseName = newFileString ifFalse:[ |
|
1273 |
(self renameFile:filename to:newFileString update:false) ifTrue:[ |
|
1274 |
newFilename := filename directory construct:newFileString. |
|
1275 |
self updateAndSelect:(OrderedCollection with:newFilename). |
|
1276 |
]. |
|
3892 | 1277 |
]. |
3957 | 1278 |
aGC closeEditor. |
3892 | 1279 |
]. |
3957 | 1280 |
field font:(aGC font). |
1281 |
field contents:(item label). |
|
3892 | 1282 |
]. |
3957 | 1283 |
field |
3892 | 1284 |
]. |
1285 |
]. |
|
1286 |
! |
|
1287 |
||
1288 |
postBuildWith:aBuilder |
|
1289 |
||
1290 |
super postBuildWith:aBuilder. |
|
1291 |
! |
|
1292 |
||
4071 | 1293 |
postOpen |
1294 |
||
1295 |
self rootHolderChanged. |
|
1296 |
self abstractCurrentFileNameHolderChanged. |
|
1297 |
self currentFileNameHolderChanged. |
|
4151 | 1298 |
self sortFileListsBy:self sortPropertyInTree value. |
4071 | 1299 |
self windowGroup addPreEventHook:self. |
1300 |
! |
|
1301 |
||
3892 | 1302 |
postOpenAsSubcanvasWith:aBuilder |
1303 |
||
4071 | 1304 |
super postOpenAsSubcanvasWith:aBuilder. |
1305 |
self postOpen. |
|
3892 | 1306 |
! |
1307 |
||
1308 |
postOpenWith:aBuilder |
|
4071 | 1309 |
"only invoked if the application not started from a master" |
3892 | 1310 |
|
4071 | 1311 |
super postOpenWith:aBuilder. |
1312 |
self postOpen. |
|
3892 | 1313 |
! |
1314 |
||
1315 |
preBuildWith:aBuilder |
|
1316 |
||
1317 |
self masterApplication isNil ifTrue:[ |
|
1318 |
self masterApplication:nil. |
|
1319 |
]. |
|
1320 |
^ super preBuildWith:aBuilder. |
|
1321 |
! |
|
1322 |
||
1323 |
release |
|
1324 |
||
1325 |
self fileList stopMonitoringTask. |
|
1326 |
^ super release. |
|
1327 |
! ! |
|
1328 |
||
1329 |
!DirectoryTreeBrowser::DirTreeBrowserHFL methodsFor:'accessing'! |
|
1330 |
||
3952 | 1331 |
draggedItem |
3892 | 1332 |
|
3952 | 1333 |
^ draggedItem |
1334 |
! |
|
3892 | 1335 |
|
3952 | 1336 |
draggedItem:anItemOrNil |
1337 |
||
1338 |
draggedItem := anItemOrNil. |
|
3892 | 1339 |
! ! |
1340 |
||
1341 |
!DirectoryTreeBrowser::DirTreeBrowserHFL methodsFor:'protocol'! |
|
1342 |
||
3969 | 1343 |
grayDirectoryIcon |
1344 |
||
1345 |
grayDirectoryIcon isNil ifTrue:[ |
|
1346 |
grayDirectoryIcon := (FileBrowser iconForKeyMatching:#directoryOpenGray). |
|
1347 |
]. |
|
1348 |
^ grayDirectoryIcon |
|
1349 |
! |
|
1350 |
||
1351 |
iconFor:anItem |
|
1352 |
"returns the icon for an item |
|
1353 |
" |
|
3892 | 1354 |
|
1355 |
draggedItem == anItem ifTrue:[ |
|
3969 | 1356 |
^ self grayDirectoryIcon. |
3892 | 1357 |
]. |
3969 | 1358 |
^ super iconFor:anItem. |
3892 | 1359 |
! ! |
1360 |
||
1361 |
!DirectoryTreeBrowser class methodsFor:'documentation'! |
|
1362 |
||
1363 |
version |
|
4422 | 1364 |
^ '$Header: /cvs/stx/stx/libtool/DirectoryTreeBrowser.st,v 1.39 2003-01-09 14:42:09 penk Exp $' |
3892 | 1365 |
! ! |