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