ApplicationModel.st
changeset 2380 26b812badb1e
parent 2373 e5084459299c
child 2382 9c27d7006631
--- a/ApplicationModel.st	Mon Feb 04 10:33:03 2008 +0100
+++ b/ApplicationModel.st	Mon Feb 04 13:24:35 2008 +0100
@@ -1278,6 +1278,144 @@
     "Modified: / 4.2.2000 / 15:30:16 / cg"
 ! !
 
+!ApplicationModel methodsFor:'building'!
+
+allButOpen
+    "create my views from the windowSpec, but do not open the main window."
+
+    ^ self allButOpenInterface:(self defaultWindowSpecName).
+
+    "Modified: / 19.6.1998 / 01:48:26 / cg"
+!
+
+allButOpenFrom:aSpec
+    "create my views but do not open the main window.
+     The argument is a spec which defines the interface."
+
+    |window|
+
+"/ DISABLED; see comment in basicInitialize
+"/
+"/    "
+"/     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.
+"/    builder := realBuilder.
+"/    builder application:self.
+"/    builder bindings:builder bindings.
+
+    builder isNil ifTrue:[
+        self createBuilder.
+    ].
+
+    self preBuildWith:builder.
+    builder buildWindowFromSpec:aSpec.
+    window := builder window.
+
+    window model:self.
+    (window respondsTo:#application:) ifTrue:[
+        window application:self.
+    ].
+
+    self showingHelp ifTrue: [ActiveHelp startFor: self].
+    self postBuildWith:builder.
+
+    "Modified: / 19.6.1998 / 03:35:31 / cg"
+!
+
+allButOpenInterface:aSymbol
+    "create my views but do not open the main window.
+     The argument specifies a selector of a method,
+     which when sent to myself should return a spec.
+     Notice, this returns the windowBuilder."
+
+    self allButOpenFrom:(self interfaceSpecFor:aSymbol).
+    ^ builder
+
+    "Modified: / 19.6.1998 / 01:48:26 / cg"
+!
+
+buildSpec:specToBuild asSubCanvasWithBuilder:aBuilder
+    "build a subcanvases spec into aSubcanvas"
+
+    |sameApp prevSpec prevSource|
+
+    aBuilder notNil ifTrue:[
+        prevSpec := aBuilder spec.
+        prevSource := aBuilder source.
+    ].
+
+    builder isNil ifTrue:[
+        builder := aBuilder.
+        aBuilder isNil ifTrue:[
+            self createBuilder
+        ]
+    ].
+
+    aBuilder source:self.
+
+    "/ if the subcanvases appModel is NOT the same as
+    "/ the topApp, it must be pre/post-built.
+    "/ Otherwise, we invoke pre/post-builtAsSubcanvas.
+    "/ which provides a hook for redefinition in concrete appModels.
+    "/ This avoids invoking pre/postBuild twice for subCanvases which
+    "/ have the topApp as appModel.
+
+    sameApp := aBuilder application == aBuilder window topView application.
+    sameApp ifTrue:[
+        self preBuildAsSubcanvasWith:aBuilder.
+    ] ifFalse:[
+        self preBuildWith:aBuilder.
+    ].
+
+    aBuilder buildFromSpec:specToBuild.
+
+    sameApp ifTrue:[
+        self postBuildAsSubcanvasWith:aBuilder.
+    ] ifFalse:[
+        self postBuildWith:aBuilder.
+    ].
+
+    prevSpec notNil ifTrue:[
+        "/ restore state in builder if original builder was used
+        aBuilder spec:prevSpec.
+    ].
+    prevSource notNil ifTrue:[
+        "/ restore state in builder if original builder was used
+        aBuilder source:prevSource.
+    ].
+
+    ^ aBuilder
+
+    "Created: / 18-06-1998 / 20:08:45 / cg"
+    "Modified: / 27-10-2006 / 11:45:25 / cg"
+!
+
+buildSubCanvas:spec withBuilder:aBuilder
+    "build a subcanvases' spec into aSubcanvas"
+
+    self buildSubCanvas:spec withMenu:false withBuilder:aBuilder
+!
+
+buildSubCanvas:spec withMenu:withMenuBoolean withBuilder:aBuilder
+    "build a subcanvases' spec into aSubcanvas"
+
+    |specToBuild|
+
+    specToBuild := spec.
+    withMenuBoolean ifFalse:[
+        "/ subapps should not build the menu and other fullSpec stuff.
+        spec class == FullSpec ifTrue:[
+            specToBuild := spec component.
+        ]
+    ].
+    self buildSpec:specToBuild asSubCanvasWithBuilder:aBuilder
+! !
+
 !ApplicationModel methodsFor:'change & update'!
 
 delayedUpdate:something with:aParameter from:changedObject
