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