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