@@ -1990,142 +2128,6 @@
 
 !ApplicationModel methodsFor:'opening'!
 
-allButOpen
-    "create my views from the windowSpec, but do not open the main window."
-
-    ^ self allButOpenInterface:(self defaultWindowSpecName).
-
-    "Modified: / 19.6.1998 / 01:48:26 / cg"
-!
-
-allButOpenFrom:aSpec
-    "create my views but do not open the main window.
-     The argument is a spec which defines the interface."
-
-    |window|
-
-"/ DISABLED; see comment in basicInitialize
-"/
-"/    "
-"/     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.
-"/    builder := realBuilder.
-"/    builder application:self.
-"/    builder bindings:builder bindings.
-
-    builder isNil ifTrue:[
-        self createBuilder.
-    ].
-
-    self preBuildWith:builder.
-    builder buildWindowFromSpec:aSpec.
-    window := builder window.
-
-    window model:self.
-    (window respondsTo:#application:) ifTrue:[
-        window application:self.
-    ].
-
-    self showingHelp ifTrue: [ActiveHelp startFor: self].
-    self postBuildWith:builder.
-
-    "Modified: / 19.6.1998 / 03:35:31 / cg"
-!
-
-allButOpenInterface:aSymbol
-    "create my views but do not open the main window.
-     The argument specifies a selector of a method,
-     which when sent to myself should return a spec.
-     Notice, this returns the windowBuilder."
-
-    self allButOpenFrom:(self interfaceSpecFor:aSymbol).
-    ^ builder
-
-    "Modified: / 19.6.1998 / 01:48:26 / cg"
-!
-
-buildSpec:specToBuild asSubCanvasWithBuilder:aBuilder
-    "build a subcanvases spec into aSubcanvas"
-
-    |sameApp prevSpec prevSource|
-
-    aBuilder notNil ifTrue:[
-        prevSpec := aBuilder spec.
-        prevSource := aBuilder source.
-    ].
-
-    builder isNil ifTrue:[
-        builder := aBuilder.
-        aBuilder isNil ifTrue:[
-            self createBuilder
-        ]
-    ].
-
-    aBuilder source:self.
-
-    "/ if the subcanvases appModel is NOT the same as
-    "/ the topApp, it must be pre/post-built.
-    "/ Otherwise, we invoke pre/post-builtAsSubcanvas.
-    "/ which provides a hook for redefinition in concrete appModels.
-    "/ This avoids invoking pre/postBuild twice for subCanvases which
-    "/ have the topApp as appModel.
-
-    sameApp := aBuilder application == aBuilder window topView application.
-    sameApp ifTrue:[
-        self preBuildAsSubcanvasWith:aBuilder.
-    ] ifFalse:[
-        self preBuildWith:aBuilder.
-    ].
-
-    aBuilder buildFromSpec:specToBuild.
-
-    sameApp ifTrue:[
-        self postBuildAsSubcanvasWith:aBuilder.
-    ] ifFalse:[
-        self postBuildWith:aBuilder.
-    ].
-
-    prevSpec notNil ifTrue:[
-        "/ restore state in builder if original builder was used
-        aBuilder spec:prevSpec.
-    ].
-    prevSource notNil ifTrue:[
-        "/ restore state in builder if original builder was used
-        aBuilder source:prevSource.
-    ].
-
-    ^ aBuilder
-
-    "Created: / 18-06-1998 / 20:08:45 / cg"
-    "Modified: / 27-10-2006 / 11:45:25 / cg"
-!
-
-buildSubCanvas:spec withBuilder:aBuilder
-    "build a subcanvases' spec into aSubcanvas"
-
-    self buildSubCanvas:spec withMenu:false withBuilder:aBuilder
-!
-
-buildSubCanvas:spec withMenu:withMenuBoolean withBuilder:aBuilder
-    "build a subcanvases' spec into aSubcanvas"
-
-    |specToBuild|
-
-    specToBuild := spec.
-    withMenuBoolean ifFalse:[
-        "/ subapps should not build the menu and other fullSpec stuff.
-        spec class == FullSpec ifTrue:[
-            specToBuild := spec component.
-        ]
-    ].
-    self buildSpec:specToBuild asSubCanvasWithBuilder:aBuilder
-!
-
 open
     "open a standard interface"
 
