author | Claus Gittinger <cg@exept.de> |
Sun, 01 Feb 1998 16:16:03 +0100 | |
changeset 542 | 11be1353d34c |
parent 515 | 1b64e990e495 |
child 585 | 19dddcff0f5f |
permissions | -rw-r--r-- |
404 | 1 |
" |
502 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
404 | 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 |
" |
|
12 |
||
13 |
||
14 |
||
15 |
SelectionBrowser subclass:#FileSelectionBrowser |
|
16 |
instanceVariableNames:'selectedFileFilter directoryView listOfFileFilters directory' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Advanced-Tools' |
|
20 |
! |
|
21 |
||
22 |
!FileSelectionBrowser class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
502 | 26 |
COPYRIGHT (c) 1997 by eXept Software AG |
404 | 27 |
All Rights Reserved |
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
documentation to be added. |
|
502 | 43 |
|
44 |
[author:] |
|
45 |
Thomas Zwick |
|
404 | 46 |
" |
47 |
! |
|
48 |
||
49 |
history |
|
50 |
"Created: / 10.1.1998 / 11:00:06 / tz" |
|
51 |
! ! |
|
52 |
||
53 |
!FileSelectionBrowser class methodsFor:'instance creation'! |
|
54 |
||
55 |
request: aTitle fileFilters: fileFilters |
|
56 |
||
57 |
"self request: 'Select A File' fileFilters: #('.*')" |
|
58 |
||
59 |
^self new |
|
60 |
title: aTitle; |
|
61 |
listOfFileFilters: fileFilters; |
|
62 |
open |
|
63 |
! |
|
64 |
||
65 |
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters |
|
66 |
||
67 |
"self |
|
68 |
request: 'Select Your Profile File' |
|
69 |
fileName: '.profile' |
|
70 |
inDirectory: Filename homeDirectory |
|
71 |
withFileFilters: #('.*')" |
|
72 |
||
73 |
^self new |
|
74 |
title: aTitle; |
|
75 |
fileName: aFileName; |
|
76 |
directory: dir; |
|
77 |
listOfFileFilters: fileFilters; |
|
78 |
open |
|
79 |
! |
|
80 |
||
462 | 81 |
request: aTitle pathName: aPath fileFilters: fileFilters |
82 |
||
83 |
"self request: 'Select A File' pathName: '' fileFilters: #('.*')" |
|
84 |
||
85 |
^self new |
|
86 |
title: aTitle; |
|
87 |
fileName: aPath; |
|
88 |
directory: aPath; |
|
89 |
listOfFileFilters: fileFilters; |
|
90 |
open |
|
91 |
! |
|
92 |
||
404 | 93 |
requestFileName |
94 |
||
95 |
"self requestFileName" |
|
96 |
||
97 |
^self new title: 'Select A File'; open |
|
98 |
||
99 |
! ! |
|
100 |
||
101 |
!FileSelectionBrowser class methodsFor:'accessing'! |
|
102 |
||
103 |
loadImageFileNameFilters |
|
104 |
^self saveImageFileNameFilters addAll: #('*.jpeg' '*.jpg'); yourself |
|
105 |
||
106 |
! |
|
107 |
||
108 |
projectFileNameFilters |
|
109 |
^Array withAll: #('*.st' '*.*o' '*.s' '*.c' 'Make*' '*.project') |
|
110 |
||
111 |
! |
|
112 |
||
113 |
saveImageFileNameFilters |
|
114 |
^Array withAll: #('*.xpm' '*.xbm' '*.gif' '*.tif' '*.tiff' '*.bmp') |
|
115 |
||
116 |
! ! |
|
117 |
||
118 |
!FileSelectionBrowser class methodsFor:'interface specs'! |
|
119 |
||
120 |
windowSpec |
|
121 |
"this window spec was automatically generated by the ST/X UIPainter" |
|
122 |
||
123 |
"do not manually edit this - the painter/builder may not be able to |
|
124 |
handle the specification if its corrupted." |
|
125 |
||
126 |
" |
|
127 |
UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec |
|
128 |
FileSelectionBrowser new openInterface:#windowSpec |
|
129 |
" |
|
130 |
"FileSelectionBrowser open" |
|
131 |
||
132 |
<resource: #canvas> |
|
133 |
||
134 |
^ |
|
135 |
||
136 |
#(#FullSpec |
|
137 |
#'window:' |
|
138 |
#(#WindowSpec |
|
139 |
#'name:' 'File Selection Browser' |
|
468 | 140 |
#'layout:' #(#LayoutFrame 207 0 351 0 606 0 650 0) |
404 | 141 |
#'label:' 'File Selection Browser' |
142 |
#'min:' #(#Point 10 10) |
|
143 |
#'max:' #(#Point 1152 900) |
|
468 | 144 |
#'bounds:' #(#Rectangle 207 351 607 651) |
404 | 145 |
#'usePreferredExtent:' false |
146 |
) |
|
147 |
#'component:' |
|
148 |
#(#SpecCollection |
|
149 |
#'collection:' |
|
150 |
#( |
|
151 |
#(#VariableHorizontalPanelSpec |
|
152 |
#'name:' 'panel' |
|
153 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0) |
|
154 |
#'component:' |
|
155 |
#(#SpecCollection |
|
156 |
#'collection:' |
|
157 |
#( |
|
158 |
#(#ViewSpec |
|
159 |
#'name:' 'view1' |
|
160 |
#'component:' |
|
161 |
#(#SpecCollection |
|
162 |
#'collection:' |
|
163 |
#( |
|
164 |
#(#FileSelectionTreeSpec |
|
165 |
#'name:' 'directoryTreeView' |
|
166 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
167 |
#'model:' #selectionOfDirectory |
|
168 |
#'hasHorizontalScrollBar:' true |
|
169 |
#'hasVerticalScrollBar:' true |
|
170 |
#'miniScrollerHorizontal:' true |
|
171 |
#'showRoot:' false |
|
172 |
#'showDirectoryIndicator:' true |
|
173 |
#'valueChangeSelector:' #readDirectory |
|
174 |
#'hierarchicalList:' #rootOfDirectory |
|
175 |
#'itemClass:' 'Directory' |
|
176 |
) |
|
177 |
) |
|
178 |
) |
|
179 |
) |
|
180 |
#(#ViewSpec |
|
181 |
#'name:' 'view2' |
|
182 |
#'component:' |
|
183 |
#(#SpecCollection |
|
184 |
#'collection:' |
|
185 |
#( |
|
186 |
#(#InputFieldSpec |
|
187 |
#'name:' 'EditField' |
|
188 |
#'layout:' #(#LayoutFrame 1 0.0 -22 1 0 1.0 0 1) |
|
189 |
#'model:' #valueOfFileName |
|
190 |
#'acceptOnReturn:' false |
|
191 |
#'acceptOnTab:' false |
|
192 |
) |
|
193 |
#(#SubCanvasSpec |
|
194 |
#'name:' 'subCanvas1' |
|
195 |
#'layout:' #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -22 1.0) |
|
196 |
#'clientHolder:' #directoryView |
|
197 |
) |
|
198 |
) |
|
199 |
) |
|
200 |
) |
|
201 |
) |
|
202 |
) |
|
203 |
#'handles:' #(#Any 0.5 1.0) |
|
204 |
) |
|
426
b8110a424326
commit buttons replaced by subSpec in ToolApplicationModel
tz
parents:
404
diff
changeset
|
205 |
#(#UISubSpecification |
b8110a424326
commit buttons replaced by subSpec in ToolApplicationModel
tz
parents:
404
diff
changeset
|
206 |
#'name:' 'SubSpecification' |
b8110a424326
commit buttons replaced by subSpec in ToolApplicationModel
tz
parents:
404
diff
changeset
|
207 |
#'layout:' #(#LayoutFrame 2 0.0 -32 1 -2 1.0 -8 1.0) |
b8110a424326
commit buttons replaced by subSpec in ToolApplicationModel
tz
parents:
404
diff
changeset
|
208 |
#'majorKey:' #ToolApplicationModel |
452 | 209 |
#'minorKey:' #windowSpecForCommitWithoutChannels |
404 | 210 |
) |
211 |
) |
|
212 |
) |
|
213 |
) |
|
214 |
! ! |
|
215 |
||
216 |
!FileSelectionBrowser methodsFor:'accessing'! |
|
217 |
||
218 |
directory: aDirectory |
|
219 |
||
462 | 220 |
directory := (aDirectory ? Filename homeDirectory) asFilename asAbsoluteFilename name |
404 | 221 |
! |
222 |
||
223 |
directoryView |
|
224 |
||
225 |
^directoryView ? (directoryView := DirectoryView new) |
|
226 |
! |
|
227 |
||
228 |
fileName: aFileName |
|
229 |
||
230 |
self valueOfFileName value: (aFileName ? '') asFilename baseName. |
|
231 |
directory := directory ? ((aFileName ? '') asFilename directoryName). |
|
232 |
||
233 |
! |
|
234 |
||
235 |
listOfFileFilters: anArray |
|
236 |
||
237 |
listOfFileFilters := anArray |
|
238 |
! ! |
|
239 |
||
240 |
!FileSelectionBrowser methodsFor:'accessing - views'! |
|
241 |
||
242 |
directoryTreeView |
|
243 |
||
244 |
^builder componentAt: #directoryTreeView |
|
245 |
||
246 |
! ! |
|
247 |
||
248 |
!FileSelectionBrowser methodsFor:'aspects'! |
|
249 |
||
250 |
rootOfDirectory |
|
251 |
||
252 |
|holder| |
|
253 |
(holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[ |
|
254 |
builder aspectAt:#rootOfDirectory put: (holder := Filename rootDirectory name asValue). |
|
255 |
]. |
|
256 |
^ holder |
|
257 |
||
258 |
! |
|
259 |
||
260 |
selectionOfDirectory |
|
261 |
||
262 |
|holder| |
|
263 |
(holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[ |
|
264 |
builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new) |
|
265 |
]. |
|
266 |
^ holder |
|
267 |
||
268 |
! |
|
269 |
||
270 |
valueOfFileName |
|
271 |
||
272 |
|holder| |
|
273 |
(holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[ |
|
274 |
builder aspectAt:#valueOfFileName put:(holder := ValueHolder new). |
|
275 |
]. |
|
276 |
^ holder |
|
277 |
! ! |
|
278 |
||
279 |
!FileSelectionBrowser methodsFor:'callbacks'! |
|
280 |
||
281 |
fileDoubleClicked: aFileName |
|
282 |
||
283 |
self valueOfFileName value: aFileName. |
|
284 |
accept value: true. |
|
285 |
self close |
|
286 |
! |
|
287 |
||
288 |
readDirectory |
|
289 |
"Diesen Mist musste ich machen, weil ztk es nicht fertig bringt, |
|
290 |
seine Models upzudaten, bevor er die Callbacks aufruft!!!!!!" |
|
291 |
||
292 |
|dir| |
|
293 |
directoryView listOfFiles removeAll. |
|
294 |
directoryView directory: |
|
295 |
(dir := (self directoryTreeView model list at: |
|
296 |
self directoryTreeView model selection) contents name); |
|
297 |
readDirectory. |
|
298 |
directory isNil ifTrue: [self class lastSelection: dir] |
|
299 |
! ! |
|
300 |
||
301 |
!FileSelectionBrowser methodsFor:'startup / release'! |
|
302 |
||
303 |
closeCancel |
|
304 |
||
305 |
directoryView release. |
|
306 |
super closeCancel |
|
307 |
! |
|
308 |
||
309 |
closeRequest |
|
310 |
||
311 |
directoryView release. |
|
312 |
super closeRequest |
|
313 |
||
314 |
! |
|
315 |
||
316 |
open |
|
317 |
||
318 |
super open. |
|
515 | 319 |
accept value ifTrue:[ |
320 |
^ (self selectionOfDirectory value ? '') asFilename |
|
321 |
constructString:(self valueOfFileName value ? '') |
|
404 | 322 |
]. |
515 | 323 |
^ nil |
404 | 324 |
|
515 | 325 |
"Modified: / 28.1.1998 / 15:21:40 / stefan" |
404 | 326 |
! |
327 |
||
328 |
postBuildWith:aBuilder |
|
329 |
||
330 |
directoryView listOfFileFilters: listOfFileFilters ? #('*'). |
|
462 | 331 |
directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName]. |
332 |
directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName]. |
|
404 | 333 |
directoryView fileFilterSelectAction: [:fileFilter| |
334 |
self valueOfFileName value: ( |
|
335 |
((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.', |
|
336 |
(fileFilter copy reverse readStream upTo: $.) reverse)]. |
|
337 |
self directoryTreeView selectPathname: directory ? self class lastSelection. |
|
338 |
||
339 |
^super postBuildWith:aBuilder |
|
340 |
! ! |
|
341 |
||
342 |
!FileSelectionBrowser class methodsFor:'documentation'! |
|
343 |
||
344 |
version |
|
345 |
^ '$Header$' |
|
346 |
! ! |