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