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