AbstractSettingsApplication.st
changeset 4893 39dec723f6ad
parent 4886 4fcb51786045
child 4899 1bde09704293
--- a/AbstractSettingsApplication.st	Wed May 14 18:37:23 2003 +0200
+++ b/AbstractSettingsApplication.st	Wed May 14 19:43:33 2003 +0200
@@ -3016,7 +3016,7 @@
 !AbstractSettingsApplication::HTTPStartServerSettingsApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.63 2003-05-13 16:49:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.64 2003-05-14 17:43:26 penk Exp $'
 ! !
 
 !AbstractSettingsApplication::HTTPStartServerSettingsApplication class methodsFor:'image specs'!
@@ -3205,18 +3205,11 @@
         newServer := HTTPServer new.
         newServer port:port.
 "/        newServer setupDefaults.
-        self createServerApplication:newServer forDefault:false.
+        self createServerApplicationFor:newServer.
     ]
 !
 
-createServerApplication:aServerInstance
-
-    self createServerApplication:aServerInstance forDefault:false.
-!
-
-createServerApplication:aServerInstance forDefault:isDefaultApplication
-
-
+createServerApplicationFor:aServerInstance
     |settingsApp settingsAppPosition newItem openApps|
 
     openApps := self requestor getAllChildrenAppsForApplication:self childrenClass:HTTPServerSettingsAppl.
@@ -3226,18 +3219,10 @@
     ].
     settingsApp := HTTPServerSettingsAppl basicNew.
     settingsApp requestor:self requestor.
-    isDefaultApplication ifTrue:[
-        settingsApp isDefaultSettingsDialog:isDefaultApplication
-    ] ifFalse:[
-        settingsApp httpServerInstance:aServerInstance.
-    ].
+    settingsApp httpServerInstance:aServerInstance.
     settingsApp basicInitialize.
     settingsAppPosition := requestor getNameOfApplication:self.
-    isDefaultApplication ifTrue:[
-        settingsAppPosition := settingsAppPosition , '/HTTPServer Default Settings'.
-    ] ifFalse:[
-        settingsAppPosition := settingsAppPosition , '/HTTPServer Port ', aServerInstance port asString.
-    ].
+    settingsAppPosition := settingsAppPosition , '/HTTPServer Port ', aServerInstance port asString.
     newItem := requestor addApplClass:#'HTTPServerSettingsAppl' withName:settingsAppPosition.
     newItem application:settingsApp.
     self createdServerChanged.
@@ -3249,14 +3234,13 @@
 
     |runningServers|
 
-    self createServerApplication:nil forDefault:true.
     HTTPServer isLoaded ifFalse:[ ^ self].
 
     runningServers := HTTPServer runningServers asOrderedCollection.
     runningServers isEmpty ifTrue:[ ^ self].
     runningServers sort:[:a :b | a port < b port].
     runningServers do:[:aHttpServerInstance |
-        self createServerApplication:aHttpServerInstance forDefault:false.
+        self createServerApplicationFor:aHttpServerInstance.
     ]
 !
 
@@ -3271,15 +3255,7 @@
 !
 
 removeAllServerSubApplications
-
-    |apps|
-
-    apps := requestor getApplicationsByClass:HTTPServerSettingsAppl.
-    apps do:[:aApp |
-        aApp isDefaultSettingsDialog ifFalse:[
-            requestor removeByApplication:aApp.
-        ]
-    ].
+    requestor removeAllApplicationsByClass:HTTPServerSettingsAppl
 !
 
 removeAllServers
@@ -3292,24 +3268,18 @@
 
 setPortOnFreePort
 
-    | createdServer |
-    createdServer := (self requestor getAllChildrenAppsForApplication:self childrenClass:HTTPServerSettingsAppl) collect:[:setApp |
-        setApp httpServerInstance.
-    ].
-    createdServer size = 1 ifTrue:[
-        HTTPServer isLoaded ifFalse:[
-            self portNumberChannel value:8080.
-        ] ifTrue:[
-            self portNumberChannel value:(HTTPServer defaultPort).
-        ].
-        ^ self
-    ].
-    self portNumberChannel value:0.
-    createdServer do:[:aHttpServer |
-        (aHttpServer notNil and:[aHttpServer port >= (self portNumberChannel value asInteger)]) ifTrue:[
-            self portNumberChannel value:(aHttpServer port + 1).
-        ].
-    ]
+    | highestUsedPortNr portToUse |
+
+    HTTPServer isLoaded ifFalse:[
+        portToUse := 8080
+    ] ifTrue:[
+        highestUsedPortNr := HTTPServer allInstances 
+                                inject:(HTTPServer defaultPort - 1) 
+                                into:[:maxSoFar :thisServer | thisServer port max:maxSoFar].
+
+        portToUse := highestUsedPortNr + 1
+    ].
+    self portNumberChannel value:portToUse.
 ! !
 
 !AbstractSettingsApplication::HTTPStartServerSettingsApplication methodsFor:'aspects'!
@@ -3389,7 +3359,7 @@
 
 hasCreatedServer
 
-    ^ ((self requestor getAllChildrenAppsForApplication:self childrenClass:HTTPServerSettingsAppl) size > 1)
+    ^ (self requestor getAllChildrenAppsForApplication:self childrenClass:HTTPServerSettingsAppl) notEmpty
 !
 
 hasUnsavedChanges
@@ -10889,5 +10859,5 @@
 !AbstractSettingsApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.63 2003-05-13 16:49:42 cg Exp $'
-! !
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.64 2003-05-14 17:43:26 penk Exp $'
+! !