author | Claus Gittinger <cg@exept.de> |
Sat, 13 Jul 2019 14:00:30 +0200 | |
changeset 18895 | f081b08d0755 |
parent 18737 | d8370f93fd9b |
child 19008 | 302ee0e701e1 |
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 |
|
22 |
sortPropertyInTree sortCaselessInTreeBrowser' |
|
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 |
|
393 |
indication: sortCaselessInTreeBrowser |
|
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 |
554 |
" expand the selected item if one directory selected" |
|
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 |
||
5970 | 633 |
| aSymbol cmpOp instanceSortBlock treeSortBlock locSortCaselessInTreeBrowser| |
4151 | 634 |
|
5970 | 635 |
locSortCaselessInTreeBrowser := self sortCaselessInTreeBrowser value. |
4151 | 636 |
aSymbol := instanceName asSymbol. |
637 |
cmpOp := #'<'. |
|
638 |
instanceSortBlock := [:a :b | |
|
639 |
|entry1 entry2| |
|
640 |
||
641 |
entry1 := (a perform:aSymbol). |
|
642 |
entry2 := (b perform:aSymbol). |
|
643 |
((entry1 isNil) or:[entry2 isNil]) ifTrue:[ |
|
644 |
true |
|
645 |
] ifFalse:[ |
|
646 |
(aSymbol = #baseName) ifTrue:[ |
|
5970 | 647 |
locSortCaselessInTreeBrowser ifTrue:[ |
4151 | 648 |
entry1 := entry1 asString asLowercase. |
649 |
entry2 := entry2 asString asLowercase. |
|
650 |
] ifFalse:[ |
|
651 |
entry1 := entry1 asString. |
|
652 |
entry2 := entry2 asString. |
|
653 |
]. |
|
654 |
]. |
|
655 |
entry1 perform:cmpOp with:entry2 |
|
656 |
] |
|
657 |
]. |
|
658 |
treeSortBlock := [ :a :b | |
|
659 |
|aIsDir bIsDir res| |
|
660 |
||
661 |
aIsDir := a isDirectory. |
|
662 |
bIsDir := b isDirectory. |
|
663 |
(aIsDir and:[bIsDir]) ifTrue:[ |
|
664 |
| entry1 entry2 | |
|
665 |
entry1 := a baseName. |
|
666 |
entry2 := b baseName. |
|
5970 | 667 |
locSortCaselessInTreeBrowser ifTrue:[ |
668 |
entry1 := entry1 asString asLowercase. |
|
669 |
entry2 := entry2 asString asLowercase. |
|
670 |
] ifFalse:[ |
|
671 |
entry1 := entry1 asString. |
|
672 |
entry2 := entry2 asString. |
|
673 |
]. |
|
4151 | 674 |
res := entry1 < entry2. |
675 |
] ifFalse:[ |
|
676 |
(aIsDir or:[bIsDir]) ifTrue:[ |
|
677 |
res := aIsDir |
|
678 |
] ifFalse:[ |
|
679 |
res := instanceSortBlock value:a value:b. |
|
680 |
] |
|
681 |
]. |
|
682 |
res |
|
683 |
]. |
|
684 |
self evaluateSortBlockWith:treeSortBlock. |
|
685 |
! |
|
686 |
||
3892 | 687 |
toggleExpand:anItem |
688 |
(anItem notNil and:[anItem isDirectory]) ifTrue:[ |
|
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
689 |
"/ self withWaitCursorDo:[ |
5219 | 690 |
anItem toggleExpand |
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
691 |
"/ ] |
3892 | 692 |
]. |
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
693 |
|
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
694 |
"Modified: / 25-07-2006 / 09:09:05 / cg" |
3892 | 695 |
! |
696 |
||
3982 | 697 |
toggleExpandSelectedItem |
698 |
|selDir| |
|
699 |
||
700 |
selDir := self selectedDirectoryItems. |
|
701 |
selDir do:[:item| |
|
702 |
self toggleExpand:item. |
|
703 |
]. |
|
704 |
! |
|
705 |
||
3892 | 706 |
updateSelectedItem |
707 |
| sel | |
|
708 |
||
3982 | 709 |
sel := self selectedItems. |
3892 | 710 |
sel isEmpty ifTrue:[ ^ self]. |
711 |
sel do:[:item| |
|
712 |
item invalidateRepairNow:true. |
|
713 |
] |
|
714 |
! ! |
|
715 |
||
716 |
!DirectoryTreeBrowser methodsFor:'aspects'! |
|
717 |
||
3956 | 718 |
allowFileOperations |
719 |
"allowFileOperations |
|
720 |
" |
|
721 |
allowFileOperations isNil ifTrue:[ |
|
722 |
allowFileOperations := true asValue. |
|
723 |
]. |
|
724 |
^ allowFileOperations. |
|
725 |
! |
|
726 |
||
3892 | 727 |
fileList |
728 |
"holder, which keeps the current list of file entries shown by the directory-browser |
|
729 |
" |
|
730 |
||
731 |
|list| |
|
732 |
||
733 |
(list := builder bindingAt:#fileList) isNil ifTrue:[ |
|
734 |
list := DirTreeBrowserHFL new. |
|
735 |
list application:self. |
|
736 |
list showRoot:true. |
|
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
737 |
self setMatchBlockInList:list. |
5672 | 738 |
"/ do not set the directory holder in startup |
739 |
"/ list directory:(self rootHolder value). |
|
3892 | 740 |
builder aspectAt:#fileList put:list. |
7098 | 741 |
"/ list monitoringTaskDelay:2 |
3892 | 742 |
]. |
743 |
^ list |
|
7098 | 744 |
|
745 |
"Modified: / 08-09-2006 / 13:29:17 / cg" |
|
3892 | 746 |
! |
747 |
||
3958 | 748 |
multipleSelect |
4801 | 749 |
^ multipleSelect ? false |
3958 | 750 |
! |
751 |
||
752 |
multipleSelect:aBoolean |
|
753 |
multipleSelect := aBoolean. |
|
4713 | 754 |
browser notNil ifTrue:[ |
755 |
browser multipleSelectOk:aBoolean. |
|
4670 | 756 |
]. |
3958 | 757 |
! |
758 |
||
3956 | 759 |
newVisibilityHolder |
9112
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
760 |
"newVisibilityHolder" |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
761 |
|
3956 | 762 |
newVisibilityHolder isNil ifTrue:[ |
763 |
newVisibilityHolder := true asValue. |
|
764 |
]. |
|
765 |
^ newVisibilityHolder. |
|
766 |
! |
|
767 |
||
4151 | 768 |
sortCaselessInTreeBrowser |
769 |
||
770 |
sortCaselessInTreeBrowser isNil ifTrue:[ |
|
5970 | 771 |
sortCaselessInTreeBrowser := self sortCaseless value asValue. |
4151 | 772 |
sortCaselessInTreeBrowser addDependent:self. |
773 |
]. |
|
774 |
^ sortCaselessInTreeBrowser. |
|
775 |
! |
|
776 |
||
777 |
sortInTreeVisibilityHolder |
|
778 |
"newVisibilityHolder |
|
779 |
" |
|
780 |
sortInTreeVisibilityHolder isNil ifTrue:[ |
|
781 |
sortInTreeVisibilityHolder := self viewFilesInDirectoryTree value asValue. |
|
782 |
]. |
|
783 |
^ sortInTreeVisibilityHolder. |
|
784 |
! |
|
785 |
||
786 |
sortPropertyInTree |
|
787 |
||
788 |
sortPropertyInTree isNil ifTrue:[ |
|
789 |
sortPropertyInTree := #baseName asValue. |
|
790 |
sortPropertyInTree addDependent:self. |
|
791 |
]. |
|
792 |
^ sortPropertyInTree. |
|
793 |
! |
|
794 |
||
9112
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
795 |
sortPropertyInTree:aValueHolder |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
796 |
sortPropertyInTree removeDependent:self. |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
797 |
sortPropertyInTree := aValueHolder. |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
798 |
sortPropertyInTree addDependent:self. |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
799 |
! |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
800 |
|
3982 | 801 |
treeSelectionHolder |
802 |
treeSelectionHolder isNil ifTrue:[ |
|
803 |
treeSelectionHolder := ValueHolder new. |
|
804 |
treeSelectionHolder addDependent:self. |
|
805 |
]. |
|
806 |
^ treeSelectionHolder |
|
13154
2d99f6a0181b
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
12514
diff
changeset
|
807 |
! |
2d99f6a0181b
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
12514
diff
changeset
|
808 |
|
2d99f6a0181b
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
12514
diff
changeset
|
809 |
treeSelectionHolder:aValueHolder |
2d99f6a0181b
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
12514
diff
changeset
|
810 |
treeSelectionHolder removeDependent:self. |
2d99f6a0181b
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
12514
diff
changeset
|
811 |
treeSelectionHolder := aValueHolder. |
2d99f6a0181b
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
12514
diff
changeset
|
812 |
treeSelectionHolder addDependent:self. |
3892 | 813 |
! ! |
814 |
||
815 |
!DirectoryTreeBrowser methodsFor:'change & update'! |
|
816 |
||
3982 | 817 |
changeMatchBlock |
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
818 |
self setMatchBlockInList:(self fileList). |
4021 | 819 |
self currentFileNameHolderChanged. |
3982 | 820 |
! |
3892 | 821 |
|
3982 | 822 |
currentFileNameHolderChanged |
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
823 |
|filesToSelect viewFiles| |
3892 | 824 |
|
3982 | 825 |
viewFiles:= self viewFilesInDirectoryTree value. |
826 |
viewFiles ifTrue:[ |
|
7562 | 827 |
filesToSelect := self currentSelectedObjects. |
3982 | 828 |
] ifFalse:[ |
6727 | 829 |
filesToSelect := self currentSelectedDirectories. |
3982 | 830 |
]. |
4018 | 831 |
self rootHolder notNil ifTrue:[ |
5655 | 832 |
self selectFiles:filesToSelect. |
3982 | 833 |
]. |
7562 | 834 |
|
835 |
"Modified: / 04-12-2006 / 13:15:42 / cg" |
|
3982 | 836 |
! |
837 |
||
4011 | 838 |
rootHolderChanged |
6764 | 839 |
|list file rootHolder| |
4011 | 840 |
|
841 |
list := self fileList. |
|
842 |
rootHolder := self rootHolder. |
|
843 |
file := rootHolder value. |
|
844 |
file notNil ifTrue:[ |
|
6764 | 845 |
file := file asFilename. |
4011 | 846 |
file isDirectory ifTrue:[ |
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
847 |
"/ self withWaitCursorDo:[ |
6529 | 848 |
list directory:file |
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
849 |
"/ ]. |
4011 | 850 |
] |
851 |
]. |
|
6764 | 852 |
rootHolder value:(list directory asString) withoutNotifying:self. |
5217 | 853 |
(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
|
854 |
|
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
855 |
"Modified: / 25-07-2006 / 09:08:59 / cg" |
4011 | 856 |
! |
857 |
||
3982 | 858 |
selectionChanged |
3995
8341aed594d2
Fix for single values and FileDialog
Stefan Vogel <sv@exept.de>
parents:
3989
diff
changeset
|
859 |
|sel currentFileDir| |
3982 | 860 |
|
5377 | 861 |
"if viewFiles is false i can't take my |
862 |
selection to overwrite currentFileNameHolder" |
|
3982 | 863 |
sel := self selectedFiles. |
5377 | 864 |
self viewFilesInDirectoryTree value ifFalse:[ |
865 |
(self currentFilesAreInSameDirectory |
|
7562 | 866 |
and:[sel size == 1 and:[self currentSelectedObjects notEmpty]]) ifTrue:[ |
867 |
currentFileDir := self getDirWithoutFileName:(self currentSelectedObjects first). |
|
5377 | 868 |
sel first = currentFileDir ifTrue:[ |
3892 | 869 |
^ self. |
870 |
]. |
|
871 |
]. |
|
872 |
]. |
|
5959 | 873 |
self setCurrentFileNames:sel. |
7562 | 874 |
|
875 |
"Modified: / 04-12-2006 / 13:15:51 / cg" |
|
3892 | 876 |
! |
877 |
||
878 |
update:something with:aParameter from:aModel |
|
5377 | 879 |
"one of my models changed" |
3892 | 880 |
|
5377 | 881 |
"the execution of selectionChanged and currentFileNameHolderChanged must |
882 |
lock against each other because values mustn't be the same (e.g. no files |
|
883 |
in tree view)" |
|
3892 | 884 |
|
5444 | 885 |
(aModel == self currentFileNameHolder or:[aModel == self currentDirectories]) ifTrue:[ |
4003 | 886 |
super update:something with:aParameter from:aModel. |
3892 | 887 |
self updateTreeSelection doIfUnLocked:[ |
888 |
self updateToExternFileHolderLock doLocked:[ |
|
3982 | 889 |
self currentFileNameHolderChanged. |
3892 | 890 |
]. |
891 |
]. |
|
4003 | 892 |
^ self. |
3892 | 893 |
]. |
894 |
aModel == self treeSelectionHolder ifTrue:[ |
|
895 |
self updateToExternFileHolderLock doIfUnLocked:[ |
|
896 |
self updateTreeSelection doLocked:[ |
|
3982 | 897 |
self selectionChanged. |
3892 | 898 |
] |
899 |
]. |
|
900 |
^ self |
|
901 |
]. |
|
3982 | 902 |
aModel == self rootHolder ifTrue:[ |
4011 | 903 |
self rootHolderChanged. |
3892 | 904 |
^ self. |
905 |
]. |
|
906 |
aModel == self viewFilesInDirectoryTree ifTrue:[ |
|
4151 | 907 |
self sortInTreeVisibilityHolder value:(aModel value). |
3982 | 908 |
self updateToExternFileHolderLock doLocked:[ |
909 |
self changeMatchBlock. |
|
3892 | 910 |
]. |
911 |
^ self. |
|
912 |
]. |
|
4151 | 913 |
aModel == self sortPropertyInTree ifTrue:[ |
914 |
self sortFileListsBy:aModel value. |
|
3989 | 915 |
^ self. |
4151 | 916 |
]. |
917 |
aModel == self sortCaselessInTreeBrowser ifTrue:[ |
|
918 |
self sortPropertyInTree setValue:#baseName. |
|
919 |
self sortPropertyInTree changed. |
|
920 |
]. |
|
4011 | 921 |
aModel == self filterBlockHolder ifTrue:[ |
3982 | 922 |
" filter goes only on fileNames not on directories |
923 |
have to change the matchBlock only if files are shown" |
|
924 |
self viewFilesInDirectoryTree value ifTrue:[ |
|
4018 | 925 |
self changeMatchBlock. |
3982 | 926 |
]. |
927 |
^ self |
|
3892 | 928 |
]. |
929 |
super update:something with:aParameter from:aModel. |
|
930 |
^ self |
|
931 |
! ! |
|
932 |
||
933 |
!DirectoryTreeBrowser methodsFor:'drag & drop'! |
|
934 |
||
4746 | 935 |
dropDestinationPath |
936 |
|destination| |
|
3892 | 937 |
|
3952 | 938 |
destination := self fileList draggedItem. |
7583 | 939 |
destination isNil ifTrue:[^ nil]. |
3952 | 940 |
|
4746 | 941 |
^ destination fileName. |
3892 | 942 |
! |
943 |
||
4682
89db9d28788a
autoScroll if drop-pointer is at top/bottom
Claus Gittinger <cg@exept.de>
parents:
4670
diff
changeset
|
944 |
dropOver:aDropContext |
4611 | 945 |
"called during drag & drop while moving over the widget." |
946 |
||
5330 | 947 |
|lineNr newDest| |
3952 | 948 |
|
949 |
inDropMode ifFalse:[^ self]. |
|
950 |
||
4682
89db9d28788a
autoScroll if drop-pointer is at top/bottom
Claus Gittinger <cg@exept.de>
parents:
4670
diff
changeset
|
951 |
lineNr := self getLineNumberFor:aDropContext. |
3952 | 952 |
lineNr notNil ifTrue:[ |
953 |
newDest := self fileList at:lineNr ifAbsent:nil. |
|
954 |
]. |
|
4018 | 955 |
(newDest isNil or:[newDest == self fileList draggedItem]) ifTrue:[ |
3952 | 956 |
^ self |
957 |
]. |
|
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
6160
diff
changeset
|
958 |
newDest isDirectory ifFalse:[ |
3952 | 959 |
newDest := nil. |
960 |
canDropItem := false. |
|
961 |
]. |
|
4682
89db9d28788a
autoScroll if drop-pointer is at top/bottom
Claus Gittinger <cg@exept.de>
parents:
4670
diff
changeset
|
962 |
self dropTargetItemChangedTo:newDest in:aDropContext. |
3952 | 963 |
|
964 |
newDest notNil ifTrue:[ |
|
4682
89db9d28788a
autoScroll if drop-pointer is at top/bottom
Claus Gittinger <cg@exept.de>
parents:
4670
diff
changeset
|
965 |
aDropContext dropSource argument == #archivApplication ifTrue:[ |
3952 | 966 |
canDropItem := true. |
967 |
] ifFalse:[ |
|
4682
89db9d28788a
autoScroll if drop-pointer is at top/bottom
Claus Gittinger <cg@exept.de>
parents:
4670
diff
changeset
|
968 |
canDropItem := self canDropFiles:(aDropContext dropObjects) for:newDest fileName. |
3952 | 969 |
]. |
970 |
]. |
|
3892 | 971 |
! |
972 |
||
3952 | 973 |
dropTargetItemChangedTo:anItem in:aDropContext |
974 |
|current| |
|
975 |
||
976 |
current := self fileList draggedItem. |
|
977 |
current == anItem ifTrue:[^ self]. |
|
978 |
||
979 |
self fileList draggedItem:anItem. |
|
980 |
||
981 |
aDropContext contentsWillChange. |
|
9535
434bc2b7d085
changed: #dropTargetItemChangedTo:in:
Claus Gittinger <cg@exept.de>
parents:
9356
diff
changeset
|
982 |
current notNil ifTrue:[ |
3952 | 983 |
current isDirectory ifTrue:[ |
984 |
self removeExpandItemTimedBlock. |
|
4440 | 985 |
current makeIconGray:false. |
3952 | 986 |
current changed:#icon. |
987 |
] |
|
988 |
]. |
|
3892 | 989 |
|
9535
434bc2b7d085
changed: #dropTargetItemChangedTo:in:
Claus Gittinger <cg@exept.de>
parents:
9356
diff
changeset
|
990 |
anItem notNil ifTrue:[ |
3952 | 991 |
anItem isDirectory ifTrue:[ |
4440 | 992 |
anItem makeIconGray:true. |
3952 | 993 |
anItem changed:#icon. |
13296
05707d78a3cc
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
13236
diff
changeset
|
994 |
(anItem notNil and:[anItem fileName isWritableDirectory]) ifTrue:[ |
6337 | 995 |
self |
996 |
setupAutoExpandItemTimedBlock: |
|
997 |
[ |
|
998 |
self expandForDrop:anItem with:aDropContext. |
|
999 |
]. |
|
3952 | 1000 |
] |
1001 |
]. |
|
1002 |
]. |
|
4713 | 1003 |
browser shown ifTrue:[ |
1004 |
browser repairDamage. |
|
3952 | 1005 |
]. |
9535
434bc2b7d085
changed: #dropTargetItemChangedTo:in:
Claus Gittinger <cg@exept.de>
parents:
9356
diff
changeset
|
1006 |
|
434bc2b7d085
changed: #dropTargetItemChangedTo:in:
Claus Gittinger <cg@exept.de>
parents:
9356
diff
changeset
|
1007 |
"Modified: / 08-08-2010 / 14:42:21 / cg" |
3892 | 1008 |
! |
1009 |
||
1010 |
expandForDrop:item with:aDropContext |
|
1011 |
||
1012 |
aDropContext saveDraw:[ |
|
1013 |
(self doExpand:item) ifTrue:[ |
|
1014 |
self windowGroup processExposeEvents |
|
1015 |
]. |
|
1016 |
] |
|
1017 |
! |
|
1018 |
||
1019 |
getDisplayObjects:anArgument |
|
4713 | 1020 |
|selectedItems string fnName stream| |
3892 | 1021 |
|
4713 | 1022 |
selectedItems := self selectedItems. |
1023 |
selectedItems isEmpty ifTrue:[ ^ '']. |
|
1024 |
||
15593 | 1025 |
stream := CharacterWriteStream with:(selectedItems first baseName). |
4713 | 1026 |
selectedItems size == 1 ifTrue:[ |
3892 | 1027 |
fnName := 'ui_menuitem.xpm'. |
1028 |
] ifFalse:[ |
|
1029 |
fnName := 'ui_submenu_open.xpm'. |
|
1030 |
stream nextPutAll:' ... '. |
|
4713 | 1031 |
stream nextPutAll:(selectedItems last baseName). |
3892 | 1032 |
]. |
1033 |
string := stream contents. |
|
1034 |
stream close. |
|
1035 |
||
1036 |
fnName := 'ui_menuitem.xpm'. |
|
17539 | 1037 |
^ Array with:(LabelAndIcon icon:(Image fromFile:fnName) string:(string allBold)) |
1038 |
||
1039 |
"Modified (format): / 20-06-2017 / 08:17:36 / cg" |
|
3892 | 1040 |
! |
1041 |
||
1042 |
removeExpandItemTimedBlock |
|
6337 | 1043 |
|b| |
3952 | 1044 |
|
6337 | 1045 |
(b := expandItemTimedBlock) notNil ifTrue:[ |
1046 |
expandItemTimedBlock := nil. |
|
1047 |
Processor removeTimedBlock:b. |
|
3892 | 1048 |
] |
6337 | 1049 |
! |
1050 |
||
1051 |
setupAutoExpandItemTimedBlock:aBlock |
|
1052 |
expandItemTimedBlock := aBlock. |
|
1053 |
Processor |
|
1054 |
addTimedBlock:expandItemTimedBlock |
|
1055 |
afterMilliseconds:(self class timeForExpandOnDropInMilliseconds). |
|
3892 | 1056 |
! ! |
1057 |
||
1058 |
!DirectoryTreeBrowser methodsFor:'event handling'! |
|
1059 |
||
1060 |
processEvent:anEvent |
|
1061 |
"filter keyboard events. |
|
1062 |
Return true, if I have eaten the event" |
|
1063 |
||
12114 | 1064 |
<resource: #keyboard (#CursorLeft #FocusPrevious #FocusNext |
17825 | 1065 |
#Cut #Copy #Delete #Replace #Paste |
1066 |
#BackSpace)> |
|
12114 | 1067 |
|
4713 | 1068 |
|focusView key rawKey| |
3892 | 1069 |
|
4713 | 1070 |
anEvent isKeyPressEvent ifFalse:[^ false]. |
3892 | 1071 |
|
4713 | 1072 |
focusView := anEvent targetView. |
1073 |
(focusView isNil or:[focusView ~~ browser]) ifTrue:[ ^ false]. |
|
3906 | 1074 |
|
4713 | 1075 |
key := anEvent key. |
1076 |
rawKey := anEvent rawKey. |
|
1077 |
||
1078 |
(key == #CursorLeft) ifTrue:[ |
|
1079 |
"go to last selection in selection history" |
|
1080 |
(self rootSelected and:[(self fileList at:1) isExpanded not]) ifTrue:[ |
|
1081 |
self doGoDirectoryUp. |
|
4009 | 1082 |
^ true |
1083 |
]. |
|
4713 | 1084 |
^ false |
1085 |
]. |
|
1086 |
(key == #FocusPrevious) ifTrue:[ |
|
1087 |
"go to last selection in selection history" |
|
1088 |
self doBack. |
|
1089 |
^ true |
|
1090 |
]. |
|
1091 |
(key == #FocusNext) ifTrue:[ |
|
1092 |
"go to next selection in selection history" |
|
1093 |
self doForward. |
|
1094 |
^ true |
|
1095 |
]. |
|
1096 |
(key == #Replace) ifTrue:[ |
|
5063 | 1097 |
self renameFileInTreeView. |
4713 | 1098 |
^ true |
3892 | 1099 |
]. |
4713 | 1100 |
(key == #Cut) ifTrue:[ |
1101 |
self doCut. |
|
1102 |
^ true |
|
1103 |
]. |
|
1104 |
(key == #Copy) ifTrue:[ |
|
1105 |
self doCopy. |
|
1106 |
^ true |
|
1107 |
]. |
|
17825 | 1108 |
((key == #Delete) or:[ key == #BackSpace ]) ifTrue:[ |
4713 | 1109 |
self doDelete. |
1110 |
^ true |
|
1111 |
]. |
|
1112 |
(key == #Paste) ifTrue:[ |
|
1113 |
self pasteFiles. |
|
1114 |
^ true |
|
1115 |
]. |
|
3892 | 1116 |
|
4713 | 1117 |
^ false |
3892 | 1118 |
! ! |
1119 |
||
1120 |
!DirectoryTreeBrowser methodsFor:'queries'! |
|
1121 |
||
4996
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4954
diff
changeset
|
1122 |
hasOpenEditor |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4954
diff
changeset
|
1123 |
|
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4954
diff
changeset
|
1124 |
^ browser hasOpenEditor |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4954
diff
changeset
|
1125 |
! |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4954
diff
changeset
|
1126 |
|
3892 | 1127 |
masterIsFileBrowser |
1128 |
||
13824 | 1129 |
^ self masterApplication isKindOf: FileBrowserV2 |
1130 |
||
1131 |
"Modified: / 04-05-2012 / 16:24:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3892 | 1132 |
! |
1133 |
||
3982 | 1134 |
selectedFilesIncludesNonRootDirectory |
6629 | 1135 |
^ self selectedDirectories contains:[:aDir | (aDir asString) ~= (self rootHolder value)]. |
3982 | 1136 |
|
6629 | 1137 |
"/ |directories| |
1138 |
"/ |
|
1139 |
"/ directories := self selectedDirectories. |
|
1140 |
"/ directories isEmpty ifTrue:[^ false]. |
|
1141 |
"/ directories do:[:aDir| |
|
1142 |
"/ (aDir asString) ~= (self rootHolder value) ifTrue:[ |
|
1143 |
"/ ^ true |
|
1144 |
"/ ] |
|
1145 |
"/ ]. |
|
1146 |
"/ ^ false |
|
3982 | 1147 |
! ! |
1148 |
||
1149 |
!DirectoryTreeBrowser methodsFor:'selection'! |
|
1150 |
||
1151 |
firstSelectedDirectory |
|
1152 |
||
1153 |
| selection dirs dirIndices| |
|
1154 |
||
1155 |
selection := self selectedItems. |
|
1156 |
selection isEmpty ifTrue:[ ^ nil ]. |
|
3892 | 1157 |
|
3982 | 1158 |
dirs := selection collect:[:item| item isDirectory]. |
1159 |
dirs isEmpty ifTrue:[^ nil]. |
|
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1160 |
dirIndices := selection |
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1161 |
collect:[:item | |
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1162 |
self fileList identityIndexOf:item. |
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1163 |
]. |
3982 | 1164 |
^ (self fileList at:(dirIndices min)) fileName. |
1165 |
! |
|
1166 |
||
1167 |
rootSelected |
|
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1168 |
| selectedItems | |
3982 | 1169 |
|
1170 |
selectedItems := self selectedItems. |
|
1171 |
selectedItems isEmpty ifTrue:[^ false]. |
|
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1172 |
^ selectedItems includesIdentical:(self fileList root) |
3982 | 1173 |
! |
1174 |
||
1175 |
selectFiles:aColOfFileOrDirectory |
|
1176 |
"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
|
1177 |
root directory, the root will be changed" |
d028c545a011
changes for better FileDialog
Claus Gittinger <cg@exept.de>
parents:
9109
diff
changeset
|
1178 |
|
10684 | 1179 |
|root items directory item newRoot rootDir| |
3982 | 1180 |
|
1181 |
aColOfFileOrDirectory isEmpty ifTrue:[ self selectItems:#()]. |
|
1182 |
||
10684 | 1183 |
root := self fileList root. |
1184 |
root notNil ifTrue:[ rootDir := root fileName asAbsoluteFilename ]. |
|
10680 | 1185 |
|
3982 | 1186 |
items := OrderedCollection new. |
12101 | 1187 |
aColOfFileOrDirectory do:[:eachFile| |
1188 |
(eachFile notNil and:[eachFile exists]) ifTrue:[ |
|
1189 |
item := self fileList findLastForFile:eachFile inRoot:root directory:rootDir. |
|
3982 | 1190 |
item isNil ifTrue:[ |
6160
fe679d48ff9b
expand directory item if file in directory not exists (for FileDialog)
penk
parents:
6149
diff
changeset
|
1191 |
"/ set a new root directory |
4771
9290fdb65a5d
#getCommonForCurrentFiles renamed to #commonPrefixOfSelectedFiles
Claus Gittinger <cg@exept.de>
parents:
4756
diff
changeset
|
1192 |
newRoot := self commonPrefixOfSelectedFiles. |
3982 | 1193 |
newRoot := self getDirWithoutFileName:newRoot. |
18737 | 1194 |
newRoot := newRoot pathName. |
9881 | 1195 |
newRoot ~= self rootHolder value ifTrue:[ |
1196 |
self rootHolder value:newRoot. |
|
1197 |
]. |
|
3982 | 1198 |
item := self fileList root. |
3892 | 1199 |
|
12101 | 1200 |
eachFile isDirectory ifTrue:[ directory := eachFile ] |
1201 |
ifFalse:[ directory := eachFile directory ] |
|
3982 | 1202 |
. |
12101 | 1203 |
directory == eachFile ifFalse:[ |
1204 |
item := item detect:[:el| el fileName = eachFile ] ifNone:item. |
|
3982 | 1205 |
]. |
1206 |
]. |
|
11593 | 1207 |
item notNil ifTrue:[ |
1208 |
"if it is a directory it should be expanded" |
|
1209 |
"/ item enforcedExpand. |
|
1210 |
items add:item. |
|
1211 |
]. |
|
3982 | 1212 |
]. |
1213 |
]. |
|
1214 |
self selectItems:items |
|
10680 | 1215 |
|
11593 | 1216 |
"Modified: / 12-07-2012 / 11:31:20 / cg" |
18737 | 1217 |
"Modified: / 11-04-2019 / 18:03:58 / Stefan Vogel" |
3982 | 1218 |
! |
1219 |
||
1220 |
selectItems:aColOfItems |
|
4011 | 1221 |
|currentSelection newSelection| |
3982 | 1222 |
|
4011 | 1223 |
currentSelection := self selectedItems. |
8495 | 1224 |
"/ aColOfItems do:[:anItem| anItem isDirectory ifTrue:[ anItem expand ]]. |
1225 |
||
4011 | 1226 |
self multipleSelect ifTrue:[ |
1227 |
currentSelection notNil ifTrue:[ |
|
1228 |
aColOfItems size == currentSelection size ifTrue:[ |
|
1229 |
(aColOfItems findFirst:[:item | (currentSelection includesIdentical:item) not ]) ~~ 0 ifFalse:[ |
|
1230 |
^ self |
|
1231 |
]. |
|
1232 |
] |
|
1233 |
]. |
|
1234 |
newSelection := aColOfItems. |
|
1235 |
] ifFalse:[ |
|
1236 |
newSelection := aColOfItems isEmpty ifTrue:[nil] ifFalse:[aColOfItems first]. |
|
1237 |
newSelection == currentSelection ifTrue:[ |
|
1238 |
^ self |
|
1239 |
] |
|
1240 |
]. |
|
1241 |
||
3982 | 1242 |
aColOfItems notEmpty ifTrue:[ |
18269 | 1243 |
aColOfItems do:#makeVisible. |
3982 | 1244 |
]. |
4011 | 1245 |
self updateToExternFileHolderLock doLocked:[ |
1246 |
self treeSelectionHolder value:newSelection. |
|
3989 | 1247 |
]. |
18269 | 1248 |
|
1249 |
"Modified: / 17-07-2018 / 13:29:56 / Claus Gittinger" |
|
3982 | 1250 |
! |
1251 |
||
14575
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1252 |
selectNextFile |
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1253 |
self halt:'unimplemented'. |
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1254 |
! |
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1255 |
|
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1256 |
selectPreviousFile |
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1257 |
self halt:'unimplemented'. |
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1258 |
! |
ef1331d0a99e
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14301
diff
changeset
|
1259 |
|
3982 | 1260 |
selectedDirectories |
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1261 |
^ self selectedDirectoryItems collect:[: el | el fileName ]. |
3982 | 1262 |
! |
1263 |
||
1264 |
selectedDirectoryItems |
|
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1265 |
^ self selectedItems select:[: el | el isDirectory ]. |
3982 | 1266 |
! |
1267 |
||
1268 |
selectedFilenameDirectories |
|
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1269 |
^ self selectedItems |
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1270 |
collect:[:item | self getDirWithoutFileName:(item fileName)] |
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1271 |
as:Set |
3982 | 1272 |
! |
1273 |
||
1274 |
selectedItems |
|
1275 |
| selection | |
|
1276 |
||
1277 |
selection := self treeSelectionHolder value. |
|
1278 |
selection isNil ifTrue:[ ^ #() ]. |
|
4801 | 1279 |
self multipleSelect ifTrue:[^ selection ]. |
4002 | 1280 |
^ Array with:selection. "Wrap single value into Array" |
3892 | 1281 |
! ! |
1282 |
||
1283 |
!DirectoryTreeBrowser methodsFor:'startup & release'! |
|
1284 |
||
1285 |
makeDependent |
|
1286 |
||
4008 | 1287 |
super makeDependent. |
3892 | 1288 |
self currentFileNameHolder addDependent:self. |
5444 | 1289 |
self currentDirectories addDependent:self. |
4071 | 1290 |
self rootHolder addDependent:self. |
3892 | 1291 |
self viewFilesInDirectoryTree addDependent:self. |
4011 | 1292 |
self filterBlockHolder addDependent:self. |
3892 | 1293 |
! |
1294 |
||
5063 | 1295 |
openEditorAction |
1296 |
^ [:ln :aGC | |
|
1297 |
self openEditorIn:aGC forLine:ln |
|
1298 |
]. |
|
1299 |
! |
|
1300 |
||
4887 | 1301 |
openEditorIn:aGC forLine:ln |
1302 |
|item alreadyAccepted filename field newFileString newFilename| |
|
1303 |
||
1304 |
alreadyAccepted := false. |
|
1305 |
browser |
|
1306 |
closeEditorAction:[:editor | |
|
1307 |
alreadyAccepted ifFalse:[ |
|
1308 |
editor acceptAction value:(editor contents) |
|
1309 |
] |
|
1310 |
]. |
|
1311 |
||
1312 |
self allowFileOperations value ifFalse:[^ nil]. |
|
1313 |
||
1314 |
item := self fileList at:ln. |
|
1315 |
item label isString ifFalse:[ |
|
1316 |
field := nil |
|
1317 |
] ifTrue:[ |
|
1318 |
field := EditField new. |
|
1319 |
field level:0. |
|
1320 |
field acceptOnReturn:true. |
|
1321 |
field acceptOnLeave:true. |
|
1322 |
field |
|
1323 |
acceptAction:[:x | |
|
1324 |
alreadyAccepted := true. |
|
1325 |
filename := item fileName. |
|
1326 |
newFileString := x asString withoutSeparators. |
|
1327 |
filename baseName ~= newFileString ifTrue:[ |
|
1328 |
(self |
|
1329 |
renameFile:filename |
|
1330 |
to:newFileString |
|
1331 |
update:false) |
|
6768 | 1332 |
ifTrue:[ |
1333 |
newFilename := filename directory construct:newFileString. |
|
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
1334 |
"/ self withWaitCursorDo:[ |
6768 | 1335 |
self updateAndSelect:(OrderedCollection with:newFilename) |
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
1336 |
"/ ] |
6768 | 1337 |
] |
4887 | 1338 |
]. |
1339 |
aGC closeEditor. |
|
1340 |
(field leaveKey == #CursorUp or:[field leaveKey == #CursorDown]) ifTrue:[ |
|
1341 |
browser |
|
1342 |
keyPress:field leaveKey |
|
1343 |
x:0 |
|
1344 |
y:0 |
|
1345 |
]. |
|
1346 |
field destroy. |
|
1347 |
browser requestFocus "/ takes it from my windowGroup; prevents it from shifting focus |
|
1348 |
]. |
|
1349 |
field font:(aGC font). |
|
1350 |
field contents:(item label) |
|
1351 |
]. |
|
1352 |
^ field |
|
6830
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
1353 |
|
8901380baeab
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6768
diff
changeset
|
1354 |
"Modified: / 25-07-2006 / 09:08:45 / cg" |
4887 | 1355 |
! |
1356 |
||
1357 |
postBuildDirBrowser:aWidget |
|
4713 | 1358 |
browser := aWidget scrolledView. |
14301
22794ffaad9c
class: DirectoryTreeBrowser
Claus Gittinger <cg@exept.de>
parents:
14185
diff
changeset
|
1359 |
"/ browser hasConstantHeight:true. |
5063 | 1360 |
self allowRenameOnOneClick ifTrue:[ |
1361 |
browser openEditorAction:self openEditorAction |
|
1362 |
]. |
|
4887 | 1363 |
browser multipleSelectOk:self multipleSelect |
3892 | 1364 |
! |
1365 |
||
5444 | 1366 |
postOpenFromMaster:fromMaster |
4071 | 1367 |
|
4885 | 1368 |
"/ self windowGroup application class == FileBrowserV2 ifTrue:[ |
1369 |
"/ self multipleSelect:true. |
|
1370 |
"/ ]. |
|
4071 | 1371 |
self rootHolderChanged. |
5444 | 1372 |
fromMaster ifFalse:[ |
5442 | 1373 |
self currentFileNameHolderChangedForCommon. |
1374 |
]. |
|
5444 | 1375 |
self currentFileNameHolderChanged. |
4151 | 1376 |
self sortFileListsBy:self sortPropertyInTree value. |
4071 | 1377 |
self windowGroup addPreEventHook:self. |
1378 |
! |
|
1379 |
||
3892 | 1380 |
release |
1381 |
self fileList stopMonitoringTask. |
|
1382 |
^ super release. |
|
1383 |
! ! |
|
1384 |
||
1385 |
!DirectoryTreeBrowser::DirTreeBrowserHFL methodsFor:'accessing'! |
|
1386 |
||
3952 | 1387 |
draggedItem |
3892 | 1388 |
|
3952 | 1389 |
^ draggedItem |
1390 |
! |
|
3892 | 1391 |
|
3952 | 1392 |
draggedItem:anItemOrNil |
1393 |
||
1394 |
draggedItem := anItemOrNil. |
|
3892 | 1395 |
! ! |
1396 |
||
1397 |
!DirectoryTreeBrowser::DirTreeBrowserHFL methodsFor:'protocol'! |
|
1398 |
||
3969 | 1399 |
grayDirectoryIcon |
1400 |
||
1401 |
grayDirectoryIcon isNil ifTrue:[ |
|
14185
aef2b4ef5bda
Do not refer to FileBrowser methods
Stefan Vogel <sv@exept.de>
parents:
13824
diff
changeset
|
1402 |
grayDirectoryIcon := (MIMETypeIconLibrary iconForKeyMatching:#directoryOpenGray). |
3969 | 1403 |
]. |
1404 |
^ grayDirectoryIcon |
|
1405 |
! |
|
1406 |
||
1407 |
iconFor:anItem |
|
1408 |
"returns the icon for an item |
|
1409 |
" |
|
4557 | 1410 |
"/ Transcript showCR:'iconFor:anItem'. |
3892 | 1411 |
draggedItem == anItem ifTrue:[ |
3969 | 1412 |
^ self grayDirectoryIcon. |
3892 | 1413 |
]. |
3969 | 1414 |
^ super iconFor:anItem. |
3892 | 1415 |
! ! |
1416 |
||
1417 |
!DirectoryTreeBrowser class methodsFor:'documentation'! |
|
1418 |
||
1419 |
version |
|
17205 | 1420 |
^ '$Header$' |
9104
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1421 |
! |
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1422 |
|
68659d07a842
code cleanup; care for showHidden
Claus Gittinger <cg@exept.de>
parents:
8495
diff
changeset
|
1423 |
version_CVS |
17205 | 1424 |
^ '$Header$' |
3892 | 1425 |
! ! |
12101 | 1426 |