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