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