50
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
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 |
|
52
|
13 |
'From Smalltalk/X, Version:2.10.5 on 24-mar-1995 at 9:31:53 am'!
|
|
14 |
|
50
|
15 |
Model subclass:#ApplicationModel
|
52
|
16 |
instanceVariableNames:'builder resources'
|
50
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
52
|
19 |
category:'Interface-Framework'
|
50
|
20 |
!
|
|
21 |
|
52
|
22 |
ApplicationModel class instanceVariableNames:'ClassResources'!
|
|
23 |
|
50
|
24 |
!ApplicationModel class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
!
|
|
39 |
|
|
40 |
version
|
|
41 |
"
|
71
|
42 |
$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.7 1995-05-10 02:24:39 claus Exp $
|
50
|
43 |
"
|
|
44 |
!
|
|
45 |
|
|
46 |
documentation
|
|
47 |
"
|
|
48 |
Since many ST-80 classes are subclasses of ApplicationModel, this class
|
|
49 |
is provided here to allow easier porting of ST-80 code.
|
57
|
50 |
|
63
|
51 |
It does not (currently) provide much functionality and is NOT
|
|
52 |
compatible to the corresponding ST80 class; therefore, manual
|
50
|
53 |
changes have to be made to get those applications to run under ST/X.
|
57
|
54 |
(but at least, this enables you to fileIn that code and have a superclass
|
|
55 |
for them)
|
50
|
56 |
|
52
|
57 |
The classResources have been put into this class to allow ST/X
|
57
|
58 |
applications (which used to be subclasses of StandardSystemView)
|
|
59 |
to migrate smoothly into ApplicationModels (which is better design ...).
|
52
|
60 |
|
50
|
61 |
Instance variables:
|
52
|
62 |
resources ResourcePack language string translation
|
|
63 |
|
|
64 |
builder ? dont know what that is used for yet,
|
|
65 |
some subclasses (see manchester goodies)
|
57
|
66 |
depend on this being there.
|
50
|
67 |
"
|
|
68 |
! !
|
|
69 |
|
52
|
70 |
!ApplicationModel class methodsFor:'initialization'!
|
|
71 |
|
|
72 |
initialize
|
|
73 |
self == ApplicationModel ifTrue:[
|
|
74 |
Smalltalk addDependent:self
|
|
75 |
]
|
|
76 |
|
|
77 |
"
|
|
78 |
ApplicationModel initialize
|
|
79 |
"
|
|
80 |
! !
|
|
81 |
|
|
82 |
!ApplicationModel class methodsFor:'instance creation'!
|
|
83 |
|
|
84 |
new
|
63
|
85 |
^ super new basicInitialize initialize
|
52
|
86 |
! !
|
|
87 |
|
50
|
88 |
!ApplicationModel class methodsFor:'startup'!
|
|
89 |
|
|
90 |
open
|
69
|
91 |
"create an instance of the application and open its view"
|
|
92 |
|
63
|
93 |
self new open
|
|
94 |
|
|
95 |
"
|
|
96 |
self open
|
|
97 |
"
|
57
|
98 |
!
|
|
99 |
|
63
|
100 |
openOn:anApplicationModel
|
|
101 |
anApplicationModel open
|
50
|
102 |
! !
|
52
|
103 |
|
|
104 |
!ApplicationModel class methodsFor:'change & update'!
|
|
105 |
|
|
106 |
update:something
|
69
|
107 |
"flush resources on language changes"
|
|
108 |
|
52
|
109 |
something == #Language ifTrue:[
|
|
110 |
"flush resources on language changes"
|
|
111 |
self flushAllClassResources
|
|
112 |
]
|
|
113 |
! !
|
|
114 |
|
63
|
115 |
!ApplicationModel class methodsFor:'queries'!
|
|
116 |
|
|
117 |
interfaceSpecFor:aSelector
|
69
|
118 |
"return an interface spec"
|
|
119 |
|
63
|
120 |
^ self perform:aSelector
|
|
121 |
! !
|
|
122 |
|
52
|
123 |
!ApplicationModel class methodsFor:'resources'!
|
|
124 |
|
|
125 |
classResources
|
|
126 |
"if not already loaded, get the classes resourcePack
|
|
127 |
and return it"
|
|
128 |
|
|
129 |
ClassResources isNil ifTrue:[
|
|
130 |
ClassResources := ResourcePack for:self.
|
|
131 |
].
|
|
132 |
^ ClassResources
|
|
133 |
!
|
|
134 |
|
|
135 |
classResources:aResourcePack
|
|
136 |
"allow setting of the classResources"
|
|
137 |
|
|
138 |
ClassResources := aResourcePack
|
|
139 |
!
|
|
140 |
|
|
141 |
flushAllClassResources
|
|
142 |
"flush all classes resource translations.
|
|
143 |
Needed after a resource file / language setting has changed."
|
|
144 |
|
|
145 |
ResourcePack flushCachedResourcePacks.
|
|
146 |
self flushClassResources.
|
|
147 |
self allSubclassesDo:[:aClass |
|
|
148 |
aClass flushClassResources.
|
|
149 |
]
|
|
150 |
!
|
|
151 |
|
|
152 |
flushClassResources
|
|
153 |
"flush classes resource string translations.
|
|
154 |
Needed whenever a resource file / language setting has changed"
|
|
155 |
|
|
156 |
ClassResources := nil.
|
63
|
157 |
!
|
|
158 |
|
|
159 |
updateClassResources
|
|
160 |
"update my classResources"
|
|
161 |
|
|
162 |
ClassResources := nil.
|
|
163 |
self classResources
|
52
|
164 |
! !
|
|
165 |
|
|
166 |
!ApplicationModel methodsFor:'initialization'!
|
|
167 |
|
63
|
168 |
basicInitialize
|
69
|
169 |
"initialize the application.
|
|
170 |
Since ST-80 applications seem commonly to redefine initialize
|
|
171 |
without doing a super initialize, the real initialization is
|
|
172 |
done here ..."
|
|
173 |
|
52
|
174 |
super initialize.
|
63
|
175 |
"
|
|
176 |
Create a windowBuilder to have someone around which
|
|
177 |
understands the builder protocol. Since UIBuilder is not present
|
|
178 |
in all systems, this allows operation without one (unless a spec
|
|
179 |
is read later ...)
|
|
180 |
"
|
|
181 |
builder := WindowBuilder new.
|
|
182 |
builder application:self.
|
52
|
183 |
resources := self class classResources.
|
63
|
184 |
!
|
|
185 |
|
|
186 |
initialize
|
|
187 |
!
|
|
188 |
|
|
189 |
addTopViewsToCurrentProject
|
|
190 |
"add all of my topViews to the current projects list of views.
|
|
191 |
This allows hiding views on a per-project basis."
|
|
192 |
|
|
193 |
self windowGroup topViews do:[:aView |
|
|
194 |
aView addToCurrentProject
|
|
195 |
]
|
52
|
196 |
! !
|
57
|
197 |
|
71
|
198 |
!ApplicationModel methodsFor:'queries'!
|
|
199 |
|
|
200 |
processName
|
|
201 |
"return a name to be shown for me in the process monitor"
|
|
202 |
|
|
203 |
^ 'Application'
|
|
204 |
! !
|
|
205 |
|
57
|
206 |
!ApplicationModel methodsFor:'startup'!
|
|
207 |
|
63
|
208 |
allButOpenFrom:aSpec
|
69
|
209 |
"create my views but do not open the main window"
|
|
210 |
|
71
|
211 |
|realBuilder|
|
|
212 |
|
|
213 |
"
|
|
214 |
here, we kludge a bit: up to now, the builder was an
|
|
215 |
instance of the no-op WindowBuilder. Now, it becomes
|
|
216 |
a UIBuilder ....
|
|
217 |
This allows for ApplicationModels without a UIBuilder
|
|
218 |
if not needed.
|
|
219 |
"
|
|
220 |
realBuilder := UIBuilder new.
|
|
221 |
realBuilder application:self.
|
|
222 |
realBuilder bindings:builder bindings.
|
|
223 |
builder := realBuilder.
|
|
224 |
|
63
|
225 |
self preBuildWith:builder.
|
|
226 |
builder buildFromSpec:aSpec.
|
|
227 |
self postBuildWith:builder.
|
|
228 |
!
|
57
|
229 |
|
69
|
230 |
open
|
|
231 |
"open a standard interface"
|
|
232 |
|
|
233 |
self openInterface.
|
|
234 |
!
|
|
235 |
|
63
|
236 |
openInterface
|
69
|
237 |
"open a standard interface"
|
|
238 |
|
63
|
239 |
self openInterface:#windowSpec
|
57
|
240 |
!
|
|
241 |
|
63
|
242 |
openInterface:aSymbol
|
69
|
243 |
"open an interface; the argument, aSymbol specifies which.
|
|
244 |
Typically, applications only use one interface,
|
|
245 |
returned by the windowSpec method."
|
|
246 |
|
71
|
247 |
|spec|
|
63
|
248 |
|
|
249 |
spec := self class interfaceSpecFor:aSymbol.
|
71
|
250 |
self allButOpenFrom:spec.
|
63
|
251 |
|
|
252 |
builder window model:self.
|
|
253 |
builder window application:self.
|
|
254 |
builder openWithExtent:nil.
|
|
255 |
self postOpenWith:builder.
|
|
256 |
^ builder
|
|
257 |
!
|
|
258 |
|
|
259 |
closeDownViews
|
69
|
260 |
"close down the applications view"
|
63
|
261 |
|
|
262 |
|wg views|
|
|
263 |
|
|
264 |
(wg := self windowGroup) notNil ifTrue:[
|
|
265 |
views := wg topViews.
|
|
266 |
views notNil ifTrue:[
|
|
267 |
views do:[:aView |
|
|
268 |
aView destroy
|
|
269 |
]
|
|
270 |
]
|
|
271 |
]
|
|
272 |
!
|
|
273 |
|
|
274 |
close
|
69
|
275 |
"this is sent by my topView when about to be closed
|
|
276 |
(By the program - not by the windowManager)."
|
|
277 |
|
|
278 |
self closeDownViews
|
|
279 |
!
|
|
280 |
|
|
281 |
closeRequest
|
63
|
282 |
"this is sent by my topView when about to be closed by the
|
69
|
283 |
windowmanager. Can be redefined to inform & query about unsafed
|
|
284 |
view contents, to send #close on ok, or ignore the closeRequest."
|
63
|
285 |
|
|
286 |
self closeDownViews
|
|
287 |
!
|
|
288 |
|
|
289 |
opened
|
|
290 |
"this is sent by my topView when its finally open"
|
|
291 |
|
|
292 |
self addTopViewsToCurrentProject.
|
|
293 |
self postOpenWith:builder
|
57
|
294 |
!
|
|
295 |
|
69
|
296 |
restarted
|
|
297 |
"sent by my windowGroup, when restarted from an image.
|
|
298 |
Nothing done here, but can be redefined to perform any actions
|
|
299 |
required to reset the application after an image-restart.
|
|
300 |
(for example: check if application files are still around, restart
|
|
301 |
subprocesses etc.)."
|
63
|
302 |
!
|
57
|
303 |
|
63
|
304 |
saveAndTerminateRequest
|
|
305 |
"some windowManagers send this to shut down an application
|
|
306 |
and have it save its state for restart.
|
|
307 |
Can be redefined in subclasses"
|
|
308 |
|
|
309 |
self closeRequest
|
|
310 |
!
|
|
311 |
|
|
312 |
preBuildWith:aBuilder
|
69
|
313 |
"this is sent before an interface is built from a spec.
|
|
314 |
Can be redefined in subclasses.
|
|
315 |
mhmh - what should this do here ?"
|
61
|
316 |
!
|
|
317 |
|
|
318 |
postBuildWith:aBuilder
|
69
|
319 |
"this is sent after an interface is built from a spec.
|
|
320 |
Can be redefined in subclasses.
|
|
321 |
mhmh - what should this do here ?"
|
63
|
322 |
!
|
61
|
323 |
|
63
|
324 |
postOpenWith:aBuilder
|
69
|
325 |
"this is sent after the applications main window is opened.
|
|
326 |
Can be redefined in subclasses.
|
|
327 |
mhmh - what should this do here ?"
|
57
|
328 |
! !
|
|
329 |
|
|
330 |
!ApplicationModel methodsFor:'accessing'!
|
|
331 |
|
|
332 |
resources
|
69
|
333 |
"return the applications resources - thats a ResourcePack containing
|
|
334 |
language strings"
|
|
335 |
|
57
|
336 |
^ resources
|
|
337 |
!
|
|
338 |
|
63
|
339 |
windowGroup
|
69
|
340 |
"return the applications windowGroup"
|
|
341 |
|
63
|
342 |
^ builder window windowGroup
|
|
343 |
!
|
|
344 |
|
57
|
345 |
builder
|
69
|
346 |
"return the applications builder; this one has more information
|
|
347 |
about views, components etc."
|
|
348 |
|
57
|
349 |
^ builder
|
|
350 |
!
|
|
351 |
|
|
352 |
builder:aBuilder
|
69
|
353 |
"set the applications builder. Normally, you should not set it
|
|
354 |
directly, but depend on the default builder, as created when the application
|
|
355 |
was created."
|
|
356 |
|
57
|
357 |
builder := aBuilder
|
63
|
358 |
!
|
|
359 |
|
|
360 |
focusSequence
|
69
|
361 |
"return a focusSequence for stepping through the applications views.
|
|
362 |
The builder usually keeps track of so-called 'tabable' views.
|
|
363 |
Stepping is done with the FocusNext/FocusPrevius keys, which are typically bound
|
|
364 |
to Meta-CursorUp/Meta-CursorDown"
|
|
365 |
|
63
|
366 |
^ builder focusSequence
|
57
|
367 |
! !
|