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