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