SettingsDialog.st
changeset 4378 7021197a578f
child 4384 e16e816f6680
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SettingsDialog.st	Fri Dec 13 17:27:35 2002 +0100
@@ -0,0 +1,1074 @@
+"{ Package: 'stx:libtool' }"
+
+ApplicationModel subclass:#SettingsDialog
+	instanceVariableNames:'requestor subCanvasApplicationHolder help doReload doSave
+		enableReload enableHelp enableOK selectedItem applicationList
+		categoryIcons'
+	classVariableNames:'ApplicationList IconList'
+	poolDictionaries:''
+	category:'Interface-Smalltalk'
+!
+
+HierarchicalList subclass:#HierarchicalApplicationList
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:SettingsDialog
+!
+
+HierarchicalItem subclass:#ApplicationItem
+	instanceVariableNames:'application applicationClass icon label nameString'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:SettingsDialog::HierarchicalApplicationList
+!
+
+!SettingsDialog class methodsFor:'documentation'!
+
+documentation
+
+"
+    This is an application which can displays a list of Settings applications inherited by AbstractSettingsApplication
+    You have to add the SettingsApplications with:
+    
+    [author:]
+        Christian Penk, eXept Software AG
+"
+! !
+
+!SettingsDialog class methodsFor:'accessing'!
+
+itemClass
+
+    ^ SettingsDialog::HierarchicalApplicationList::ApplicationItem
+! !
+
+!SettingsDialog class methodsFor:'application icons'!
+
+defaultSettingsAppIcon
+
+    ^ self settingsIcon
+!
+
+settingsIcon
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self settingsIcon inspect
+     ImageEditor openOnClass:self andSelector:#settingsIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:#'AbstractLauncherApplication::SettingsDialog class settingsIcon'
+        ifAbsentPut:[(Depth8Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(8 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
+@@BP#8>O#8>M  @@@@@@@@@@@@@@@@BJ%9&Y&Y&Y%R^B@@@@@@@@@@@@@@BI&J^(*J"(*JZTIIFQ$YFQ$YH@@@@@ JN#(:N#(:N#(9.V%)ZV%)ZKZP@@@HOU
+4=OS4=OL3,''I0<B;/]F3*TE?@@BC5MKR4-KM,\^:.MJ:-;21/:1D_@@@ =SR4-KM3<+K/<J01,R20+R+QG0@@HOT4-KR/,^?-\[H1(Q^WW"1*4Q<@@BC5MKR
+,-CO1<>/+(X*F1(S,Z1D_@@@ =SR4-J:2,[J0X  TU!!BE+F$GS!!=@HOT,+WK.\J/28\&TV=EKAV1RELG  BC5L7H0-KB/HT TV-CKA8>TG@=_H8M ;[H1+::
+-;8\TWECKBD9)T=0]R40AXOE2;F5-;:/G6)EKBD?ZF5KV#ITJ0M>''*B_''ZF]''5,(KA8)X8ENU#XR@ )L^1$YFQ$YFQ$WBA PE@QMVSDON82S@@@@@@@@@@@@
+@@A_@F)IU#DQMWH@@@@@@@@@@@@@@@@@@F1JWC\LMJI''^ @@@@@@@@@@@@@@@F9GU28ROGI%+VY4@@@@@@@@@@@@@GIFXC(IL9(@^VR*X''\@@@@@@@@@@@AU
+IPXKP@@@@@A3XZ4#@@@@@@@@@@@@# 8AK90@@@@@@GX"T @a') ; colorMapFromArray:#[0 0 0 0 60 60 0 84 84 4 45 45 21 20 15 38 38 38 38 192 192 43 43 43 45 45 45 45 151 151 46 99 99 46 147 147 46 151 151 47 47 47 47 88 88 47 151 151 48 48 48 48 144 144 48 145 145 56 53 38 57 57 49 59 52 40 62 56 43 65 65 53 65 65 65 67 67 54 68 68 68 70 70 70 72 64 47 72 72 35 72 72 72 73 69 48 73 73 73 74 74 74 80 44 10 80 62 43 81 81 24 84 132 132 85 85 76 86 86 36 86 86 86 87 87 49 87 87 77 87 193 193 88 88 88 91 101 101 92 193 193 94 117 117 97 97 97 97 193 193 98 195 195 99 120 120 101 75 31 101 107 89 101 193 193 102 193 193 103 103 103 104 86 69 106 193 193 107 120 120 107 121 121 109 109 109 110 96 70 111 78 42 111 119 119 113 113 60 113 113 113 115 115 115 116 116 56 116 116 116 116 145 145 118 147 147 119 121 85 121 150 150 122 151 151 122 152 148 124 124 124 124 146 139 124 151 149 127 118 78 127 119 78 128 128 128 129 120 112 133 157 157 135 216 216 137 137 137 139 207 207 140 206 206 141 141 141 141 201 201 141 202 202 142 136 75 142 201 201 143 128 88 143 143 88 144 144 144 144 204 204 145 85 24 146 126 100 147 82 13 148 83 17 148 86 24 148 123 91 148 127 98 149 122 89 150 150 150 151 151 151 152 152 152 152 155 155 153 129 100 154 154 154 156 156 156 156 199 199 157 157 157 158 158 158 159 159 159 160 160 160 162 179 179 163 161 159 163 163 162 164 151 101 164 160 156 164 163 161 165 165 150 165 165 165 168 168 168 169 169 62 171 171 171 172 172 71 174 117 58 177 177 177 178 178 89 185 174 113 186 178 115 186 186 115 189 179 116 189 189 115 189 189 132 190 190 139 192 192 142 192 192 192 193 193 154 194 194 194 196 196 155 197 197 159 200 200 168 202 202 174 202 202 202 204 204 102 205 205 97 206 206 149 210 210 144 210 210 149 213 213 103 213 213 213 215 215 164 215 215 215 227 212 124 227 213 140 227 217 124 227 220 124 227 227 124 234 156 79 236 236 197 239 214 144 243 201 148 243 243 146 243 243 155 244 244 147 245 232 157 247 165 83 248 215 149 248 231 149 255 170 86 255 227 156 255 228 156 255 229 156 255 230 156 255 231 156 255 233 168 255 234 156 255 235 156 255 235 193 255 236 156 255 237 156 255 238 156 255 239 156 255 239 168 255 240 156 255 240 168 255 241 156 255 242 156 255 242 168 255 243 156 255 244 156 255 244 168 255 245 156 255 245 193 255 246 156 255 247 156 255 248 156 255 248 168 255 249 156 255 250 156 255 250 168 255 251 156 255 251 168 255 252 156 255 253 156 255 253 168 255 255 156 255 255 168 255 255 193 255 255 200]; mask:((ImageMask new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'O<@@_>@@???@??? ???0???0???0???0???0???8???8???<???<???<???<???8@B? @A?0@C?8@G=<@G0<@G0\') ; yourself); yourself]
+! !
+
+!SettingsDialog class methodsFor:'interface specs'!
+
+windowSpec
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "
+     UIPainter new openOnClass:SettingsDialog andSelector:#windowSpec
+     SettingsDialog new openInterface:#windowSpec
+     SettingsDialog open
+    "
+
+    <resource: #canvas>
+
+    ^ 
+     #(#FullSpec
+        #name: #windowSpec
+        #window: 
+       #(#WindowSpec
+          #label: 'Settings Dialog'
+          #name: 'Settings Dialog'
+          #min: #(#Point 10 10)
+          #max: #(#Point 1024 768)
+          #bounds: #(#Rectangle 16 42 816 662)
+          #menu: #mainMenu
+        )
+        #component: 
+       #(#SpecCollection
+          #collection: #(
+           #(#VariableHorizontalPanelSpec
+              #name: 'VariableHorizontalPanel1'
+              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+              #showHandle: true
+              #snapMode: #both
+              #component: 
+             #(#SpecCollection
+                #collection: #(
+                 #(#ViewSpec
+                    #name: 'Box1'
+                    #component: 
+                   #(#SpecCollection
+                      #collection: #(
+                       #(#HierarchicalListViewSpec
+                          #name: 'HierarchicalListView1'
+                          #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
+                          #model: #selectedItem
+                          #hasHorizontalScrollBar: true
+                          #hasVerticalScrollBar: true
+                          #listModel: #applicationList
+                          #useIndex: false
+                          #highlightMode: #label
+                          #showLeftIndicators: false
+                          #indicatorSelector: #doIndicatorClick:
+                        )
+                       #(#HorizontalPanelViewSpec
+                          #name: 'HorizontalPanel2'
+                          #layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
+                          #horizontalLayout: #fitSpace
+                          #verticalLayout: #center
+                          #horizontalSpace: 3
+                          #verticalSpace: 3
+                          #component: 
+                         #(#SpecCollection
+                            #collection: #(
+                             #(#ActionButtonSpec
+                                #label: 'Save as...'
+                                #name: 'Button1'
+                                #translateLabel: true
+                                #model: #saveSettings
+                                #extent: #(#Point 128 22)
+                              )
+                             #(#ActionButtonSpec
+                                #label: 'Load from...'
+                                #name: 'Button2'
+                                #translateLabel: true
+                                #model: #loadSettings
+                                #extent: #(#Point 128 22)
+                              )
+                             )
+                           
+                          )
+                        )
+                       )
+                     
+                    )
+                  )
+                 #(#ViewSpec
+                    #name: 'Box2'
+                    #component: 
+                   #(#SpecCollection
+                      #collection: #(
+                       #(#SubCanvasSpec
+                          #name: 'SubCanvas'
+                          #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
+                          #level: -1
+                          #hasHorizontalScrollBar: false
+                          #hasVerticalScrollBar: false
+                          #clientHolder: #subCanvasApplicationHolder
+                          #postBuildCallback: #postBuildSubCanvas:
+                        )
+                       #(#HorizontalPanelViewSpec
+                          #name: 'HorizontalPanel1'
+                          #layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
+                          #horizontalLayout: #fitSpace
+                          #verticalLayout: #center
+                          #horizontalSpace: 3
+                          #verticalSpace: 3
+                          #component: 
+                         #(#SpecCollection
+                            #collection: #(
+                             #(#ActionButtonSpec
+                                #label: 'OK'
+                                #name: 'OK'
+                                #translateLabel: true
+                                #model: #doSave
+                                #enableChannel: #enableOK
+                                #extent: #(#Point 127 22)
+                              )
+                             #(#ActionButtonSpec
+                                #label: 'Discard'
+                                #name: 'Reload'
+                                #translateLabel: true
+                                #model: #doReload
+                                #enableChannel: #enableReload
+                                #extent: #(#Point 128 22)
+                              )
+                             #(#ActionButtonSpec
+                                #label: 'Close'
+                                #name: 'Close'
+                                #translateLabel: true
+                                #model: #closeRequest
+                                #extent: #(#Point 127 22)
+                              )
+                             #(#ActionButtonSpec
+                                #label: 'Help'
+                                #name: 'Help'
+                                #translateLabel: true
+                                #model: #help
+                                #enableChannel: #enableHelp
+                                #extent: #(#Point 128 22)
+                              )
+                             )
+                           
+                          )
+                        )
+                       )
+                     
+                    )
+                  )
+                 )
+               
+              )
+              #handles: #(#Any 0.3375 1.0)
+            )
+           )
+         
+        )
+      )
+! !
+
+!SettingsDialog class methodsFor:'menu specs'!
+
+mainMenu
+    "This resource specification was automatically generated
+     by the MenuEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the MenuEditor may not be able to read the specification."
+
+    "
+     MenuEditor new openOnClass:SettingsDialog andSelector:#mainMenu
+     (Menu new fromLiteralArrayEncoding:(SettingsDialog mainMenu)) startUp
+    "
+
+    <resource: #menu>
+
+    ^ 
+     #(#Menu
+        #(
+         #(#MenuItem
+            #label: 'File'
+            #translateLabel: true
+            #submenu: 
+           #(#Menu
+              #(
+               #(#MenuItem
+                  #label: 'Load from...'
+                  #itemValue: #loadSettings
+                  #translateLabel: true
+                )
+               #(#MenuItem
+                  #label: 'Save as...'
+                  #itemValue: #saveSettings
+                  #translateLabel: true
+                )
+               #(#MenuItem
+                  #label: 'Exit'
+                  #itemValue: #closeRequest
+                  #translateLabel: true
+                )
+               )
+              nil
+              nil
+            )
+          )
+         )
+        nil
+        nil
+      )
+! !
+
+!SettingsDialog methodsFor:'accessing'!
+
+requestor
+    "return the 'requestor' of the SettingsDialog"
+
+    ^ requestor
+!
+
+requestor:something
+    "set the value of the instance variable 'requestor' (automatically generated)"
+
+    requestor := something.
+! !
+
+!SettingsDialog methodsFor:'actions'!
+
+destroyAll
+
+    self applicationList do:[ : applItem |
+        (applItem isCategory not and:[applItem application notNil]) ifTrue:[
+            applItem application close.
+        ].
+    ].
+    ^ true
+!
+
+doIndicatorClick:index 
+    "handle a click on the indicator
+    "
+
+    (self applicationList at:index) toggleExpand
+!
+
+doReload
+
+    | item |
+
+    item := self selectedItem value.
+    (item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ self].
+    item application loadRequest.
+!
+
+doSave
+    | item |
+
+    item := self selectedItem value.
+    (item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ self].
+    item application saveSettings.
+!
+
+help
+
+    | item |
+
+    item := self selectedItem value.
+    (item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ self].
+    item application help.
+!
+
+sendLoadRequestToAll
+
+    self applicationList do:[ : applItem |
+        (applItem isCategory not and:[applItem application notNil]) ifTrue:[
+            ^ applItem application loadRequest 
+        ].
+    ].
+    ^ true
+!
+
+sendSaveRequestToAll
+
+    self applicationList do:[ : applItem |
+        (applItem isCategory not and:[applItem application notNil]) ifTrue:[
+            applItem application saveRequest ifFalse:[
+                ^ false
+            ].
+        ].
+    ].
+    ^ true
+! !
+
+!SettingsDialog methodsFor:'application list access'!
+
+addApplClass:aClass withName:aName
+" add a application in the to the settingsTree, take the icon from the application class defaultIcon method"
+
+    self addApplClass:aClass withName:aName icon:nil.
+!
+
+addApplClass:aClass withName:aName icon:icon
+
+    |applicationLabel locIcon locClass|
+
+    (self applicationNames includes:aName) ifTrue:[
+        ^ self.
+    ].
+    self addCategoriesFor:aName.
+    locIcon := icon.
+    locClass := Smalltalk classNamed:aClass.
+    (locIcon isNil and:[locClass respondsTo:#defaultIcon]) ifTrue:[ locIcon := locClass defaultIcon].
+    applicationLabel := (aName asCollectionOfSubstringsSeparatedBy:$/) last.
+    self createItemName:aName label:applicationLabel class:locClass icon:locIcon
+!
+
+addIcon:aIcon forCategory:aCategoryName
+
+" add a new category Icon for a categorie "
+
+    self categoryIcons at:aCategoryName put:aIcon
+!
+
+applicationNames
+
+    ^ self applicationList collect:[:item | item nameString].
+!
+
+categoryIcons
+
+    categoryIcons isNil ifTrue:[
+        categoryIcons := Dictionary new.
+    ].
+    ^ categoryIcons 
+!
+
+remApplClass:aName 
+" remove a application from the settingsTree"
+
+    |item parent remParent|
+
+    item := self getItemForName:aName.
+    parent := item parent.
+    parent remove:item.
+    
+    [parent isCategory and:[parent children isEmptyOrNil]] whileTrue:[
+        remParent := parent.
+        parent := remParent parent.
+        parent remove:remParent.
+    ].
+!
+
+removeApplicationByClass:aClass
+
+    | classEntries|
+
+    self applicationList isNil ifTrue:[
+        self initialize.
+    ].
+    classEntries := self applicationList select:[: aEntry | ((aEntry at:2) == aClass)].
+    ApplicationList removeAll:classEntries.
+! !
+
+!SettingsDialog methodsFor:'application list access -private'!
+
+addCategoriesFor:aName
+
+    " create all the categories before application itself
+    "
+
+    (aName includes:$/) not ifTrue:[ ^ self].
+    self treeName:aName do:[:currentLabel :currentName| | length icon|
+        currentLabel notEmpty ifTrue:[
+            icon := self categoryIcons at:currentName ifAbsent:[nil].
+            self createItemName:currentName label:currentLabel icon:icon.
+        ]
+    ] forgetLast:1.
+!
+
+createItemName:aNameString label:aLabel class:aClass icon:aIcon
+
+    " create an application item in my application list 
+    "
+    | newItem rootItem parent locIcon|
+
+    aNameString ~= aLabel ifTrue:[
+        parent := self getItemForName:(aNameString copyTo:(aNameString size - aLabel size - 1)).
+    ].
+    parent isNil ifTrue:[
+        parent := self applicationList root.
+    ].
+    parent children notNil ifTrue:[
+        (parent children detect:[ :aItem | aItem label = aLabel] ifNone:[nil]) notNil ifTrue:[
+            ^ self.
+        ]
+    ].
+    newItem := self class itemClass new.  
+    newItem label:(Text string:aLabel emphasis:#bold).
+    newItem nameString:aNameString.
+    newItem applicationClass:aClass.
+    locIcon := aIcon.
+    locIcon isNil ifTrue:[ locIcon := self class defaultSettingsAppIcon].
+    newItem icon:locIcon.
+    rootItem := self applicationList root.
+    parent children isNil ifTrue:[
+        parent children:(OrderedCollection with:newItem)
+    ] ifFalse:[
+        | newColl alreadyIn|
+        newColl := parent children copy.
+        newColl add:newItem.
+        parent children:newColl.
+    ]
+!
+
+createItemName:aNameString label:aLabel icon:aIcon
+
+    " create an application item in my application list 
+    "
+    self createItemName:aNameString label:aLabel class:nil icon:aIcon
+!
+
+getItemForName:aName
+
+    | searchItem|
+
+    searchItem := self applicationList root.
+    self treeName:aName do:[:currentLabel :currentName|
+        searchItem children isNil ifTrue:[ ^ nil].
+        searchItem := searchItem children detect:[: item | item nameString = currentName] ifNone:[nil].
+        searchItem isNil ifTrue:[ ^ nil].
+    ].
+    ^ searchItem
+!
+
+treeName:aName do:aBlock
+
+    self treeName:aName do:aBlock forgetLast:0
+!
+
+treeName:aName do:aBlock forgetLast:last
+
+    | tree  length|
+
+    tree := aName asCollectionOfSubstringsSeparatedBy:$/.
+    tree from:1 to:(tree size - last) keysAndValuesDo:[:idx :aCategory| | itemName |
+        length := 0.
+        tree from:1 to:idx keysAndValuesDo:[:idx2 : el | 
+            length := length + el size.
+            idx2 > 1 ifTrue:[length := length + 1].
+        ].
+        itemName := aName copyTo:length.
+        aBlock value:aCategory value:itemName.
+    ].
+! !
+
+!SettingsDialog methodsFor:'aspects'!
+
+applicationList
+
+    applicationList isNil ifTrue:[
+        applicationList := SettingsDialog::HierarchicalApplicationList new.
+    ].
+    ^ applicationList.
+!
+
+enableHelp
+
+    enableHelp isNil ifTrue:[
+        enableHelp := true asValue.
+    ].
+    ^ enableHelp.
+!
+
+enableOK
+
+    enableOK isNil ifTrue:[
+        enableOK := true asValue.
+    ].
+    ^ enableOK.
+!
+
+enableReload
+
+    enableReload isNil ifTrue:[
+        enableReload := true asValue.
+    ].
+    ^ enableReload.
+!
+
+selectedItem
+
+    selectedItem isNil ifTrue:[
+        selectedItem := ValueHolder new.
+        selectedItem addDependent:self.
+    ].
+    ^ selectedItem.
+!
+
+subCanvasApplicationHolder
+
+    subCanvasApplicationHolder isNil ifTrue:[
+        subCanvasApplicationHolder := ValueHolder new.
+    ].
+    ^ subCanvasApplicationHolder.
+! !
+
+!SettingsDialog methodsFor:'change & update'!
+
+modifiedChanged
+
+    |changedObject|
+
+    changedObject := self subCanvasApplicationHolder value modifiedChannel.
+    self enableOK value:(changedObject value).
+    self enableReload value:(changedObject value).
+!
+
+selectionChanged
+
+    | item oldAppl noApp|
+
+    oldAppl := self subCanvasApplicationHolder value.
+    oldAppl notNil ifTrue:[
+        oldAppl saveRequest.
+        oldAppl modifiedChannel removeDependent:self.
+    ].
+    item := self selectedItem value.
+    item isNil ifTrue:[ noApp := true] ifFalse:[noApp := item isCategory].
+    self enableOK value:(noApp not).
+    self enableReload value:(noApp not).
+    self enableHelp value:(noApp not).
+    noApp ifTrue:[
+        self subCanvasApplicationHolder value:nil.
+        ^ self
+    ].
+    item application isNil ifTrue:[
+        item application:(item applicationClass new).
+
+    ].
+    item application modifiedChannel addDependent:self.
+    self subCanvasApplicationHolder value:item application.
+    self modifiedChanged.
+!
+
+update:something with:aParameter from:changedObject
+    "Invoked when an object that I depend upon sends a change notification."
+
+    "stub code automatically generated - please change as required"
+
+    changedObject == self selectedItem ifTrue:[
+        self selectionChanged.
+        ^ self
+    ].
+    changedObject == self subCanvasApplicationHolder value modifiedChannel ifTrue:[
+        self modifiedChanged.
+        ^ self
+    ].
+
+    super update:something with:aParameter from:changedObject
+! !
+
+!SettingsDialog methodsFor:'initialization & release'!
+
+closeRequest
+    "This is a hook method generated by the Browser.
+     It will be invoked when your app/dialog-window is about to be
+     closed (this method has a chance to suppress the close).
+     See also #closeDownViews, which is invoked when the close is really done."
+
+    self sendSaveRequestToAll ifFalse:[ ^ self].
+    self destroyAll.
+    self requestor settingsClosed.
+    ^ super closeRequest
+!
+
+initialize
+
+    |rootItem|
+
+    resources := AbstractLauncherApplication resources.
+    rootItem := self class itemClass new.
+    rootItem label:(Text string:(resources string:'Settings') emphasis:#bold).
+    rootItem nameString:'Settings'.
+    rootItem icon:self class settingsIcon.
+    self applicationList root:rootItem.
+    self applicationList showRoot:true.
+    self selectedItem value:rootItem.
+    super initialize.
+!
+
+postBuildSubCanvas:aWidget
+
+    aWidget keepClientView:true. 
+!
+
+postOpenWith:aBuilder
+
+    self applicationList root expand.
+    super postOpenWith:aBuilder.
+! !
+
+!SettingsDialog methodsFor:'menu actions'!
+
+loadSettings
+
+    "restore settings from a settings-file."
+
+    "a temporary kludge - we need a central systemSettings object for this,
+     which can be saved/restored with a single store/read."
+
+    |fileName|
+
+    fileName := Dialog 
+        requestFileName:(resources string:'Load Settings From:') 
+        default:'settings.stx'
+        ok:(resources string:'Load') 
+        abort:(resources string:'Cancel') 
+        pattern:'*.stx'
+        fromDirectory:nil.
+
+    (fileName size == 0) ifTrue:[
+        "/ canceled
+        ^ self
+    ].
+
+    self withWaitCursorDo:[
+        Smalltalk fileIn:fileName.
+        Transcript current topView model reOpen.
+        self sendLoadRequestToAll.
+    ].
+!
+
+saveSettings
+
+    |fileName resources|
+
+    resources := self class owningClass classResources.
+
+    fileName := Dialog 
+        requestFileName:(resources string:'Save settings in:') 
+        default:'settings.stx'
+        ok:(resources string:'Save') 
+        abort:(resources string:'Cancel') 
+        pattern:'*.stx'
+        fromDirectory:'.'.
+
+    fileName size ~~ 0 ifTrue:[
+        "not canceled"
+        self saveSettingsIn:fileName.
+    ]
+!
+
+saveSettingsIn:fileName
+    "save settings to a settings-file."
+
+    "a temporary kludge - we need a central systemSettings object for this,
+     which can be saved/restored with a single store/read.
+     Will move entries over to UserPreferences over time;
+     new items should always go there."
+
+    |resources s screen currentUserPrefs|
+
+    resources := self class owningClass classResources.
+
+    s := fileName asFilename writeStream.
+    s isNil ifTrue:[
+        self warn:(resources string:'Cannot write the %1 file !!' with:fileName).
+        ^ self
+    ].
+
+    currentUserPrefs := UserPreferences current.
+    screen := Screen current.
+
+    s nextPutLine:'"/ ST/X saved settings';
+      nextPutLine:'"/ DO NOT MODIFY MANUALLY';
+      nextPutLine:'"/ (modifications would be lost with next save-settings)';
+      nextPutLine:'"/';
+      nextPutLine:'"/ this file was automatically generated by the';
+      nextPutLine:'"/ ''save settings'' function of the Launcher';
+      nextPutLine:'"/'.
+    s cr.
+
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ saved by ' , OperatingSystem getLoginName , '@' , OperatingSystem getHostName , ' at ' , AbsoluteTime now printString.
+    s nextPutLine:'"/'.
+    s cr.
+
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Display settings:'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ only restore the display settings, if on the same Display ...'.
+    s nextPutLine:'Display notNil ifTrue:['.
+    s nextPutLine:' Display displayName = ' , (screen displayName storeString) , ' ifTrue:['.
+      screen fixColors notNil ifTrue:[
+        s nextPutLine:'  Image flushDeviceImages.'.
+        s nextPutLine:'  Color colorAllocationFailSignal catch:['.
+        s nextPutLine:'    Color getColorsRed:6 green:6 blue:4 on:Display'.
+        s nextPutLine:'  ].'.
+      ] ifFalse:[
+        s nextPutLine:'  Display releaseFixColors.'.
+      ].
+      s nextPutLine:'  Display hasColors: ' , (screen hasColors storeString) , '.'.
+      s nextPutLine:'  Display widthInMillimeter: ' , (screen widthInMillimeter storeString) , '.'.
+      s nextPutLine:'  Display heightInMillimeter: ' , (screen heightInMillimeter storeString) , '.'.
+      s nextPutLine:'  Display supportsDeepIcons: ' , (screen supportsDeepIcons storeString) , '.'.
+      s nextPutLine:'  Image ditherAlgorithm: ' , (Image ditherAlgorithm storeString) , '.'.
+      s nextPutLine:'  View defaultStyle:' , View defaultStyle storeString , '.'.
+    s nextPutLine:' ].'.
+    s nextPutLine:'].'.
+    s cr.
+
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Compiler settings:'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'Compiler warnSTXSpecials: ' , (Compiler warnSTXSpecials storeString) , '.';
+      nextPutLine:'Compiler warnUnderscoreInIdentifier: ' , (Compiler warnUnderscoreInIdentifier storeString) , '.';
+      nextPutLine:'Compiler warnOldStyleAssignment: ' , (Compiler warnOldStyleAssignment storeString) , '.';
+      nextPutLine:'Compiler warnCommonMistakes: ' , (Compiler warnCommonMistakes storeString) , '.';
+      nextPutLine:'Compiler warnPossibleIncompatibilities: ' , (Compiler warnPossibleIncompatibilities storeString) , '.';
+      nextPutLine:'Compiler allowUnderscoreInIdentifier: ' , (Compiler allowUnderscoreInIdentifier storeString) , '.';
+      nextPutLine:'Compiler allowSqueakExtensions: ' , (Compiler allowSqueakExtensions storeString) , '.';
+      nextPutLine:'Compiler allowDolphinExtensions: ' , (Compiler allowDolphinExtensions storeString) , '.';
+      nextPutLine:'Compiler arraysAreImmutable: ' , (Compiler arraysAreImmutable storeString) , '.';
+      nextPutLine:'Compiler lineNumberInfo: ' , (Compiler lineNumberInfo storeString) , '.';
+
+      nextPutLine:'Compiler foldConstants: ' , (Compiler foldConstants storeString) , '.';
+      nextPutLine:'Compiler stcCompilation: ' , (Compiler stcCompilation storeString) , '.';
+      nextPutLine:'OperatingSystem getOSType = ' , (OperatingSystem getOSType storeString) , ' ifTrue:[';
+      nextPutLine:'  Compiler stcCompilationIncludes: ' , (Compiler stcCompilationIncludes storeString) , '.';
+      nextPutLine:'  Compiler stcCompilationDefines: ' , (Compiler stcCompilationDefines storeString) , '.';
+      nextPutLine:'  Compiler stcCompilationOptions: ' , (Compiler stcCompilationOptions storeString) , '.';
+      nextPutLine:'  ' , (Compiler stcModulePath storeString) , ' asFilename exists ifTrue:[';
+      nextPutLine:'    Compiler stcModulePath: ' , (Compiler stcModulePath storeString) , '.';
+      nextPutLine:'  ].';
+      nextPutLine:'  Compiler stcPath: ' , (Compiler stcPath storeString) , '.';
+      nextPutLine:'  Compiler ccCompilationOptions: ' , (Compiler ccCompilationOptions storeString) , '.';
+      nextPutLine:'  Compiler ccPath: ' , (Compiler ccPath storeString) , '.';
+      nextPutLine:'  ObjectFileLoader linkArgs: ' , (ObjectFileLoader linkArgs storeString) , '.';
+      nextPutLine:'  ObjectFileLoader linkCommand: ' , (ObjectFileLoader linkCommand storeString) , '.';
+      nextPutLine:'  ObjectFileLoader libPath: ' , (ObjectFileLoader libPath storeString) , '.';
+      nextPutLine:'  ObjectFileLoader searchedLibraries: ' , (ObjectFileLoader searchedLibraries storeString) , '.';
+      nextPutLine:'].';
+
+      nextPutLine:'ObjectMemory justInTimeCompilation: ' , (ObjectMemory justInTimeCompilation storeString) , '.';
+      nextPutLine:'ObjectMemory fullSingleStepSupport: ' , (ObjectMemory fullSingleStepSupport storeString) , '.'.
+
+    HistoryManager notNil ifTrue:[
+        HistoryManager isActive ifTrue:[
+            s nextPutLine:'HistoryManager notNil ifTrue:[HistoryManager activate].'.
+            s nextPutLine:'HistoryManager notNil ifTrue:[HistoryManager fullHistoryUpdate:' , HistoryManager fullHistoryUpdate storeString , '].'.
+        ] ifFalse:[
+            s nextPutLine:'HistoryManager notNil ifTrue:[HistoryManager deactivate].'.
+        ].
+    ].
+
+    ObjectFileLoader notNil ifTrue:[
+        s nextPutLine:'ObjectFileLoader searchedLibraries: ' , (ObjectFileLoader searchedLibraries storeString) , '.'.
+        s nextPutLine:'ObjectFileLoader libPath: ' , (ObjectFileLoader libPath storeString) , '.'.
+    ].
+
+    s nextPutLine:'Class catchMethodRedefinitions: ' , (Class catchMethodRedefinitions storeString) , '.'.
+    s nextPutLine:'ClassCategoryReader sourceMode: ' , (ClassCategoryReader sourceMode storeString) , '.'.
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Info & Debug Messages:'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'ObjectMemory infoPrinting: ' , (ObjectMemory infoPrinting storeString) , '.';
+      nextPutLine:'ObjectMemory debugPrinting: ' , (ObjectMemory debugPrinting storeString) , '.';
+      nextPutLine:'Object infoPrinting: ' , (Object infoPrinting storeString) , '.';
+      nextPutLine:'DeviceWorkstation errorPrinting: ' , (DeviceWorkstation errorPrinting storeString) , '.'.
+
+    FlyByHelp isActive ifTrue:[
+        s nextPutLine:'FlyByHelp start.'
+    ].
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Edit settings:'.
+    s nextPutLine:'"/'.
+    "/ s nextPutLine:'EditTextView st80Mode: ' , (EditTextView st80Mode storeString) , '.'.
+    s nextPutLine:'TextView st80SelectMode: ' , (TextView st80SelectMode storeString) , '.'.
+    s nextPutLine:'UserPreferences current syntaxColoring: ' , (currentUserPrefs syntaxColoring storeString) , '.'.
+    (ListView userDefaultTabPositions = ListView tab4Positions) ifTrue:[
+        s nextPutLine:'ListView userDefaultTabPositions:(ListView tab4Positions).'.
+    ] ifFalse:[
+        s nextPutLine:'ListView userDefaultTabPositions:(ListView tab8Positions).'.
+    ].
+
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ User preference values:'.
+    s nextPutLine:'"/'.
+    currentUserPrefs keysAndValuesDo:[:k :v |
+        (UserPreferences includesSelector:(k , ':') asSymbol) ifTrue:[
+            s nextPutLine:'UserPreferences current ' , k , ':' , v storeString , '.'.
+        ] ifFalse:[
+            s nextPutLine:'UserPreferences current at:' , k storeString , ' put:' , v storeString , '.'.
+        ]
+    ].
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Misc settings:'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'Class keepMethodHistory: ' , (Class methodHistory notNil storeString) , '.';
+      nextPutLine:'Smalltalk logDoits: ' , (Smalltalk logDoits storeString) , '.';
+      nextPutLine:'Autoload compileLazy: ' , (Autoload compileLazy storeString) , '.';
+      nextPutLine:'Smalltalk loadBinaries: ' , (Smalltalk loadBinaries storeString) , '.';
+      nextPutLine:'StandardSystemView includeHostNameInLabel: ' , (StandardSystemView includeHostNameInLabel storeString) , '.';
+
+      "/ claus - I dont think its a good idea to save those ...
+      nextPutLine:'"/ Class updateChanges: ' , (Class updatingChanges storeString) , '.';
+      nextPutLine:'"/ ObjectMemory nameForChanges: ' , (ObjectMemory nameForChanges storeString) , '.';
+
+      nextPutLine:'StandardSystemView returnFocusWhenClosingModalBoxes: ' , (StandardSystemView returnFocusWhenClosingModalBoxes storeString) , '.';
+      nextPutLine:'StandardSystemView takeFocusWhenMapped: ' , (StandardSystemView takeFocusWhenMapped storeString) , '.';
+      nextPutLine:'Display notNil ifTrue:[';
+      nextPutLine:' Display activateOnClick: ' , ((screen activateOnClick:nil) storeString) , '.';
+      nextPutLine:'].';
+      nextPutLine:'MenuView showAcceleratorKeys: ' , (MenuView showAcceleratorKeys storeString) , '.';
+      nextPutLine:'Class tryLocalSourceFirst: ' , (Class tryLocalSourceFirst storeString) , '.'.
+    (Exception emergencyHandler == AbstractLauncherApplication notifyingEmergencyHandler) ifTrue:[
+        s nextPutLine:'Exception emergencyHandler:(AbstractLauncherApplication notifyingEmergencyHandler).'.
+    ].
+    Processor isTimeSlicing ifTrue:[
+        s nextPutLine:'Processor startTimeSlicing.'.
+        s nextPutLine:('Processor supportDynamicPriorities:' , (Processor supportDynamicPriorities ? false) storeString , '.').
+    ] ifFalse:[
+        s nextPutLine:'Processor stopTimeSlicing.'.
+    ].
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Printer settings:'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'Printer := ' , (Printer name) , '.';
+      nextPutLine:'Printer printCommand: ' , (Printer printCommand storeString) , '.'.
+
+    Printer supportsPageSizes ifTrue:[
+        s nextPutLine:'Printer pageFormat: ' , (Printer pageFormat storeString) , '.'.
+        s nextPutLine:'Printer landscape: ' , (Printer landscape storeString) , '.'.
+    ].
+    Printer supportsMargins ifTrue:[
+        s nextPutLine:'Printer topMargin: ' , (Printer topMargin storeString) , '.'.
+        s nextPutLine:'Printer leftMargin: ' , (Printer leftMargin storeString) , '.'.
+        s nextPutLine:'Printer rightMargin: ' , (Printer rightMargin storeString) , '.'.
+        s nextPutLine:'Printer bottomMargin: ' , (Printer bottomMargin storeString) , '.'.
+    ].
+    Printer supportsPostscript ifTrue:[
+        s nextPutLine:'Printer supportsColor: ' , (Printer supportsColor storeString) , '.'.
+    ].
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Font settings:'.
+    s nextPutLine:'"/ (only restored, if image is restarted on the same display)'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'Display notNil ifTrue:['.
+    s nextPutLine:' Display displayName = ' , (screen displayName storeString) , ' ifTrue:['.
+    s nextPutLine:'  View defaultFont: ' , (View defaultFont storeString) , '.'.
+    s nextPutLine:'  Label defaultFont: ' , (Label defaultFont storeString) , '.'.
+    s nextPutLine:'  Button defaultFont: ' , (Button defaultFont storeString) , '.'.
+    s nextPutLine:'  Toggle defaultFont: ' , (Toggle defaultFont storeString) , '.'.
+    s nextPutLine:'  SelectionInListView defaultFont: ' , (SelectionInListView defaultFont storeString) , '.'.
+    s nextPutLine:'  MenuView defaultFont: ' , (MenuView defaultFont storeString) , '.'.
+    s nextPutLine:'  PullDownMenu defaultFont: ' , (PullDownMenu defaultFont storeString) , '.'.
+    s nextPutLine:'  TextView defaultFont: ' , (TextView defaultFont storeString) , '.'.
+    s nextPutLine:'  EditTextView defaultFont: ' , (EditTextView defaultFont storeString) , '.'.
+    s nextPutLine:'  CodeView defaultFont: ' , (CodeView defaultFont storeString) , '.'.
+    s nextPutLine:' ].'.
+    s nextPutLine:'].'.
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ Language setting:'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'Smalltalk language: ' , (Smalltalk language storeString) , '.'.
+    s nextPutLine:'Smalltalk languageTerritory: ' , (Smalltalk languageTerritory storeString) , '.'.
+
+    s cr.
+    s nextPutLine:'"/'.
+    s nextPutLine:'"/ SourceCodeManager settings:'.
+    s nextPutLine:'"/ (only restored, if image is restarted on the same host)'.
+    s nextPutLine:'"/'.
+    s nextPutLine:'OperatingSystem getHostName = ' , (OperatingSystem getHostName storeString) , ' ifTrue:['.
+    s nextPutLine:'  Class tryLocalSourceFirst:' , Class tryLocalSourceFirst storeString , '.'.
+    (Smalltalk at:#SourceCodeManager) == CVSSourceCodeManager ifTrue:[
+    s nextPutLine:'  Smalltalk at:#SourceCodeManager put: CVSSourceCodeManager.'.
+    s nextPutLine:'  AbstractSourceCodeManager cacheDirectoryName:' , AbstractSourceCodeManager cacheDirectoryName storeString , '.'.
+    s nextPutLine:'  CVSSourceCodeManager cvsBinDirectory:' , CVSSourceCodeManager cvsBinDirectory storeString , '.'.
+    s nextPutLine:'  CVSSourceCodeManager repositoryNamesPerModule:' , CVSSourceCodeManager repositoryNamesPerModule storeString , '.'.
+    s nextPutLine:'  CVSSourceCodeManager initializeForRepository:' , CVSSourceCodeManager repositoryName storeString , '.'.
+    ].
+    s nextPutLine:'].'.
+
+    s close.
+
+    "
+     Transcript topView application saveSettings
+    "
+
+    "Modified: / 6.1.1999 / 14:24:16 / cg"
+! !
+
+!SettingsDialog methodsFor:'queries'!
+
+recursiveGetParentFor:aCategory fromItem:aItem
+
+    | children |
+    children := aItem children.
+    children notNil ifTrue:[
+        children do:[:aChildItem | | newItem |
+            aChildItem nameString = aCategory ifTrue:[ ^ aChildItem].
+            newItem := self recursiveGetParentFor:aCategory fromItem:aChildItem.
+            newItem notNil ifTrue:[^ newItem].
+        ].
+    ].
+    ^ nil
+! !
+
+!SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'accessing'!
+
+application
+    "return the value of the instance variable 'application' (automatically generated)"
+
+    ^ application
+!
+
+application:something
+    "set the value of the instance variable 'application' (automatically generated)"
+
+    application := something.
+!
+
+applicationClass
+    "return the value of the instance variable 'applicationClass' (automatically generated)"
+
+    ^ applicationClass
+!
+
+applicationClass:something
+    "set the value of the instance variable 'applicationClass' (automatically generated)"
+
+    applicationClass := something.
+!
+
+icon
+    "return the value of the instance variable 'icon' (automatically generated)"
+
+    ^ icon
+!
+
+icon:something
+    "set the value of the instance variable 'icon' (automatically generated)"
+
+    icon := something.
+!
+
+label
+    "return the value of the instance variable 'label' (automatically generated)"
+
+    ^ label
+!
+
+label:something
+    "set the value of the instance variable 'label' (automatically generated)"
+
+    label := something.
+!
+
+nameString
+    "return the value of the instance variable 'nameString' (automatically generated)"
+
+    ^ nameString
+!
+
+nameString:something
+    "set the value of the instance variable 'nameString' (automatically generated)"
+
+    nameString := something.
+! !
+
+!SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'queries'!
+
+isCategory
+
+    ^ self applicationClass isNil
+! !
+
+!SettingsDialog class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.1 2002-12-13 16:27:35 penk Exp $'
+! !