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