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