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