.
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
'From Smalltalk/X, Version:2.10.5 on 24-mar-1995 at 9:31:53 am'!
Model subclass:#ApplicationModel
instanceVariableNames:'builder resources'
classVariableNames:''
poolDictionaries:''
category:'Interface-Framework'
!
ApplicationModel class instanceVariableNames:'ClassResources'!
!ApplicationModel class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
version
"
$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.6 1995-05-09 00:20:49 claus Exp $
"
!
documentation
"
Since many ST-80 classes are subclasses of ApplicationModel, this class
is provided here to allow easier porting of ST-80 code.
It does not (currently) provide much functionality and is NOT
compatible to the corresponding ST80 class; therefore, manual
changes have to be made to get those applications to run under ST/X.
(but at least, this enables you to fileIn that code and have a superclass
for them)
The classResources have been put into this class to allow ST/X
applications (which used to be subclasses of StandardSystemView)
to migrate smoothly into ApplicationModels (which is better design ...).
Instance variables:
resources ResourcePack language string translation
builder ? dont know what that is used for yet,
some subclasses (see manchester goodies)
depend on this being there.
"
! !
!ApplicationModel class methodsFor:'initialization'!
initialize
self == ApplicationModel ifTrue:[
Smalltalk addDependent:self
]
"
ApplicationModel initialize
"
! !
!ApplicationModel class methodsFor:'instance creation'!
new
^ super new basicInitialize initialize
! !
!ApplicationModel class methodsFor:'startup'!
open
"create an instance of the application and open its view"
self new open
"
self open
"
!
openOn:anApplicationModel
anApplicationModel open
! !
!ApplicationModel class methodsFor:'change & update'!
update:something
"flush resources on language changes"
something == #Language ifTrue:[
"flush resources on language changes"
self flushAllClassResources
]
! !
!ApplicationModel class methodsFor:'queries'!
interfaceSpecFor:aSelector
"return an interface spec"
^ self perform:aSelector
! !
!ApplicationModel class methodsFor:'resources'!
classResources
"if not already loaded, get the classes resourcePack
and return it"
ClassResources isNil ifTrue:[
ClassResources := ResourcePack for:self.
].
^ ClassResources
!
classResources:aResourcePack
"allow setting of the classResources"
ClassResources := aResourcePack
!
flushAllClassResources
"flush all classes resource translations.
Needed after a resource file / language setting has changed."
ResourcePack flushCachedResourcePacks.
self flushClassResources.
self allSubclassesDo:[:aClass |
aClass flushClassResources.
]
!
flushClassResources
"flush classes resource string translations.
Needed whenever a resource file / language setting has changed"
ClassResources := nil.
!
updateClassResources
"update my classResources"
ClassResources := nil.
self classResources
! !
!ApplicationModel methodsFor:'initialization'!
basicInitialize
"initialize the application.
Since ST-80 applications seem commonly to redefine initialize
without doing a super initialize, the real initialization is
done here ..."
super initialize.
"
Create a windowBuilder to have someone around which
understands the builder protocol. Since UIBuilder is not present
in all systems, this allows operation without one (unless a spec
is read later ...)
"
builder := WindowBuilder new.
builder application:self.
resources := self class classResources.
!
initialize
!
addTopViewsToCurrentProject
"add all of my topViews to the current projects list of views.
This allows hiding views on a per-project basis."
self windowGroup topViews do:[:aView |
aView addToCurrentProject
]
! !
!ApplicationModel methodsFor:'startup'!
allButOpenFrom:aSpec
"create my views but do not open the main window"
self preBuildWith:builder.
builder buildFromSpec:aSpec.
self postBuildWith:builder.
!
open
"open a standard interface"
self openInterface.
!
openInterface
"open a standard interface"
self openInterface:#windowSpec
!
openInterface:aSymbol
"open an interface; the argument, aSymbol specifies which.
Typically, applications only use one interface,
returned by the windowSpec method."
|spec realBuilder|
spec := self class interfaceSpecFor:aSymbol.
"
here, we kludge a bit: up to now, the builder was an
instance of the no-op WindowBuilder. Now, it becomes
a UIBuilder ....
This allows for ApplicationModels without a UIBuilder
if not needed.
"
realBuilder := UIBuilder new.
realBuilder application:self.
realBuilder bindings:builder bindings.
builder := realBuilder.
self allButOpenFrom:spec.
builder window model:self.
builder window application:self.
builder openWithExtent:nil.
self postOpenWith:builder.
^ builder
!
closeDownViews
"close down the applications view"
|wg views|
(wg := self windowGroup) notNil ifTrue:[
views := wg topViews.
views notNil ifTrue:[
views do:[:aView |
aView destroy
]
]
]
!
close
"this is sent by my topView when about to be closed
(By the program - not by the windowManager)."
self closeDownViews
!
closeRequest
"this is sent by my topView when about to be closed by the
windowmanager. Can be redefined to inform & query about unsafed
view contents, to send #close on ok, or ignore the closeRequest."
self closeDownViews
!
opened
"this is sent by my topView when its finally open"
self addTopViewsToCurrentProject.
self postOpenWith:builder
!
restarted
"sent by my windowGroup, when restarted from an image.
Nothing done here, but can be redefined to perform any actions
required to reset the application after an image-restart.
(for example: check if application files are still around, restart
subprocesses etc.)."
!
saveAndTerminateRequest
"some windowManagers send this to shut down an application
and have it save its state for restart.
Can be redefined in subclasses"
self closeRequest
!
preBuildWith:aBuilder
"this is sent before an interface is built from a spec.
Can be redefined in subclasses.
mhmh - what should this do here ?"
!
postBuildWith:aBuilder
"this is sent after an interface is built from a spec.
Can be redefined in subclasses.
mhmh - what should this do here ?"
!
postOpenWith:aBuilder
"this is sent after the applications main window is opened.
Can be redefined in subclasses.
mhmh - what should this do here ?"
! !
!ApplicationModel methodsFor:'accessing'!
resources
"return the applications resources - thats a ResourcePack containing
language strings"
^ resources
!
windowGroup
"return the applications windowGroup"
^ builder window windowGroup
!
builder
"return the applications builder; this one has more information
about views, components etc."
^ builder
!
builder:aBuilder
"set the applications builder. Normally, you should not set it
directly, but depend on the default builder, as created when the application
was created."
builder := aBuilder
!
focusSequence
"return a focusSequence for stepping through the applications views.
The builder usually keeps track of so-called 'tabable' views.
Stepping is done with the FocusNext/FocusPrevius keys, which are typically bound
to Meta-CursorUp/Meta-CursorDown"
^ builder focusSequence
! !