@@ -2473,6 +2475,42 @@
     self postOpenWith:builder
 ! !
 
+!ApplicationModel methodsFor:'opening-webInterface'!
+
+defineInterface
+    "define a standard interface.
+
+     Subclasses which do not have an interfaceSpec 
+     should redefine this method and create their page there."
+
+    ^ self defineInterface:(self defaultPageSpecName)
+!
+
+defineInterface:aSpecSymbol
+    "define an interface."
+
+    ^ self defineInterfaceFrom:(self interfaceSpecFor:aSpecSymbol)
+!
+
+defineInterfaceFrom:aSpec
+    "define an interface (setup a page), given a spec."
+
+    |page|
+
+    builder isNil ifTrue:[
+        self createWebBuilder.
+    ].
+
+    self preBuildWith:builder.
+    builder buildPageFromSpec:aSpec.
+    page := builder page.
+    page application:self.
+
+    self postBuildWith:builder.
+
+    "Modified: / 19.6.1998 / 03:35:31 / cg"
+! !
+
 !ApplicationModel methodsFor:'private'!
 
 builderClass
@@ -2497,10 +2535,26 @@
     "Created: / 19.6.1998 / 03:32:37 / cg"
 !
 
-selfResponsibleFor:aKey
-    "internal: return true, if I am to provide a value for some aspect."
-
-    ^ (aKey isNil or:[masterApplication isNil or:[self respondsTo:aKey]])
+createWebBuilder
+    "create a Web-UIBuilder if not already present"
+
+    builder isNil ifTrue:[
+        builder := self webBuilderClass new.
+        builder application:self.
+    ]
+
+    "Created: / 19.6.1998 / 03:32:37 / cg"
+!
+
+webBuilderClass
+    "return the UIBuilder class for me.
+     This method can be redefined if (eventually) there are
+     spec readers for other UI languages (motif UIL ?)"
+
+    ^ WebPageBuilder
+
+    "Created: / 19.6.1998 / 01:39:26 / cg"
+    "Modified: / 19.6.1998 / 01:45:24 / cg"
 ! !
 
 !ApplicationModel methodsFor:'queries'!
@@ -2596,6 +2650,12 @@
     ^ nil
 !
 
+selfResponsibleFor:aKey
+    "internal: return true, if I am to provide a value for some aspect."
+
+    ^ (aKey isNil or:[masterApplication isNil or:[self respondsTo:aKey]])
+!
+
 topApplication
     "return the top-master application"
 
@@ -2970,7 +3030,7 @@
 !ApplicationModel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.241 2008-01-17 10:01:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.242 2008-02-04 12:24:35 cg Exp $'
 ! !
 
 ApplicationModel initialize!