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