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