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