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