AbstractLauncherApplication.st
author penk
Tue, 12 Nov 2002 12:25:24 +0100
changeset 4244 64dcb0a42673
parent 4243 2dc1cbadd5fc
child 4245 fe5535df5fb3
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1997 by eXept Software AG
              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.
"


"{ Package: 'stx:libtool' }"

ToolApplicationModel subclass:#AbstractLauncherApplication
	instanceVariableNames:'transcript'
	classVariableNames:'NotifyingEmergencyHandler OpenLaunchers RegisteredMenuHandlers'
	poolDictionaries:''
	category:'Interface-Smalltalk'
!

AbstractSettingsApplication subclass:#KbdMappingSettingsAppl
	instanceVariableNames:'modifiedChannel selectedRawKey macroTextHolder
		selectedFunctionKey labelTextHolder functionKeyList rawKeyList
		mappings'
	classVariableNames:''
	poolDictionaries:''
	privateIn:AbstractLauncherApplication
!

AbstractSettingsApplication subclass:#LanguageSettingsAppl
	instanceVariableNames:'modifiedChannel languageHolder languageList listOfLanguages
		translatedLanguages noticeLabelHolder currentLanguageChannel
		currentLanguageLabel'
	classVariableNames:''
	poolDictionaries:''
	privateIn:AbstractLauncherApplication
!

Object subclass:#LauncherDialogs
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:AbstractLauncherApplication
!

ApplicationModel subclass:#SettingsDialog
	instanceVariableNames:'canvasHolder appList selectionHolder selection requestor
		colOfInstances'
	classVariableNames:'ApplicationList'
	poolDictionaries:''
	privateIn:AbstractLauncherApplication
!

AbstractSettingsApplication subclass:#StyleSettingsAppl
	instanceVariableNames:'modifiedChannel showStandardStylesOnly styleList selectedStyle
		styleDirectoryContents infoLabelHolder noticeLabelHolder'
	classVariableNames:''
	poolDictionaries:''
	privateIn:AbstractLauncherApplication
!

AbstractSettingsApplication subclass:#ToolsSettingsAppl
	instanceVariableNames:'useNewVersionDiffBrowser transcriptBufferSize useNewInspector
		showClockInLauncher useNewChangesBrowser useNewFileBrowser
		useNewSystemBrowser currentUserPrefs modifiedChannel'
	classVariableNames:''
	poolDictionaries:''
	privateIn:AbstractLauncherApplication
!

!AbstractLauncherApplication class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1997 by eXept Software AG
              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.
"

!

documentation
"
    This is an abstract class, providing mechanisms and common functionality
    for launcher-type applications. Subclasses may implement their GUI either
    with or without the UIPainter framework, and still use the common functions
    provided here.

    [author:]
        Claus Gittinger, eXept Software AG
"


! !

!AbstractLauncherApplication class methodsFor:'accessing'!

closeAllLaunchers
    "close all opened launchers"

    self openLaunchers copy do:[:eachLauncher |
        eachLauncher closeRequest
    ].

    "
     self closeAllLaunchers.
     NewLauncher open
    "
!

current
    "return the launcher running on the current screen.
     (for access via addMenu/ removeMenu)"

    |currentScreen|

    OpenLaunchers size > 0 ifTrue:[
        currentScreen := Screen current.
        ^ OpenLaunchers detect:[:eachLauncher | eachLauncher graphicsDevice == currentScreen] ifNone:nil
    ].
    ^ nil.

    "
     NewLauncher current
    "

    "Modified: / 9.9.1996 / 22:41:36 / stefan"
    "Modified: / 13.10.1998 / 16:09:50 / cg"
!

openLaunchers
    "return all opened launchers"

    OpenLaunchers isNil ifTrue:[
        OpenLaunchers := IdentitySet new
    ].
    ^ OpenLaunchers
! !

!AbstractLauncherApplication class methodsFor:'defaults'!

notifyingEmergencyHandler
    "return a block (used as an emergency handler
     for exceptions), which does errorNotification before going
     into the debugger."

    "Remember the handlerBlock, to be able to determine if the current
     handler is the notifying one."

    NotifyingEmergencyHandler isNil ifTrue:[
        NotifyingEmergencyHandler := NoHandlerError notifyingEmergencyHandler
    ].
    ^ NotifyingEmergencyHandler

    "Created: 7.1.1997 / 22:18:19 / cg"
    "Modified: 15.1.1997 / 21:15:38 / cg"
! !

!AbstractLauncherApplication class methodsFor:'queries'!

isVisualStartable
    "return true, if this application can be started via #open.
     (to allow start of a change browser via double-click in the browser)"

    "/ assume all my subclasses can
    ^ self ~~ AbstractLauncherApplication

    "
     AbstractLauncherApplication isVisualStartable
     NewLauncher isVisualStartable
    "
! !

!AbstractLauncherApplication methodsFor:'private'!

findApplicationClass:classOrClassName nameSpace:aNameSpace
    "find some application, given the classes name.
     Look for it in Smalltalk and the given nameSpace"

    |cls|

    classOrClassName isBehavior ifTrue:[
        cls := classOrClassName.
    ] ifFalse:[
        cls := Smalltalk at:classOrClassName asSymbol.
        cls isNil ifTrue:[
            "/ look if its in the nameSpace
            aNameSpace notNil ifTrue:[
                cls := aNameSpace at:classOrClassName asSymbol
            ]
        ].
        cls isNil ifTrue:[
            self warn:(resources string:'Sorry, the ''%1''-class is not available.' with:classOrClassName).
            ^ nil
        ].
    ].
    ^ cls
!

findWindow:title
    "a helper for find & destroy and find & raise operations;
     let user choose a view and return it; return nil on cancel"

    ^ self findWindow:title windowGroupFilter:nil

!

findWindow:title windowGroupFilter:windowGroupFilterOrNil
    "a helper for find & destroy and find & raise operations;
     let user choose a view and return it; return nil on cancel"

    |knownTopViews nameList box|

    knownTopViews := IdentitySet new.
    Screen allScreens do:[:aScreen |
        aScreen knownViews do:[:aView |
            |top showIt wg|

            aView notNil ifTrue:[
                top := aView topView.
                (top isKindOf:DebugView) ifTrue:[
                    "/ although modal, show it.
                    showIt := top realized
                ] ifFalse:[
                    wg := top windowGroup.
                    showIt := (wg notNil and:[wg isModal not]).
                    showIt ifTrue:[
                        windowGroupFilterOrNil notNil ifTrue:[
                            showIt := windowGroupFilterOrNil includes:wg
                        ]
                    ]
                ].
                showIt ifTrue:[
                    knownTopViews add:top
                ]
            ]
        ]
    ].

    knownTopViews := knownTopViews asOrderedCollection.
    knownTopViews sort:[:v1 :v2 | |l1 l2|
                                l1 := v1 label ? 'aView'.
                                l2 := v2 label ? 'aView'.
                                l1 < l2
                       ].

    nameList := knownTopViews collect:[:v | 
                                        |isDead wg p l|

                                        l := v label ? 'aView'.
                                        v device == Display ifFalse:[
                                            l := l , ' [' , (v device displayName ? '?') , ']'
                                        ].
                                        ((wg := v windowGroup) notNil
                                        and:[(p := wg process) notNil
                                        and:[p state ~~ #dead]]) ifTrue:[
                                            l  
                                        ] ifFalse:[
                                            l , ' (dead ?)'
                                        ]
                                      ].

    box := ListSelectionBox new.
    box selectionChangeCallback:[:selectionIndex |   |v|
                                    v := knownTopViews at:box selectionIndex.
                                    v raise. box raise 
                                ].
    box noEnterField.
    box list:nameList.
    box label:(resources string:'view selection').
    box title:(resources string:title) withCRs.
    box action:[:selection |
        |v|

        v := knownTopViews at:box selectionIndex.
        box destroy.
        ^ v
    ].
    box extent:400@300.
    box open.
    ^ nil
!

openApplication: classOrClassName
     "open an application, given by the classe name."

    self openApplication:classOrClassName nameSpace:nil
!

openApplication:classOrClassName nameSpace:aNameSpace
    "open some application, given the classes name.
     Look for it in Smalltalk and the given nameSpace"

    self openApplication:classOrClassName nameSpace:aNameSpace with:#open
!

openApplication:classOrClassName nameSpace:aNameSpace with:aSelector
    "open some application, given the classes name.
     Look for it in Smalltalk and the given nameSpace"

    |cls|

    cls := self findApplicationClass:classOrClassName nameSpace:aNameSpace.
    cls isNil ifTrue:[
        ^ self
    ].

    Autoload autoloadFailedSignal handle:[:ex |
        self warn:(resources string:'Sorry, the %1 class seems to be not available.' with:cls name)
    ] do:[
        self withWaitCursorDo:[
            cls perform:aSelector
        ]
    ]
!

openSettings

    | builder|

    builder := SettingsDialog open.
    builder application requestor:self.
!

pickAView
    "let user pick a view and return it"

    |v|

    (Delay forSeconds:1) wait.
    v := Screen current viewFromUser.
    v isNil ifTrue:[
	self warn:'Sorry, this is not a smalltalk view'.
	^ nil
    ].
    ^ v

!

saveScreenImage:anImage defaultName:defaultName
    "save an image into a file 
     - ask user for filename using a fileSelectionBox."

    |fileName|

    fileName := Dialog
                    requestFileName:(resources string:'Save hardcopy image in:') 
                    default:(defaultName , '.tiff')
                    ok:(resources string:'Save')
                    abort:(resources string:'Cancel')
                    pattern:'*.tiff'
                    fromDirectory:nil
                    whenBoxCreatedEvaluate:[:box | 
                                                |editButton|
                                                UserPreferences current useNewFileDialog ifFalse:[
                                                    editButton := Button label:(resources string:'Edit').
                                                    (DialogBox styleSheet at:'dialogBox.okAtLeft' default:false) ifFalse:[
                                                        box addButton:editButton before:nil
                                                    ] ifTrue:[
                                                        box addButton:editButton after:nil
                                                    ].
                                                    editButton 
                                                        action:[ 
                                                            box hide; destroy.
                                                            ImageEditor openOnImage:anImage.
                                                        ].
                                                ]
                                           ].
    fileName notNil ifTrue:[
        anImage saveOn:fileName
    ].

    "Modified: / 21.2.1996 / 13:09:28 / cg"
    "Created: / 29.1.1998 / 23:20:36 / cg"
!

showDocumentation:aRelativeDocFilePath
    "open an HTML browser on some document"

    "
     although that one is not yet finished,
     its better than nothing ...
    "
    HTMLDocumentView notNil ifTrue:[
	self withWaitCursorDo:[
	    "
	     temporary kludge;
	     not all machines can autoload binaries;
	     however, on my SGI (which can) we want it
	     to load automatically.
	    "
	    HTMLDocumentView isLoaded ifFalse:[
		ErrorSignal catch:[HTMLDocumentView autoload]
	    ].
	    HTMLDocumentView isLoaded ifTrue:[
		HTMLDocumentView openFullOnDocumentationFile:aRelativeDocFilePath. 
		^ self
	    ].
	]
    ].

    self warn:'Sorry, the ST/X HTML reader is not
included in this release.

Please use Mosaic, netscape, chimera or any
other HTML viewer to see the documentation.

The documentation is found in the ''doc/online'' directory.'.

    "Modified: / 25.2.1998 / 21:24:20 / cg"
! !

!AbstractLauncherApplication methodsFor:'private - settings callBacks'!

changeViewStyleTo:newStyle

    newStyle notNil ifTrue:[
        self withWaitCursorDo:[
            (transcript ? Transcript) showCR:'change style to ' , newStyle , ' ...'.
            View defaultStyle:newStyle asSymbol.
        ].
        self reopenLauncher.
        DebugView newDebugger.
    ]

!

fontBoxForEncoding:encodingMatch
    "open a fontBox, showing fonts which match some encoding
     (used when changing to japanese ...)"

    ^ LauncherDialogs fontBoxForEncoding:encodingMatch

"/    |box y b
"/     labelDef buttonDef listDef menuDef textDef
"/     models labels allOfThem filter|
"/
"/    encodingMatch notNil ifTrue:[
"/        filter := [:f | f encoding notNil 
"/                        and:[encodingMatch match:f encoding]].
"/    ].
"/
"/    models := OrderedCollection new.
"/    labels := OrderedCollection new.
"/
"/    models add:(allOfThem := nil asValue).
"/    models add:(labelDef := Label defaultFont asValue).
"/    models add:(buttonDef := Button defaultFont asValue).
"/    models add:(listDef := SelectionInListView defaultFont asValue).
"/    models add:(menuDef := MenuView defaultFont asValue).
"/    models add:(textDef := TextView defaultFont asValue).
"/
"/    box := Dialog new.
"/    box label:(resources string:'Font settings').
"/
"/    models
"/    with:(resources array:#('all' 'labels' 'buttons' 'lists' 'menus' 'edit text'))
"/    do:[:model :title |
"/        |y2 lbl f i|
"/
"/        f := model value.
"/
"/        (box addTextLabel:title) adjust:#left.
"/
"/        y := box yPosition.
"/        b := box addComponent:(Button label:(resources string:'change ...')) tabable:true.
"/        b relativeExtent:nil; extent:(b preferredExtent).
"/        y2 := box yPosition.
"/        box yPosition:y.
"/        i := box leftIndent.
"/        box leftIndent:(b widthIncludingBorder + View viewSpacing).
"/        (lbl := box addTextLabel:'')
"/            adjust:#left;
"/            font:(model value);
"/            labelChannel:(BlockValue 
"/                            with:[:v | |f|
"/                                f := v value.
"/                                f isNil ifTrue:[
"/                                    ''
"/                                ] ifFalse:[
"/                                    f userFriendlyName
"/                                ]
"/                            ]
"/                            argument:model).
"/        labels add:lbl.
"/
"/        box leftIndent:i.
"/        box yPosition:(box yPosition max:y2).
"/        box addVerticalSpace.
"/        box addHorizontalLine.
"/        box addVerticalSpace.
"/
"/        b action:[
"/            |f|
"/
"/            f := FontPanel 
"/                fontFromUserInitial:(model value) 
"/                              title:(resources string:'font for %1' with:title)
"/                             filter:filter.
"/            f notNil ifTrue:[
"/                model == allOfThem ifTrue:[
"/                    models do:[:m | m value:f].
"/                    labels do:[:l | l font:f]
"/                ] ifFalse:[
"/                    model value:f.  
"/                    lbl font:f.
"/                ].
"/            ]
"/        ].
"/        model == allOfThem ifTrue:[
"/            box addVerticalSpace
"/        ]
"/    ].
"/
"/    box addAbortButton; addOkButton.
"/    (box addButton:(Button label:(resources string:'defaults')) before:nil)
"/        action:[
"/            "/ fetch defaults
"/            View readStyleSheetAndUpdateAllStyleCaches.
"/            labelDef value: Label defaultFont.
"/            buttonDef value: Button defaultFont.
"/            listDef value: SelectionInListView defaultFont.
"/            menuDef value: MenuView defaultFont.
"/            textDef value: TextView defaultFont.
"/        ].
"/
"/    box open.
"/    box accepted ifTrue:[
"/        Label defaultFont:labelDef value.
"/        Button defaultFont:buttonDef value.
"/        Toggle defaultFont:buttonDef value.
"/        SelectionInListView defaultFont:listDef value.
"/        MenuView defaultFont:menuDef value.
"/        PullDownMenu defaultFont:menuDef value.
"/        TextView defaultFont:textDef value.
"/        EditTextView defaultFont:textDef value.
"/        CodeView defaultFont:textDef value.
"/    ].
"/    box destroy.
"/    ^ box accepted

    "Modified: / 15.9.1998 / 22:04:56 / cg"
!

reopenLauncher
    "reopen a new launcher.
     for now (since style & language settings currently do
     not affect living views ...)
     WARNING: bad design: Message known in LauncherDialogs"

    |oldOrigin contents builder newLauncher|

    oldOrigin := self window origin.
    transcript notNil ifTrue:[contents := transcript endEntry; list].
    builder := self class openAt:oldOrigin.
    builder window waitUntilVisible; origin:oldOrigin.
    newLauncher := builder application.
    transcript notNil ifTrue:[
        newLauncher transcript list:contents; hideCursor; scrollToBottom; cursorToEnd; showCursor.
    ].
    ^ newLauncher

    "Modified: / 4.8.1998 / 17:08:33 / cg"
! !

!AbstractLauncherApplication methodsFor:'queries'!

bugReporterAvailable
    ^ BugGUI notNil
!

hasPDALauncher
    ^ PDALauncher notNil
!

processName
    "for monitors only - my name"

    ^ 'ST/X Launcher'

!

remoteImageBrowserAvailable
    ^ SmalltalkShareClient notNil and:[RemoteImage notNil]
!

transcript
    "my transcript"

    transcript isNil ifTrue:[
        ^ Transcript current
    ].
    ^ transcript 
! !

!AbstractLauncherApplication methodsFor:'startup / release'!

addTopViewsToCurrentProject
    "ignored here - the launcher is always global (i.e. not project private)."

    ^ self

!

closeDownViews
    OpenLaunchers remove:self ifAbsent:nil.
    super closeDownViews
!

postBuildWith:aBuilder
    super postBuildWith:aBuilder.

    OpenLaunchers isNil ifTrue:[
        OpenLaunchers := IdentitySet new.
    ].
    OpenLaunchers add:self

!

requestForWindowClose
    "close request from windowing system (window close);
     confirm and ask if closing of launcher only or
     a smalltalk-exit is wanted"

    |answer|

    answer := Dialog 
                confirmWithCancel:(resources string:'Close %1 only or Exit Smalltalk (Close all) ?' with:self class name)
                labels:(resources array:#('Cancel' 'Close' 'Exit'))
                default:3.
    answer isNil ifTrue:[
        "/ cancel
        ^ false
    ].

    answer == false ifTrue:[
        ^ true
    ].

    self exit

    "Modified: / 20.5.1999 / 17:24:47 / cg"
!

saveAndTerminateRequest
    "some windowManagers can send this, to shutDown an application
     but let it save its state before, for later restart. 
     Although I have not yet encountered such a windowManager,
     we are already prepared for this ;-)"

    self snapshot.
    super saveAndTerminateRequest

! !

!AbstractLauncherApplication methodsFor:'user actions - about'!

openLicenseConditions
    "open an HTML browser on the 'LICENCE' document"

    self withWaitCursorDo:[
	|lang doc|

	Smalltalk releaseIdentification = 'ST/X_free_demo_vsn' ifTrue:[
	    doc := 'english/LICENCE_DEMO_STX.html'
	] ifFalse:[
	    ((lang := Smalltalk language) = 'de'
	    or:[lang = 'german']) ifTrue:[
		doc := 'german/LICENCE_STX.html'
	    ] ifFalse:[
		doc := 'english/LICENCE_STX.html'
	    ].
	].
	doc := resources at:'LICENCEFILE' default:doc.
	self showDocumentation:('../' , doc)
    ]

    "Created: / 5.2.1998 / 21:43:19 / cg"
    "Modified: / 23.4.1998 / 11:45:53 / cg"
! !

!AbstractLauncherApplication methodsFor:'user actions - classes'!

browseAllBreakAndTracePoints
    "open a browser showing all breakPointed/traced methods
     (but, to get rid of them, there is also a menu itme to remove them all)"

    UserPreferences systemBrowserClass
        browseMethods:(WrappedMethod allInstances)
        title:'all breakPointed/traced methods'
!

browseImplementors
    "open an implementors- browser after asking for a selector"

    |selector|

    selector := Dialog 
                    requestSelector:(resources at:'Browse implementors of (Tab for completion):') 
                    okLabel:(resources at:'Browse')
                    initialAnswer:''.

    selector size > 0 ifTrue:[
        self withWaitCursorDo:[
            UserPreferences systemBrowserClass browseImplementorsMatching:selector
        ]  
    ].

    "Modified: / 17.11.2001 / 16:33:28 / cg"
!

browseResources
    "open a resource- browser after asking for a resource string"

    |box resourceHolder valueHolder component rsrc value t anyString|

    anyString := resources string:'* any *'.

    resourceHolder := ValueHolder newString.
    valueHolder := '*' asValue.

    box := DialogBox new.
    box label:(resources at:'Resource search:').
    component := box addTextLabel:(resources at:'Search for methods which contain a\particular resource specification') withCRs.
    component adjust:#left.
    box addVerticalSpace:10.

    component := box addTextLabel:(resources at:'Resource symbol (empty for any; no matchPattern allowed):') withCRs.
    component adjust:#left.
    component :=  box addComboBoxOn:resourceHolder tabable:true.
    component list:((Array with:anyString) , #('canvas' 'menu' 'keyboard' 'style' 'image' 'programMenu' '-' 'obsolete' 'needsFix')).

    component := box addTextLabel:(resources at:'Resource value (* for any; matchPattern is allowed):') withCRs.
    component adjust:#left.
    box addInputFieldOn:valueHolder tabable:true.

    box addVerticalSpace:10.
    box addHelpButtonFor:'programming/language.html#RESOURCEDEFS'.
    box addAbortAndOkButtons.

    box open.
    box destroy.

    box accepted ifTrue:[
        rsrc := resourceHolder value.
        value := valueHolder value.

        (rsrc size == 0 or:[rsrc = '*' or:[rsrc = anyString]]) ifTrue:[
            t := 'methods with any resource'.
            rsrc := nil
        ] ifFalse:[
            t := 'methods with #' , rsrc , '-resource'.
            rsrc := rsrc withoutSeparators asSymbol
        ].
        (value size == 0 or:[value = '*']) ifTrue:[
            t := t , ' and any value'.
            value := nil
        ] ifFalse:[
            t := t , ' and value ' , value.
        ].
        self withWaitCursorDo:[
            UserPreferences systemBrowserClass
                browseForResource:rsrc
                containing:value
                in:(Smalltalk allClasses)
                title:t
        ]  
    ].
!

browseSenders
    "open a senders- browser after asking for a selector"

    |selector|

    selector := Dialog 
                    requestSelector:(resources at:'Browse senders of (Tab for completion):') 
                    okLabel:(resources at:'Browse')
                    initialAnswer:''.
    selector size > 0 ifTrue:[
        self withWaitCursorDo:[
            UserPreferences systemBrowserClass
                browseAllCallsOn:selector
        ]  
    ].

    "Modified: / 17.11.2001 / 16:33:42 / cg"
!

browseUnboundGlobals
    "open a browser on methods refering to unbound global variables"

    self withWaitCursorDo:[
        UserPreferences systemBrowserClass
            browseReferendsOfUnboundGlobalsWithTitle:(resources string:'References to unbound global variables')
            warnIfNone:true
    ]
!

browseUndeclared
    "open a browser on methods refering to undeclared variables"

    self withWaitCursorDo:[
        UserPreferences systemBrowserClass
            browseReferendsOf:(Smalltalk undeclaredPrefix , '*')
            title:(resources string:'References to undeclared variables')
            warnIfNone:true
    ]
!

clearUndeclaredVariables
    "remove all undeclared variables"

    Smalltalk clearUndeclaredVariables
!

removeAllBreakAndTracePoints
    "remove all break- and trace points"

    self withCursor:Cursor execute do:[ MessageTracer cleanup]

!

startClassBrowser
    "open a classBrowser; asks for class"

    UserPreferences systemBrowserClass askThenBrowseClass
!

startClassBrowserOnChangedClasses
    "open a classBrowser on the changeSet"

    NewSystemBrowser isNil ifTrue:[
        ^ self warn:'This needs the NewSystemBrowser to be loaded.'
    ].
    NewSystemBrowser openOnClassesInChangeSet
!

startClassBrowserOnChangedMethods
    "open a classBrowser on the changeSet"

    NewSystemBrowser isNil ifTrue:[
        ^ self warn:'This needs the NewSystemBrowser to be loaded.'
    ].
    NewSystemBrowser openOnMethodsInChangeSet
!

startClassBrowserOnChanges
    "open a classBrowser on the changeSet"

    ^ self startClassBrowserOnChangedClasses
!

startClassHierarchyBrowser
    "open a classHierarchyBrowser; asks for class"

    UserPreferences systemBrowserClass askThenBrowseClassHierarchy
!

startFullClassBrowser
    "open a fullClass systemBrowser; asks for class"

    UserPreferences systemBrowserClass askThenBrowseFullClassProtocol
!

startRemoteImageBrowser
    "open a remoteImage browser; asks for hostname.
     The remote host must have an st/x running with remote browsing enabled.
     Sorry, for now, only the old browser can be used this way."

    |hostName|

    hostName := Dialog request:'Remote Host:'.
    SystemBrowser openOnRemoteImageOnHost:hostName port:nil.
!

startSnapshotImageBrowser
    "open a snapshotImage browser; asks for filename.
     Sorry, for now, only the old browser can be used this way."

    |imageFileName|

    imageFileName := Dialog requestFileName:'Name of Snapshot Image File:' default:'st.img' pattern:'*.img;*.sav'.
    SystemBrowser openOnSnapShotImage:imageFileName
! !

!AbstractLauncherApplication methodsFor:'user actions - demos'!

startPDALauncher
    self startRemoteLauncherWithSetup:[:newDisplay | newDisplay bePDA].
!

startRemoteLauncher
    self startRemoteLauncherWithSetup:[:newDisplay | ].
!

startRemoteLauncherWithSetup:aSetupBlock
    |host remoteDisplay remoteDisplayClass|

    host := Dialog 
                request:(resources string:'Remote Launcher on which display:')
                initialAnswer:'{hostName}:0'
                initialSelection:(1 to:10).
    host size > 0 ifTrue:[
        (host includes:$:) ifFalse:[
            host := (host , ':0')
        ].

        remoteDisplayClass := XWorkstation.

"/        "/ Q: should we allow GL graphics on the remote display
"/        "/ (Problem: the GL library is not threadsafe, when multiple-display connections
"/        "/ are open - leading to mixing output between views ...)
"/
"/        "/ only simulated GL can be done remote (i.e. not on SGI)
"/        (Screen current supportsGLDrawing 
"/        and:[Screen current isTrueGL not])
"/        ifTrue:[
"/            remoteDisplayClass := GLXWorkstation.
"/        ].

        [
            remoteDisplay := remoteDisplayClass newDispatchingFor:host.
        ] on:Screen deviceOpenErrorSignal do:[:ex|
            self warn:'Could not connect to display: ''' , host , '''.'.
            ^ self
        ].
        aSetupBlock value:remoteDisplay.
        Screen currentScreenQuerySignal 
            answer:remoteDisplay
            do:[
                self class open.
            ]
    ].

    "Created: / 10.9.1998 / 11:48:42 / cg"
! !

!AbstractLauncherApplication methodsFor:'user actions - file'!

objectModuleDialog
    "opens a moduleInfo dialog"

    ^ LauncherDialogs objectModuleDialog

    "Modified: / 31.7.1998 / 17:33:24 / cg"
!

packageDialog
    "opens a package dialog"

    ^ LauncherDialogs packageDialog

    "Modified: / 31.7.1998 / 17:33:24 / cg"
!

saveImageAs: aFileName
    "save image in aFilename"

    aFileName notNil ifTrue:[
        self withCursor:Cursor write do:[
            (ObjectMemory snapShotOn:aFileName) ifFalse:[
                self warn:('Failed to save snapshot image (disk full or not writable)').
            ]
        ].
    ].
! !

!AbstractLauncherApplication methodsFor:'user actions - help'!

showBookPrintDocument
    "open an HTML browser on the 'book'-printing document"

    self showDocumentation:'BOOK.html'
!

startClassDocumentation
    "open an HTML browser on the 'classDoc/TOP' document"

    self showDocumentation:'classDoc/TOP.html'

!

startDocumentationIndex
    "open an HTML browser on the 'index' document"

    self showDocumentation:'index.html'
!

startDocumentationTool
    "open an HTML browser on the 'TOP' document"

    self showDocumentation:'TOP.html'

!

startWhatsNewDocumentation
    "open an HTML browser on the 'whatsNew.html' document"

    self showDocumentation:'whatsNew.html'

!

startWhatsNewSTX
    "open an HTML browser on the 'relNotes.html' document"

    self showDocumentation:'newFeatures.html'

! !

!AbstractLauncherApplication methodsFor:'user actions - settings'!

communicationsSettings
    "open a dialog on misc other settings"

    self settingsDialog:[:handler | handler communicationsSettings]

    "Modified: / 31.7.1998 / 22:46:56 / cg"
!

compilerSettings
    "open a dialog on compiler related settings"

    self settingsDialog:[:handler | handler compilerSettings]
!

displaySettings
    "open a dialog on display related settings"

    self settingsDialog:[:handler | handler displaySettings]

    "Modified: / 31.7.1998 / 22:45:38 / cg"
!

editSettings
    "open a dialog on edit settings"

    self settingsDialog:[:handler | handler editSettings]

    "Modified: / 31.7.1998 / 22:46:56 / cg"
    "Created: / 6.1.1999 / 14:14:48 / cg"
!

fontSettings
    "open a dialog on font related settings"

    self settingsDialog:[:handler | handler fontSettingsFor:self]

    "Modified: / 31.7.1998 / 22:45:44 / cg"
!

javaSettings
    "open a dialog on java-subsystem related settings"

    self settingsDialog:[:handler | handler javaSettings]

    "Modified: / 31.7.1998 / 22:46:13 / cg"
!

keyboardSetting 
    "open a dialog on keyboard related settings"

    self settingsDialog:[:handler | handler keyboardSettings]

    "Modified: / 31.7.1998 / 22:45:56 / cg"
!

languageSetting 
    "open a dialog on language related settings"

    self settingsDialog:[:handler | handler languageSettingsFor:self]

    "Modified: / 31.7.1998 / 22:46:13 / cg"
!

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.
        self reOpen
    ].
!

memorySettings
    "open a dialog on objectMemory related settings"

    self settingsDialog:[:handler | handler memorySettings]

    "Modified: / 31.7.1998 / 22:46:33 / cg"
!

messageSettings
    "open a dialog on infoMessage related settings"

    self settingsDialog:[:handler | handler messageSettings]

    "Modified: / 31.7.1998 / 22:46:45 / cg"
!

miscSettings
    "open a dialog on misc other settings"

    self settingsDialog:[:handler | handler miscSettings]

    "Modified: / 31.7.1998 / 22:46:56 / cg"
!

printerSettings
    "open a dialog on printer related settings"

    self settingsDialog:[:handler | handler printerSettings]

    "Modified: / 31.7.1998 / 22:47:05 / cg"
!

saveSettings
    "save settings to a settings-file."

    self settingsDialog:[:handler | handler saveSettings]

    "Modified: / 31.7.1998 / 22:48:38 / cg"
!

settingsDialog:symbolOrBlock 
    "open a dialog on viewStyle related settings"

    |handler|

    RegisteredMenuHandlers notNil ifTrue:[
        handler := RegisteredMenuHandlers at:symbolOrBlock ifAbsent:nil.
    ].
    handler isNil ifTrue:[
        handler := LauncherDialogs
    ].
    symbolOrBlock isBlock ifTrue:[
        symbolOrBlock value:handler
    ] ifFalse:[
        handler perform:symbolOrBlock with:self.
    ]

    "Modified: / 31.7.1998 / 22:47:33 / cg"
!

sourceAndDebuggerSettings
    "open a dialog on misc other settings"

    self settingsDialog:[:handler | handler sourceAndDebuggerSettings]

    "Modified: / 31.7.1998 / 22:47:21 / cg"
!

toolSettings
    "open a dialog on tool settings"

    self settingsDialog:[:handler | handler toolSettings]

    "Modified: / 31.7.1998 / 22:46:56 / cg"
    "Created: / 13.10.1998 / 15:50:53 / cg"
!

viewStyleSetting 
    "open a dialog on viewStyle related settings"

    self settingsDialog:[:handler | handler viewStyleSettingsFor:self]

    "Modified: / 31.7.1998 / 22:47:33 / cg"
! !

!AbstractLauncherApplication methodsFor:'user actions - system'!

compressingGarbageCollect
    "perform a compressing garbageCollect"

    self withWaitCursorDo:[ObjectMemory verboseGarbageCollect]

!

garbageCollect
    "perform a non-compressing garbageCollect"

    self withWaitCursorDo:[ObjectMemory reclaimSymbols]

!

startStopEventTrace
    "start/stop event tracing for a particular view"

    |v wg|

    v := Screen current viewFromUser.
    v notNil ifTrue:[
	v := v topView.
	wg := v windowGroup.
	wg notNil ifTrue:[
	    "/
	    "/ toggle eventTrace in its windowGroup
	    "/
	    wg traceEvents:(wg preEventHook isNil)
	]
    ]

! !

!AbstractLauncherApplication methodsFor:'user actions - tools'!

inspectGlobalVariables
    "inspect globals"

    Smalltalk inspect
!

inspectWorkspaceVariables
    "inspect workspace variables"

    Workspace workspaceVariables inspect
!

newProject 
    "creates a new project & opens a projectView for it"

    Project notNil ifTrue: [(ProjectView for: Project new) open]
!

openTerminal
    self openApplication:#VT100TerminalView 

    "Created: / 27.7.1998 / 12:48:30 / cg"
!

openWorkspace
    WorkspaceApplication notNil ifTrue:[
        ^ WorkspaceApplication open
    ].
    ^ self openApplication:Workspace
!

removeAllWorkspaceVariables
    "remove workspace variables"

    Workspace removeAllWorkspaceVariables
!

selectProject
    "asks for and switch to another project"

    |list box|

    Project notNil ifTrue:[
        list := Project allInstances.
        box := ListSelectionBox new.
        box list:(list collect:[:p | p name]).
        box title:(resources string:'select a project').
        box action:[:selection |
            |project|

            project := list detect:[:p | p name = selection] ifNone:[nil].
            project isNil ifTrue:[
                transcript notNil ifTrue:[
                    transcript showCR:'no such project.'
                ]
            ] ifFalse:[
                project showViews.
                Project current:project
            ]
        ].
        box open.
        box destroy
    ]
!

startBugMessages
    "open the SUnit test runner"

    self openApplication:#BugGUI

    "Modified: / 17.10.1998 / 14:38:18 / cg"
!

startChangeSetBrowser
    "open a change Set Browser"

    ChangeSetBrowser open

    "Created: / 5.11.2001 / 18:04:05 / cg"
!

startChangesBrowser
    "open a changebrowser - either new or old GUI, depending on userPrefs"

    self openApplication:(UserPreferences current changesBrowserClass)

    "Modified: / 17.10.1998 / 14:38:18 / cg"
!

startNewChangesBrowser
    "opens the new changeBrowser"

    self openApplication:#NewChangesBrowser

    "Created: / 6.6.1998 / 19:47:26 / cg"
!

startNewLauncher
    "opens the new launcher"

    NewLauncher isNil ifTrue:[
	^ self warn:'The NewLauncher is not available in this release.'
    ].
    NewLauncher openAt:(self window origin)

!

startOldChangesBrowser
    "opens the old changeBrowser"

    self openApplication:#ChangesBrowser

    "Created: / 6.6.1998 / 19:47:26 / cg"
!

startOldLauncher
    "opens the old launcher"

    Launcher isNil ifTrue:[
	^ self warn:'The (Old)Launcher is not available in this release.'
    ].
    Launcher openAt:(self window origin)

!

startSUnitTestRunner
    "open the SUnit test runner"

    self openApplication:#TestRunner

    "Modified: / 17.10.1998 / 14:38:18 / cg"
! !

!AbstractLauncherApplication methodsFor:'user actions - windows'!

askForAnotherDisplay
    "ask for some other display"

    |displayName|

    displayName := Dialog request:'Display:' initialAnswer:(Screen default displayName).
    displayName size == 0 ifTrue:[^ nil].

    ^ XWorkstation newDispatchingFor:displayName.
!

deIconifyAllWindows
    |setOfViews currentScreen|

    setOfViews := Project current views asIdentitySet.
    setOfViews addAll:(Project defaultProject views).

    currentScreen := Screen current.
    setOfViews do:[:aTopView |
	aTopView device == currentScreen ifTrue:[
	    aTopView expand
	].
    ].

    "
     Transcript topView application deIconifyAllWindows
    "

!

findAndDestroyWindow
    "find a window (by name) and destroy it"

    |v|
    v := self findWindow:'select view to close:'.
    v notNil ifTrue:[v destroy]

!

findAndMigrateWindow
    "find a window (by name) and migrate it to some other display"

    |possibleGroups v|

    possibleGroups := WindowGroup allInstances select:[:eachGroup |
                                        eachGroup graphicsDevice == Screen current
                                        and:[eachGroup isModal not
                                        and:[eachGroup topViews size > 0]]].
    possibleGroups size == 0 ifTrue:[
        self information:'No windows found which could be migrated to some other display.'.
        ^ self
    ].

    v := self findWindow:'Select view to migrate:' windowGroupFilter:possibleGroups.
    v notNil ifTrue:[
        self migrateWindow:v topView
    ]
!

findAndMigrateWindowBack
    "find a window (by name) and migrate it back to this display"

    |possibleGroups v|

    possibleGroups := WindowGroup allInstances select:[:eachGroup |
                                        eachGroup graphicsDevice ~~ Screen current
                                        and:[eachGroup isModal not
                                        and:[eachGroup topViews size > 0]]].
    possibleGroups size == 0 ifTrue:[
        self information:'No windows are open on any other display.'.
        ^ self
    ].
        
    v := self findWindow:'Select view to migrate back:' windowGroupFilter:possibleGroups.
    v notNil ifTrue:[
        v windowGroup migrateTo:(Screen current)
    ]
!

findAndRaiseWindow
    "find a window (by name) and raise it"

    |v|

    v := self findWindow:'select view to raise deiconified:'.
    v notNil ifTrue:[v raiseDeiconified]

!

fullScreenHardcopy
    "after a second (to allow redraw of views under menu ...),
     save the contents of the whole screen."

    self window sensor ctrlDown ifTrue:[
        ^ self fullScreenHardcopyUngrabbed
    ].

    Processor 
        addTimedBlock:[
                        self 
                            saveScreenImage:(Image fromScreen) 
                            defaultName:'screen'
                      ] 
        afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
!

fullScreenHardcopyUngrabbed
    "after a second (to allow redraw of views under menu ...),
     save the contents of the whole screen."

    Processor 
        addTimedBlock:[
                        |display image|

                        display := Screen current.
                        image := Image 
                            fromScreen:(0@0 corner:(display extent))
                            on:display
                            grab:false.

                        self 
                            saveScreenImage:image 
                            defaultName:'screen'
                      ] 
        afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
!

iconifyAllWindows
    |setOfViews currentScreen|

    setOfViews := Project current views asIdentitySet.
    setOfViews addAll:(Project defaultProject views).

    currentScreen := Screen current.
    setOfViews do:[:aTopView |
	aTopView device == currentScreen ifTrue:[
	    aTopView collapse
	]
    ]

!

migrateAllWindows
    "migrate all views to some other display"

    |anotherDisplay toMigrate|

    [
        anotherDisplay := self askForAnotherDisplay.
        anotherDisplay isNil ifTrue:[
            ^ self.
        ].
    ] on:Screen deviceOpenErrorSignal do:[:ex|
        ^ self warn:'cannot open display: ', ex parameter.
    ].

    toMigrate := WindowGroup allInstances 
        select:[:each | each graphicsDevice == Screen current
                        and:[each topViews size > 0
                        and:[each isModal not]]
               ].
    toMigrate do:[:eachGroup |
        eachGroup migrateTo:anotherDisplay
    ]
!

migrateWindow:aWindow
    "migrate a view to some other display"

    aWindow windowGroup isModal ifTrue:[
        self warn:'Sorry - I cannot migrate a modalBox; please migrate the owning View.'.
        ^ self
    ].
    self migrateWindow:aWindow withBackOption:(self confirm:'Show ''Return Back'' Button on the other display ?')

!

migrateWindow:aWindow withBackOption:withBackOption
    "migrate a view to some other display"

    |anotherDisplay wg here b|

    aWindow isTopView ifFalse:[
        self information:'Cannto migrate this view'.
        ^ self
    ].

    [
        anotherDisplay := self askForAnotherDisplay.
        anotherDisplay isNil ifTrue:[
            ^ self.
        ].
    ] on:Screen deviceOpenErrorSignal do:[:ex|
        ^ self warn:'cannot open display: ', ex parameter.
    ].

    wg := aWindow windowGroup.
    wg migrateTo:anotherDisplay.

    withBackOption ifTrue:[
        here := Screen current.
        b := Button onDevice:anotherDisplay.
        b label:'Return window back to ' , here displayName.
        b action:[ wg migrateTo:here. b destroy. ].
        b origin:0@0.
        b open.
    ].
!

screenHardcopy
    "after a second (to allow redraw of views under menu ...),
     let user specify a rectangular area on the screen
     and save its contents."

    |area|

    Processor 
        addTimedBlock:[
                        [Screen current leftButtonPressed] whileTrue:[Delay waitForSeconds:0.05].

                        area := Rectangle fromUser.
                        (area width > 0 and:[area height > 0]) ifTrue:[
                            Delay waitForSeconds:2.
                            self saveScreenImage:(Image fromScreen:area) defaultName:'hardcopy'
                        ]
                      ] 
        afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)

    "Modified: / 18.8.1998 / 15:00:42 / cg"
!

startWindowTreeView
    "open a windowTree (on a picked topView)"

    |v|

    WindowTreeView isNil ifTrue:[
        ^ self warn:'The WindowTreeView is not available in this release.'
    ].

    v := self pickAView.
    v notNil ifTrue:[
        WindowTreeView openOn:v topView
    ]

!

startWindowTreeViewForAll
    "open a windowTree on all views in the system"

    |v|

    WindowTreeView isNil ifTrue:[
        ^ self warn:'The WindowTreeView is not available in this release.'
    ].

    WindowTreeView openOnAll

!

viewDestroy
    "let user pick a view and destroy it.
     Even allow destroying non-smalltalk views
     (also for views which I forgot due to some error)"

    |device v id i c|

    (Delay forSeconds:1) wait.

    device := Screen current.
    i := Image fromFile:'bitmaps/xpmBitmaps/cursors/cross2.xpm'.
    i isNil ifTrue:[
	c := Cursor crossHair
    ] ifFalse:[
	c := Cursor fromImage:i
    ].
    id := device viewIdFromPoint:(device pointFromUserShowing:c).
    (v := device viewFromId:id) notNil ifTrue:[
	v topView destroy.
	^ self
    ].
    id = device rootView id ifTrue:[
	^ self
    ].
    (Dialog confirm:'mhmh, this may not a be smalltalk view\(Or I somehow forgot about it).\Destroy anyway ?' withCRs)
    ifTrue:[
	device destroyView:nil withId:id
    ].


!

viewHardcopy
    "after a second (to allow redraw of views under menu ...),
     let user specify a view and save its contents."

    Processor 
        addTimedBlock:[
                        |v|
                        (v := Screen current viewFromUser) notNil ifTrue:[
                            self saveScreenImage:(Image fromView:(v topView)) defaultName:'hardcopy'
                        ]
                      ] 
        afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
!

viewInspect
    "let user pick a view and inspect it. Only smalltalk views are allowed"

    |v|

    (v := self pickAView) notNil ifTrue:[
	v inspect
    ]

!

viewMigrate
    "let user pick a view and migrate it to some other display"

    |v|

    (v := self pickAView) notNil ifTrue:[
        self migrateWindow:v topView
    ]
! !

!AbstractLauncherApplication::KbdMappingSettingsAppl 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:AbstractLauncherApplication::KbdMappingSettingsAppl andSelector:#windowSpec
     AbstractLauncherApplication::KbdMappingSettingsAppl new openInterface:#windowSpec
     AbstractLauncherApplication::KbdMappingSettingsAppl open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: 'Keyboard Mappings'
          #name: 'Keyboard Mappings'
          #min: #(#Point 10 10)
          #max: #(#Point 1024 768)
          #bounds: #(#Rectangle 16 42 491 620)
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#VariableVerticalPanelSpec
              #name: 'VariableVerticalPanel1'
              #layout: #(#LayoutFrame 0 0.0 60 0 0 1.0 -34 1)
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#VariableHorizontalPanelSpec
                    #name: 'VariableHorizontalPanel1'
                    #component: 
                   #(#SpecCollection
                      #collection: #(
                       #(#SequenceViewSpec
                          #name: 'RawKeyList'
                          #model: #selectedRawKey
                          #hasHorizontalScrollBar: true
                          #hasVerticalScrollBar: true
                          #useIndex: false
                          #sequenceList: #rawKeyList
                        )
                       #(#SequenceViewSpec
                          #name: 'FunctionKeyList'
                          #model: #selectedFunctionKey
                          #hasHorizontalScrollBar: true
                          #hasVerticalScrollBar: true
                          #useIndex: false
                          #sequenceList: #functionKeyList
                        )
                       )
                     
                    )
                    #handles: #(#Any 0.5 1.0)
                  )
                 #(#ViewSpec
                    #name: 'Box1'
                    #component: 
                   #(#SpecCollection
                      #collection: #(
                       #(#TextEditorSpec
                          #name: 'MacroText'
                          #layout: #(#LayoutFrame 0 0.0 20 0 0 1.0 0 1.0)
                          #model: #macroTextHolder
                          #hasHorizontalScrollBar: true
                          #hasVerticalScrollBar: true
                          #isReadOnly: true
                        )
                       #(#LabelSpec
                          #label: 'Macro text (if any):'
                          #name: 'MacroTextLabel'
                          #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 20 0)
                          #translateLabel: true
                          #adjust: #left
                        )
                       )
                     
                    )
                  )
                 )
               
              )
              #handles: #(#Any 0.5 1.0)
            )
           #(#HorizontalPanelViewSpec
              #name: 'HorizontalPanel1'
              #layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
              #horizontalLayout: #center
              #verticalLayout: #center
              #horizontalSpace: 3
              #verticalSpace: 3
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'Close'
                    #name: 'Cancel'
                    #visibilityChannel: #isNotPartOfSettinsDialog
                    #translateLabel: true
                    #model: #doCancel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Help'
                    #name: 'Help'
                    #translateLabel: true
                    #model: #help
                    #extent: #(#Point 125 22)
                  )
                 )
               
              )
            )
           #(#LabelSpec
              #label: 'NoticeText'
              #name: 'Text'
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 60 0)
              #translateLabel: true
              #labelChannel: #labelTextHolder
              #resizeForLabel: true
              #adjust: #left
            )
           )
         
        )
      )
! !

!AbstractLauncherApplication::KbdMappingSettingsAppl methodsFor:'actions'!

doCancel

    self isPartOfSettinsDialog ifTrue:[
        self loadRequest.
    ].
    self closeRequest.
!

evaluateModified

    self modifiedChannel value:(self hasUnsavedChanges).
!

help

    self withWaitCursorDo:[HTMLDocumentView openFullOnHelpFile:'Launcher/keyboardSetting.html'].
!

loadRequest

    self modifiedChannel value:false.
!

saveRequest
    | result |

    (self hasUnsavedChanges) ifTrue:[
        result := self confirmWithCancel:(resources string:'Save changed Tool Settings ?'). 
        result isNil ifTrue:[ ^ false].
        result ifTrue:[
            self saveSettings.
        ] 
    ].
    ^ true
!

saveSettings
! !

!AbstractLauncherApplication::KbdMappingSettingsAppl methodsFor:'aspects'!

functionKeyList
    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    functionKeyList isNil ifTrue:[
        functionKeyList := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       functionKeyList addDependent:self.
"/       functionKeyList onChangeSend:#functionKeyListChanged to:self.
    ].
    ^ functionKeyList.
!

labelTextHolder
    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    labelTextHolder isNil ifTrue:[
        labelTextHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       labelTextHolder addDependent:self.
"/       labelTextHolder onChangeSend:#labelTextHolderChanged to:self.
    ].
    ^ labelTextHolder.
!

macroTextHolder
    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    macroTextHolder isNil ifTrue:[
        macroTextHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       macroTextHolder addDependent:self.
"/       macroTextHolder onChangeSend:#macroTextHolderChanged to:self.
    ].
    ^ macroTextHolder.
!

modifiedChannel

    modifiedChannel isNil ifTrue:[
        modifiedChannel := false asValue.
    ].
    ^ modifiedChannel
!

rawKeyList
    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    rawKeyList isNil ifTrue:[
        rawKeyList := List new.
    ].
    ^ rawKeyList.
!

selectedFunctionKey

    selectedFunctionKey isNil ifTrue:[
        selectedFunctionKey := ValueHolder new.
        selectedFunctionKey addDependent:self.
    ].
    ^ selectedFunctionKey.
!

selectedRawKey

    selectedRawKey isNil ifTrue:[
        selectedRawKey := ValueHolder new.
        selectedRawKey addDependent:self.
    ].
    ^ selectedRawKey.
! !

!AbstractLauncherApplication::KbdMappingSettingsAppl methodsFor:'change & update'!

changeFunctionKeySelection

    |raw|
    raw := self selectedRawKey value.
    self selectedFunctionKey value:(mappings at:raw asSymbol) asString.
!

changeMacroText

    |f macro indent|

    f := self selectedFunctionKey value.
    (f startsWith:'Cmd') ifTrue:[
        f := f copyFrom:4
    ].
    macro := UserPreferences current functionKeySequences 
                at:(f asSymbol) ifAbsent:nil.
    macro notNil ifTrue:[
        macro := macro asStringCollection.
        indent := macro
                     inject:99999 into:[:min :element |
                         |stripped|

                         stripped := element withoutLeadingSeparators.
                         stripped size == 0 ifTrue:[
                             min
                         ] ifFalse:[
                             min min:(element size - stripped size)
                         ]
                     ].
        indent ~~ 0 ifTrue:[
            macro := macro collect:[:line | 
                         line size > indent ifTrue:[
                            line copyFrom:indent+1
                         ] ifFalse:[
                            line
                         ].
                    ]
        ].                        
    ].
    macroTextHolder value:macro.
!

changeRawKeySelection
    |f raw|

    f := self selectedFunctionKey value.
    raw := mappings keyAtValue:f asString.
    raw isNil ifTrue:[
        raw := mappings keyAtValue:f first.
        raw isNil ifTrue:[
            raw := mappings keyAtValue:f asSymbol.
        ]
    ].
    self selectedRawKey value:raw.
!

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 selectedFunctionKey ifTrue:[
        self changeRawKeySelection.
        self changeMacroText.
        ^ self
    ].
    changedObject == self selectedRawKey ifTrue:[
        self changeFunctionKeySelection.
        ^ self
    ].
    super update:something with:aParameter from:changedObject
! !

!AbstractLauncherApplication::KbdMappingSettingsAppl methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

closeRequest

    self saveRequest ifFalse:[
        ^ self
    ].

    ^ super closeRequest.
!

initialize

    resources := self class owningClass classResources.
    
    mappings := Screen current keyboardMap.

    rawKeyList := (mappings keys asArray collect:[:key | key asString]) sort.
    functionKeyList := (mappings values asSet asArray collect:[:key | key asString]) sort.

    self labelTextHolder value:(resources at:'KEY_MSG2' default:'keyboard mapping:') withCRs.
    super initialize
! !

!AbstractLauncherApplication::KbdMappingSettingsAppl methodsFor:'queries'!

hasUnsavedChanges

    ^ false
! !

!AbstractLauncherApplication::LanguageSettingsAppl 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:AbstractLauncherApplication::LanguageSettingsAppl andSelector:#windowSpec
     AbstractLauncherApplication::LanguageSettingsAppl new openInterface:#windowSpec
     AbstractLauncherApplication::LanguageSettingsAppl open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: 'Language Settings'
          #name: 'Language Settings'
          #min: #(#Point 10 10)
          #max: #(#Point 1024 768)
          #bounds: #(#Rectangle 16 42 491 713)
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#InputFieldSpec
              #name: 'EntryField1'
              #layout: #(#LayoutFrame 0 0.0 105 0 0 1.0 125 0)
              #model: #languageHolder
              #acceptOnReturn: true
              #acceptOnTab: true
              #acceptOnLostFocus: true
              #acceptOnPointerLeave: false
            )
           #(#SequenceViewSpec
              #name: 'List1'
              #layout: #(#LayoutFrame 0 0.0 125 0 0 1.0 -34 1)
              #model: #languageHolder
              #hasHorizontalScrollBar: true
              #hasVerticalScrollBar: true
              #doubleClickSelector: #doubleClick:
              #useIndex: false
              #sequenceList: #languageList
            )
           #(#HorizontalPanelViewSpec
              #name: 'HorizontalPanel1'
              #layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1.0)
              #horizontalLayout: #center
              #verticalLayout: #center
              #horizontalSpace: 3
              #verticalSpace: 3
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'OK'
                    #name: 'OK'
                    #translateLabel: true
                    #model: #saveSettings
                    #enableChannel: #modifiedChannel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Cancel'
                    #name: 'Cancel'
                    #translateLabel: true
                    #model: #doCancel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Help'
                    #name: 'Help'
                    #translateLabel: true
                    #model: #help
                    #extent: #(#Point 125 22)
                  )
                 )
               
              )
            )
           #(#LabelSpec
              #label: 'Notice:'
              #name: 'Notice'
              #layout: #(#LayoutFrame 0 0 0 0 0 1.0 105 0)
              #translateLabel: true
              #labelChannel: #noticeLabelHolder
              #adjust: #left
            )
           #(#LabelSpec
              #label: 'Label'
              #name: 'CurrentLang'
              #layout: #(#LayoutFrame -150 1 0 0 0 1 20 0)
              #style: #(#FontDescription #helvetica #bold #roman 12)
              #translateLabel: true
              #labelChannel: #currentLanguageChannel
              #adjust: #left
            )
           #(#LabelSpec
              #label: 'Current Language:'
              #name: 'Label1'
              #layout: #(#LayoutFrame 190 0 0 0 -150 1 20 0)
              #translateLabel: true
              #labelChannel: #currentLanguageLabel
              #adjust: #right
            )
           )
         
        )
      )
! !

!AbstractLauncherApplication::LanguageSettingsAppl methodsFor:'accessing'!

languageList
    "return the value of the instance variable 'languageList' (automatically generated)"

    ^ languageList
!

requestor
    "return the value of the instance variable 'requestor' (automatically generated)"

    | masterApplication |
    masterApplication := self masterApplication.
    masterApplication notNil ifTrue:[
        ^ masterApplication requestor.
    ].
    ^ nil
! !

!AbstractLauncherApplication::LanguageSettingsAppl methodsFor:'actions'!

doCancel

    self isPartOfSettinsDialog ifTrue:[
        self loadRequest.
    ].
    self closeRequest.
!

doubleClick:aEntry

    self saveSettings.
!

evaluateModified

    self modifiedChannel value:(self hasUnsavedChanges).
!

help

    self withWaitCursorDo:[HTMLDocumentView openFullOnHelpFile:'Launcher/languageSetting.html'].
!

loadRequest

    self languageHolder value:self currentLanguage.
    self currentLanguageChannel value:self currentLanguage.
    self modifiedChannel value:false.
!

saveRequest
    | result |

    (self hasUnsavedChanges) ifTrue:[
        result := self confirmWithCancel:(resources string:'Save changed Language Settings ?'). 
        result isNil ifTrue:[ ^ false].
        result ifTrue:[
            self saveSettings.
        ] 
    ].
    ^ true
!

saveSettings

    |fontPref idx language oldLanguage territory enc 
     answer matchingFonts l screen newLanguage switch|

    newLanguage := self languageHolder value.
    self withWaitCursorDo:[
        idx := translatedLanguages indexOf:newLanguage.
        idx ~~ 0 ifTrue:[
            language := listOfLanguages at:idx
        ] ifFalse:[
            language := newLanguage
        ].
        (language includes:$-) ifTrue:[
            l := language asCollectionOfSubstringsSeparatedBy:$-.
            language := l at:1.
            territory := l at:2.
        ].
        territory isNil ifTrue:[
            territory := language copyTo:2
        ].

        "/ check if the new language needs a differently encoded font;
        "/ ask user to switch font and allow cancellation.
        "/ Otherwise, you are left with unreadable menu & button items ...

        oldLanguage := Smalltalk language.
        Smalltalk language:language asSymbol.
        ResourcePack flushCachedResourcePacks.
        "/ refetch resources ...
        resources := AbstractLauncherApplication classResources.
        fontPref := resources at:'PREFERRED_FONT_ENCODING' default:'iso8859*'.
        fontPref := fontPref asLowercase.    
        Smalltalk language:oldLanguage.

        switch := true.
        enc := MenuView defaultFont encoding.
        (fontPref match:enc asLowercase) ifFalse:[
            "/ look if there is one at all.
            screen := Screen current.
            matchingFonts := screen listOfAvailableFonts select:[:f | fontPref match:f encoding asLowercase].
            matchingFonts size == 0 ifTrue:[
                "/ flush and try again - just in case, the font path has changed.
                screen flushListOfAvailableFonts.
                matchingFonts := screen listOfAvailableFonts select:[:f | fontPref match:f encoding asLowercase].
            ].
            matchingFonts size == 0 ifTrue:[
                (Dialog 
                    confirm:(resources 
                                string:'Your display does not offer any %1-encoded font.\\Change the language anyway ?\ (texts will probably be unreadable then)'
                                  with:fontPref) withCRs)
                ifFalse:[
                    switch := false
                ]
            ] ifFalse:[
                answer := Dialog 
                            confirmWithCancel:(resources 
                                                    string:'menu font is not %1-encoded.\\Change it ?'
                                                    with:fontPref) withCRs
                                       labels:(resources
                                                    array:#('cancel' 'no' 'yes'))
                                       default:3.
                answer isNil ifTrue:[
                    switch := false
                ] ifFalse:[
                    answer ifTrue:[
                        switch := ( self requestor fontBoxForEncoding:fontPref)
                    ]
                ].
            ].
        ].

        switch ifTrue:[
            Transcript showCR:'change language to ' , newLanguage , ' ...'.
            Smalltalk language:language asSymbol.
            Smalltalk languageTerritory:territory asSymbol.
            "/ ResourcePack flushCachedResourcePacks - already done by language-change
        ].
    ].
    switch ifTrue:[
        self requestor notNil ifTrue:[
            self requestor reopenLauncher.
        ].
        DebugView newDebugger.
    ].
    self currentLanguageChannel value:self currentLanguage.
    self modifiedChannel value:false.
! !

!AbstractLauncherApplication::LanguageSettingsAppl methodsFor:'aspects'!

currentLanguageChannel

    currentLanguageChannel isNil ifTrue:[
        currentLanguageChannel := self currentLanguage asValue.
    ].
    ^ currentLanguageChannel.
!

currentLanguageLabel

    currentLanguageLabel isNil ifTrue:[
        currentLanguageLabel := (resources string:'Current Language:') asValue.
    ].
    ^ currentLanguageLabel.
!

languageHolder

    languageHolder isNil ifTrue:[
        languageHolder := self currentLanguage asValue.
        languageHolder onChangeSend:#evaluateModified to:self.
    ].
    ^ languageHolder.
!

modifiedChannel

    modifiedChannel isNil ifTrue:[
        modifiedChannel := false asValue.
    ].
    ^ modifiedChannel
!

noticeLabelHolder

    noticeLabelHolder isNil ifTrue:[
        noticeLabelHolder := ((resources at:'LANG_MSG' default:'Select a Language') withCRs) asValue.
    ].
    ^ noticeLabelHolder.
! !

!AbstractLauncherApplication::LanguageSettingsAppl methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

closeRequest

    self saveRequest ifFalse:[
        ^ self
    ].

    ^ super closeRequest.
!

initialize

    |flags|

    resources := self class owningClass classResources.
    listOfLanguages := resources at:'LIST_OF_OFFERED_LANGUAGES' default:#('default').
    listOfLanguages := listOfLanguages asOrderedCollection.
    translatedLanguages := listOfLanguages collect:[:lang | |item|
                                        item := resources at:lang.
                                        item isString ifTrue:[
                                            item
                                        ] ifFalse:[
                                            item at:1
                                        ]
                                ].
    flags := listOfLanguages collect:[:lang | |item|
                                        item := resources at:lang.
                                        item isArray ifTrue:[
                                            item at:2
                                        ] ifFalse:[
                                            nil
                                        ]
                                ].
    flags := flags collect:[:nm | |img d| nm notNil ifTrue:[
                                            img := Image fromFile:nm.
                                            img isNil ifTrue:[
                                                d := Smalltalk getPackageDirectoryForPackage:'stx:goodies'.
                                                img := Image fromFile:(d construct:nm).
                                            ].
                                        ] ifFalse:[
                                            nil
                                        ]
                           ].
    listOfLanguages := listOfLanguages collect:[:nm | nm copyFrom:'LANG_' size + 1].
    languageList := translatedLanguages with:flags collect:[:lang :flag | LabelAndIcon icon:flag string:lang.].
    super initialize
! !

!AbstractLauncherApplication::LanguageSettingsAppl methodsFor:'queries'!

currentLanguage

    | lang |

    lang := Language ~= LanguageTerritory ifTrue:[
        Language , '-' , LanguageTerritory
    ] ifFalse:[
        Language
    ].
    ^ languageList at:(listOfLanguages indexOf:lang)
!

hasUnsavedChanges

    ^ (self languageHolder value) ~= (self currentLanguage)  
! !

!AbstractLauncherApplication::LauncherDialogs class methodsFor:'dialogs'!

communicationsSettings
    "open a dialog on communications settings"

    |box check in resources y acceptChannel
     hasRDoitServer rDoitServerPort
     rDoitsEnabled rDoitLogging rDoitErrorLogging rDoitErrorDebugging 
     org_rDoitsEnabled org_rDoitLogging org_rDoitErrorLogging org_rDoitErrorDebugging org_rDoitServerPort

     hasRemoteBrowsingSupport remoteBrowsingEnabled org_remoteBrowsingEnabled

     hasWindowMigrationServer windowMigrationAuthenticate windowMigrationPassword
     windowMigrationEnabled  
     org_windowMigrationEnabled org_windowMigrationAuthenticate org_windowMigrationPassword

     hasHTTPServer httpServerRunning httpServerFileRoot httpServerHomeURL
     httpServerPort httpServerLogFile hasSwiki swikiEnabled swikiRoot
     allowEmbedded hasSoap soapEnabled
     org_httpServerRunning org_httpServerFileRoot org_httpServerHomeURL
     org_httpServerPort org_swikiRoot org_swikiEnabled org_httpServerLogFile
     org_allowEmbedded org_soapEnabled

     osiACSEPresent osiROSEPresent osiCMISEPresent
     osiACSEErrorLogging osiACSEConnectionLogging osiACSEDataLogging
     osiROSEErrorLogging osiROSEResponseLogging osiROSEInvokationLogging
     osiCMISEErrorLogging osiCMISEMessageLogging
    |

    acceptChannel := false asValue.

    resources := self owningClass classResources.

    "/ 
    "/ extract relevant remoteBrowsing settings ...
    "/
    remoteBrowsingEnabled := false.
    (hasRemoteBrowsingSupport := SmalltalkShareServer notNil) ifTrue:[
        SmalltalkShareServer isLoaded ifTrue:[
            remoteBrowsingEnabled := SmalltalkShareServer serverRunning.
        ].
    ].
    org_remoteBrowsingEnabled := remoteBrowsingEnabled.
    remoteBrowsingEnabled := remoteBrowsingEnabled asValue.

    "/ 
    "/ extract relevant windowMigration settings ...
    "/
    windowMigrationEnabled := windowMigrationAuthenticate := false.
    (hasWindowMigrationServer := WindowMigrationServer notNil) ifTrue:[
        WindowMigrationServer isLoaded ifTrue:[
            windowMigrationEnabled := WindowMigrationServer serverRunning.
        ].
        windowMigrationPassword := WindowMigrationServer password.
        windowMigrationAuthenticate := windowMigrationPassword notNil.
    ].
    org_windowMigrationEnabled := windowMigrationEnabled.
    windowMigrationEnabled := windowMigrationEnabled asValue.
    org_windowMigrationAuthenticate := windowMigrationAuthenticate.
    windowMigrationAuthenticate := windowMigrationAuthenticate asValue.
    org_windowMigrationPassword := windowMigrationPassword.
    windowMigrationPassword := windowMigrationPassword asValue.

    "/ 
    "/ extract relevant rdoit settings ...
    "/
    rDoitsEnabled := rDoitLogging := rDoitErrorLogging := false.
    (hasRDoitServer := RDoItServer notNil) ifTrue:[
        RDoItServer isLoaded ifTrue:[
            rDoitsEnabled := RDoItServer serverRunning.
            rDoitLogging := RDoItServer isLogging.
            rDoitErrorLogging := RDoItServer isErrorLogging.
            rDoitErrorDebugging := RDoItServer isErrorCatching not.
            rDoitServerPort := RDoItServer defaultPortNumber.
        ]
    ].
    org_rDoitsEnabled := rDoitsEnabled.
    org_rDoitLogging := rDoitLogging.
    org_rDoitErrorLogging := rDoitErrorLogging.
    org_rDoitErrorDebugging := rDoitErrorDebugging.
    org_rDoitServerPort := rDoitServerPort.

    rDoitServerPort := rDoitServerPort asValue.
    rDoitsEnabled := rDoitsEnabled asValue.
    rDoitLogging := rDoitLogging asValue.
    rDoitErrorLogging := rDoitErrorLogging asValue.
    rDoitErrorDebugging := rDoitErrorDebugging asValue.

    "/
    "/ extract http-server settings
    "/
    hasHTTPServer := httpServerRunning := false.
    (hasHTTPServer := HTTPServer notNil) ifTrue:[
        HTTPServer isLoaded ifTrue:[
            httpServerRunning := HTTPServer isRunning.
            httpServerFileRoot := HTTPServer fileRoot.
            httpServerHomeURL := HTTPServer homeURL.
            httpServerPort := HTTPServer defaultPort.
            httpServerLogFile := HTTPServer defaultLogFile.
        ].
    ].
    org_httpServerRunning := httpServerRunning.
    httpServerRunning := httpServerRunning asValue.
    org_httpServerFileRoot := httpServerFileRoot.
    httpServerFileRoot := httpServerFileRoot asValue.
    org_httpServerHomeURL := httpServerHomeURL.
    httpServerHomeURL := httpServerHomeURL asValue.
    org_httpServerPort := httpServerPort.
    httpServerPort := httpServerPort asValue.
    org_httpServerLogFile := httpServerLogFile.
    httpServerLogFile := httpServerLogFile asValue.

    httpServerRunning 
        onChangeEvaluate:[
            httpServerFileRoot value:(HTTPServer fileRoot).
            httpServerHomeURL value:(HTTPServer homeURL).
            httpServerPort value:(HTTPServer defaultPort).
            httpServerLogFile value:(HTTPServer defaultLogFile)
        ].

    hasSwiki := false.
    swikiEnabled := false.
    soapEnabled := false.

    (hasSwiki := PWS::SwikiAction notNil) ifTrue:[
        PWS::SwikiAction isLoaded ifTrue:[
            (HTTPServer notNil and:[HTTPServer isLoaded]) ifTrue:[
                swikiEnabled := HTTPServer hasMySwikiConfigured.
                swikiRoot := PWS::SwikiAction serverDirectory.
            ]
        ].
    ].
    (hasSoap := SOAP::SoapHttpModule notNil) ifTrue:[
        SOAP::SoapHttpModule isLoaded ifTrue:[
            (HTTPServer notNil and:[HTTPServer isLoaded]) ifTrue:[
                soapEnabled := HTTPServer hasSoapEnabled.
            ]
        ].
    ].

    org_swikiRoot := swikiRoot.
    org_swikiEnabled := swikiEnabled.
    org_soapEnabled := soapEnabled.
    swikiRoot := swikiRoot asValue.
    swikiEnabled := swikiEnabled asValue.
    soapEnabled := soapEnabled asValue.

    swikiEnabled
        onChangeEvaluate:[
            swikiRoot value:(PWS::SwikiAction serverDirectory).
        ].

    allowEmbedded := HTTPServer isLoaded and:[HTTPServer enableEmbeddedSmalltalk].
    org_allowEmbedded := allowEmbedded.
    allowEmbedded := allowEmbedded asValue.

    "/
    "/ osi settings ...
    "/
    osiACSEPresent := OSI::ACSE notNil and:[OSI::ACSE isLoaded].
    osiROSEPresent := OSI::ROSE notNil and:[OSI::ROSE isLoaded].
    osiCMISEPresent := OSI::CMISE notNil and:[OSI::CMISE isLoaded].

    osiACSEPresent ifTrue:[
        osiACSEErrorLogging := OSI::ACSE errorLogging asValue.
        osiACSEConnectionLogging := OSI::ACSE connectionLogging asValue.
        osiACSEDataLogging :=  OSI::ACSE dataLogging asValue.
    ].
    osiROSEPresent ifTrue:[
        osiROSEErrorLogging := OSI::ROSE errorLogging asValue.
        osiROSEInvokationLogging := OSI::ROSE invocationLogging asValue.
        osiROSEResponseLogging :=  OSI::ROSE responseLogging asValue.
    ].
    osiCMISEPresent ifTrue:[
        osiCMISEErrorLogging := OSI::CMISE errorLogging asValue.
        osiCMISEMessageLogging := OSI::CMISE messageLogging asValue.
    ].

    "/
    "/ create a box on those values ...
    "/
    box := DialogBox new.
    box label:(resources string:'Communication settings').

    box addTextLabel:(resources string:'Remote browsing').

    check := box addCheckBox:(resources string:'Remote browsing enabled') on:remoteBrowsingEnabled.
    hasRemoteBrowsingSupport ifFalse:[
        check disable
    ].
    box addHorizontalLine.

    box addTextLabel:(resources string:'Window migration').

    check := box addCheckBox:(resources string:'Window migration enabled') on:windowMigrationEnabled.
    hasWindowMigrationServer ifFalse:[
        check disable
    ].
    check := box addCheckBox:(resources string:'Password check') on:windowMigrationAuthenticate.
    check enableChannel:windowMigrationEnabled.
    hasWindowMigrationServer ifFalse:[
        check disable
    ].
    box leftIndent:20.
    in := box 
            addLabelledInputField:(resources string:'Password:')
            adjust:#right
            on:nil 
            tabable:true
            separateAtX:0.3.
    in passwordCharacter:$*.
    in model:windowMigrationPassword.
    in acceptChannel:acceptChannel.
    in enableChannel:windowMigrationAuthenticate.
    box leftIndent:0.

    box addHorizontalLine.

    box addTextLabel:'RDoIt Server'.

    check := box addCheckBox:(resources string:'Remote doits enabled') on:rDoitsEnabled.
    hasRDoitServer ifFalse:[
        check disable
    ].
    box leftIndent:20.
    rDoitsEnabled onChangeEvaluate:[ rDoitsEnabled value ifTrue:[
                                        rDoitServerPort value isNil ifTrue:[
                                            rDoitServerPort value:(RDoItServer defaultPortNumber).
                                        ]
                                     ]   
                                   ].

    in := box 
            addLabelledInputField:(resources string:'Port:')
            adjust:#right
            on:nil 
            tabable:true
            separateAtX:0.3.
    in converter:(PrintConverter new initForNumber).
    in model:rDoitServerPort.
    in acceptChannel:acceptChannel.
    in enableChannel:rDoitsEnabled.

    y := box yPosition.
    check := box addCheckBox:(resources string:'Log errors') on:rDoitErrorLogging.
    check width:0.4.
    check enableChannel:rDoitsEnabled.
    hasRDoitServer ifFalse:[
        check disable
    ].
    box yPosition:y.
    check := box addCheckBox:(resources string:'Log requests') on:rDoitLogging.
    check left:0.4; width:0.4.
    check enableChannel:rDoitsEnabled.
    hasRDoitServer ifFalse:[
        check disable
    ].
    check := box addCheckBox:(resources string:'Debug errors') on:rDoitErrorDebugging.
    check width:0.4.
    check enableChannel:rDoitsEnabled.
    hasRDoitServer ifFalse:[
        check disable
    ].
    box leftIndent:0.

    box addHorizontalLine.

    box addTextLabel:'HTTP Server'.

    check := box addCheckBox:(resources string:'Serving HTTP Requests') on:httpServerRunning.
    hasHTTPServer ifFalse:[
        check disable
    ].
    box leftIndent:20.
    in := box 
            addLabelledInputField:(resources string:'Port:')
            adjust:#right
            on:nil 
            tabable:true
            separateAtX:0.3.
    in converter:(PrintConverter new initForNumber).
    in model:httpServerPort.
    in acceptChannel:acceptChannel.
    in enableChannel:httpServerRunning.

    in := box 
            addLabelledInputField:(resources string:'Log File:')
            adjust:#right
            on:httpServerLogFile 
            tabable:true
            separateAtX:0.3.
    in acceptChannel:acceptChannel.
    in enableChannel:httpServerRunning.

    in := box 
            addLabelledInputField:(resources string:'File Root:')
            adjust:#right
            on:httpServerFileRoot 
            tabable:true
            separateAtX:0.3.
    in acceptChannel:acceptChannel.
    in enableChannel:httpServerRunning.

    in := box 
            addLabelledInputField:(resources string:'Home URL:')
            adjust:#right
            on:httpServerHomeURL 
            tabable:true
            separateAtX:0.3.
    in acceptChannel:acceptChannel.
    in enableChannel:httpServerRunning.

    check := box addCheckBox:(resources string:'Swiki enabled') on:swikiEnabled.
    hasHTTPServer ifFalse:[
        check disable
    ].
    check enableChannel:httpServerRunning.

"/    box leftIndent:40.

    in := box 
            addLabelledInputField:(resources string:'SwikiRoot:')
            adjust:#right
            on:swikiRoot 
            tabable:true
            separateAtX:0.3.
    in acceptChannel:acceptChannel.
    in enableChannel:(BlockValue forLogical:httpServerRunning and:swikiEnabled).

    check := box addCheckBox:(resources string:'Allow embedded ST applications') on:allowEmbedded.
    hasHTTPServer ifFalse:[
        check disable
    ].
    check enableChannel:httpServerRunning.

    check := box addCheckBox:(resources string:'Soap enabled') on:soapEnabled.
    hasHTTPServer ifFalse:[
        check disable
    ].
    check enableChannel:httpServerRunning.

    box leftIndent:0.
    box addHorizontalLine.

    box addTextLabel:(resources string:'OSI Protocols (addOn package)').

    y := box yPosition.
    check := box addCheckBox:(resources string:'Log %1 Errors' with:'ACSE') on:osiACSEErrorLogging.
    check width:0.33.
    osiACSEPresent ifFalse:[
        check disable
    ].

    box yPosition:y.
    check := box addCheckBox:(resources string:'Connections') on:osiACSEConnectionLogging.
    osiACSEPresent ifFalse:[
        check disable
    ].
    check left:0.33; width:0.33.

    box yPosition:y.
    check := box addCheckBox:(resources string:'Data Xfer') on:osiACSEDataLogging.
    osiACSEPresent ifFalse:[
        check disable
    ].
    check left:0.66; width:0.34.


    box addVerticalSpace.

    y := box yPosition.
    check := box addCheckBox:(resources string:'Log %1 Errors' with:'ROSE') on:osiROSEErrorLogging.
    osiROSEPresent ifFalse:[
        check disable
    ].
    check width:0.33.

    box yPosition:y.
    check := box addCheckBox:(resources string:'Invoactions') on:osiROSEInvokationLogging.
    osiROSEPresent ifFalse:[
        check disable
    ].
    check left:0.33; width:0.33.

    box yPosition:y.
    check := box addCheckBox:(resources string:'Responses') on:osiROSEResponseLogging.
    osiROSEPresent ifFalse:[
        check disable
    ].
    check left:0.66; width:0.34.

    box addVerticalSpace.

    y := box yPosition.
    check := box addCheckBox:(resources string:'Log %1 Errors' with:'CMISE') on:osiCMISEErrorLogging.
    osiCMISEPresent ifFalse:[
        check disable
    ].
    check width:0.33.

    box yPosition:y.
    check := box addCheckBox:(resources string:'Messages') on:osiCMISEMessageLogging.
    osiCMISEPresent ifFalse:[
        check disable
    ].
    check left:0.33; width:0.33.


    box addHorizontalLine.
    box 
        addHelpButtonFor:'Launcher/communicationsSettings.html';
        addAbortAndOkButtons.

    "/
    "/ show the box ...
    "/
    box open.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
        acceptChannel value:false; value:true.

        hasRemoteBrowsingSupport ifTrue:[
            remoteBrowsingEnabled := remoteBrowsingEnabled value.
            (remoteBrowsingEnabled ~~ org_remoteBrowsingEnabled) ifTrue:[
                remoteBrowsingEnabled ~~ SmalltalkShareServer serverRunning ifTrue:[
                    remoteBrowsingEnabled ifFalse:[
                        SmalltalkShareServer killAll
                    ] ifTrue:[
                        SmalltalkShareServer start.
                        "/ must wait a bit; give it a chance to
                        "/ really start (before checking)
                        Delay waitForSeconds:0.5.
                        SmalltalkShareServer serverRunning ifFalse:[
                            self warn:'SmalltalkShareServer startup failed (see stderr).'
                        ]
                    ]
                ].
            ]
        ].

        hasWindowMigrationServer ifTrue:[
            windowMigrationEnabled := windowMigrationEnabled value.
            windowMigrationAuthenticate := windowMigrationAuthenticate value.
            windowMigrationPassword := windowMigrationPassword value.
            (windowMigrationEnabled ~~ org_windowMigrationEnabled
            or:[windowMigrationAuthenticate ~~ org_windowMigrationAuthenticate 
            or:[windowMigrationPassword ~~ org_windowMigrationPassword]])  ifTrue:[
                windowMigrationAuthenticate ~~ org_windowMigrationAuthenticate ifTrue:[
                    windowMigrationAuthenticate ifFalse:[
                        WindowMigrationServer password:nil    
                    ] ifTrue:[
                        WindowMigrationServer password:windowMigrationPassword    
                    ].
                ].
                windowMigrationEnabled ~~ WindowMigrationServer serverRunning ifTrue:[
                    windowMigrationEnabled ifFalse:[
                        WindowMigrationServer stop
                    ] ifTrue:[
                        WindowMigrationServer start.
                        "/ must wait a bit; give it a chance to
                        "/ really start (before checking)
                        Delay waitForSeconds:0.5.
                        WindowMigrationServer serverRunning ifFalse:[
                            self warn:'WindowMigrationServer startup failed (see stderr).'
                        ]
                    ]
                ].
            ]
        ].

        hasRDoitServer ifTrue:[
            (rDoitLogging value ~~ org_rDoitLogging
            or:[rDoitErrorDebugging value ~~ org_rDoitErrorDebugging
            or:[rDoitErrorLogging value ~~ org_rDoitErrorLogging
            or:[rDoitsEnabled value ~~ org_rDoitsEnabled
            or:[rDoitServerPort value ~~ org_rDoitServerPort]]]]) ifTrue:[
                RDoItServer autoload.
                RDoItServer defaultPortNumber:rDoitServerPort value.
                RDoItServer logging:(rDoitLogging value).
                RDoItServer errorLogging:(rDoitErrorLogging value).
                RDoItServer errorCatching:(rDoitErrorDebugging value not).
                rDoitsEnabled := rDoitsEnabled value.
                rDoitsEnabled ~~ RDoItServer serverRunning ifTrue:[
                    rDoitsEnabled ifFalse:[
                        RDoItServer stop
                    ] ifTrue:[
                        RDoItServer start.
                        "/ must wait a bit; give it a chance to
                        "/ really start (before checking)
                        Delay waitForSeconds:0.5.
                        RDoItServer serverRunning ifFalse:[
                            self warn:'RDoit startup failed (see stderr).'
                        ]
                    ]
                ].
            ].
        ].

        (hasHTTPServer and:[HTTPServer isLoaded]) ifTrue:[
            httpServerPort := httpServerPort value.
            org_httpServerPort ~= httpServerPort ifTrue:[
                HTTPServer defaultPort:httpServerPort.
            ].

            httpServerFileRoot := httpServerFileRoot value.
            httpServerFileRoot size == 0 ifTrue:[
                httpServerFileRoot := nil
            ].
            org_httpServerFileRoot ~= httpServerFileRoot ifTrue:[
                HTTPServer fileRoot:httpServerFileRoot.
            ].

            httpServerLogFile := httpServerLogFile value.
            httpServerLogFile size == 0 ifTrue:[
                httpServerLogFile := nil
            ].
            org_httpServerLogFile ~= httpServerLogFile ifTrue:[
                HTTPServer defaultLogFile:httpServerLogFile.
            ].

            httpServerHomeURL := httpServerHomeURL value.
            httpServerHomeURL size == 0 ifTrue:[
                httpServerHomeURL := nil
            ].
            org_httpServerHomeURL ~= httpServerHomeURL ifTrue:[
                HTTPServer homeURL:httpServerHomeURL.
            ].

            httpServerRunning value ~~ org_httpServerRunning ifTrue:[
                httpServerRunning value ifTrue:[
                    HTTPServer startServer
                ] ifFalse:[
                    HTTPServer stopServer
                ]
            ].
        ].

        hasSwiki ifTrue:[
            swikiRoot := swikiRoot value.
            swikiRoot size == 0 ifTrue:[
                swikiRoot := nil
            ].
            org_swikiRoot ~= swikiRoot ifTrue:[
                PWS::ServerAction serverDirectory:swikiRoot.
            ].

            swikiEnabled value ~~ org_swikiEnabled ifTrue:[
                swikiEnabled value ifTrue:[
                    HTTPServer setupMySwiki
                ] ifFalse:[
                    HTTPServer disableMySwiki
                ]
            ].
            allowEmbedded value ~~ org_allowEmbedded ifTrue:[
                HTTPServer enableEmbeddedSmalltalk:allowEmbedded value
            ].
        ].
        hasSoap ifTrue:[
            soapEnabled value ~~ org_soapEnabled ifTrue:[
                soapEnabled value ifTrue:[
                    HTTPServer setupSoap
                ] ifFalse:[
                    HTTPServer disableSoap
                ]
            ].
        ].

        osiACSEPresent ifTrue:[
            OSI::ACSE errorLogging:osiACSEErrorLogging value.
            OSI::ACSE connectionLogging:osiACSEConnectionLogging value.
            OSI::ACSE dataLogging:osiACSEDataLogging value.
        ].
        osiROSEPresent ifTrue:[
            OSI::ROSE errorLogging:osiROSEErrorLogging value.
            OSI::ROSE invocationLogging:osiROSEInvokationLogging value.
            OSI::ROSE responseLogging:osiROSEResponseLogging value.
        ].
        osiCMISEPresent ifTrue:[
            OSI::CMISE errorLogging:osiCMISEErrorLogging value.
            OSI::CMISE messageLogging:osiCMISEMessageLogging value.
        ].
    ].
    box destroy

    "Modified: / 28.6.1999 / 15:44:35 / stefan"
    "Modified: / 20.1.2000 / 19:14:18 / cg"
!

compilerSettings
    "open a dialog on compiler related settings"

    |box warnings warnSTX warnUnderscore warnDollar warnOldStyle warnUnusedVars
     allowDollar allowUnderscore allowSqueakExtensions allowQualifiedNames
     allowDolphinExtensions allowOldStyleAssignment allowReservedWordsAsSelectors 
     immutableArrays
     warnSTXBox warnUnderscoreBox warnOldStyleBox warnCommonMistakes warnCommonMistakesBox
     warnCompatibility warnCompatibilityBox warnDollarBox warnUnusedVarsBox
     stcCompilation compilationList stcCompilationOptions 
     historyLines fullHistoryUpdate 
     catchMethodRedefs catchClassRedefs keepSourceOptions keepSource  
     constantFoldingOptions constantFolding justInTimeCompilation 
     warnEnabler check component oldIndent supportsJustInTimeCompilation y
     y2 fullDebugSupport yMax
     compileLazy loadBinaries canLoadBinaries strings idx thisIsADemoVersion
     resources stcSetupButt|

    resources := self owningClass classResources.

    canLoadBinaries := ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles].
    loadBinaries := Smalltalk loadBinaries asValue.
    compileLazy := Autoload compileLazy asValue.

    warnings := Compiler warnings asValue.

    warnSTX := Compiler warnSTXSpecials asValue.
    warnUnderscore := Compiler warnUnderscoreInIdentifier asValue.
    warnDollar := Compiler warnDollarInIdentifier asValue.
    warnOldStyle := Compiler warnOldStyleAssignment asValue.
    warnCommonMistakes := Compiler warnCommonMistakes asValue.
    warnCompatibility := Compiler warnPossibleIncompatibilities asValue.
    warnUnusedVars := Compiler warnUnusedVars asValue.
    allowUnderscore := Compiler allowUnderscoreInIdentifier asValue.
    allowDollar := Compiler allowDollarInIdentifier asValue.
    allowSqueakExtensions := Compiler allowSqueakExtensions asValue.
    allowDolphinExtensions := Compiler allowDolphinExtensions asValue.
    allowQualifiedNames := Compiler allowQualifiedNames asValue.
    allowOldStyleAssignment := Compiler allowOldStyleAssignment asValue.
    allowReservedWordsAsSelectors := Compiler allowReservedWordsAsSelectors asValue.
    immutableArrays := Compiler arraysAreImmutable asValue.

    constantFoldingOptions := #( nil #level1 #level2 #full ).
    constantFolding := SelectionInList new list:(resources array:#('disabled' 'level1 (always safe)' 'level2 (usually safe)' 'full')).
    constantFolding selectionIndex:3.

    thisIsADemoVersion := (Smalltalk releaseIdentification = 'ST/X_free_demo_vsn').
    thisIsADemoVersion ifTrue:[
        stcCompilationOptions := #( never).
        strings := #('never').
        idx := 1.
    ] ifFalse:[
        stcCompilationOptions := #( always default never).
        strings := #('always' 'primitive code only' 'never').
        idx := 2.
    ].

    stcCompilation := SelectionInList new list:(resources array:strings).
    stcCompilation selectionIndex:idx.

    (supportsJustInTimeCompilation := ObjectMemory supportsJustInTimeCompilation)
    ifTrue:[
        justInTimeCompilation := ObjectMemory justInTimeCompilation.
        fullDebugSupport := ObjectMemory fullSingleStepSupport.
    ] ifFalse:[
        justInTimeCompilation := false.
        fullDebugSupport := (Compiler lineNumberInfo == #full) asValue.
    ].
    justInTimeCompilation := justInTimeCompilation asValue.
    fullDebugSupport := fullDebugSupport asValue.

    catchMethodRedefs := Class catchMethodRedefinitions asValue.
    catchClassRedefs := Class catchClassRedefinitions asValue.
    historyLines := HistoryManager notNil and:[HistoryManager isLoaded and:[HistoryManager isActive]].
    historyLines ifFalse:[
        fullHistoryUpdate := false asValue   
    ] ifTrue:[
        fullHistoryUpdate := HistoryManager fullHistoryUpdate asValue.
    ].
    historyLines := historyLines asValue.

    keepSourceOptions := #( keep reference absReference sourceReference discard ).
    keepSource := SelectionInList new 
                        list:(resources array:#('Keep as String' 'Reference to Filename' 'Reference to Full Path' 'Append and Ref in `st.src''' 'Discard' )).
    keepSource selectionIndex:1.

    warnEnabler := [
              warnings value ifTrue:[
                warnSTXBox enable. 
                warnOldStyleBox enable.
                warnCommonMistakesBox enable.
                warnCompatibilityBox enable.
                warnUnusedVarsBox enable.
                allowUnderscore value ifTrue:[
                    warnUnderscoreBox enable.
                ] ifFalse:[
                    warnUnderscoreBox disable.
                ].
                allowDollar value ifTrue:[
                    warnDollarBox enable.
                ] ifFalse:[
                    warnDollarBox disable.
                ].
              ] ifFalse:[
                warnSTXBox disable. 
                warnUnderscoreBox disable.
                warnDollarBox disable.
                warnOldStyleBox disable.
                warnCommonMistakesBox disable.
                warnCompatibilityBox disable.
                warnUnusedVarsBox disable.
              ]].

    warnings onChangeEvaluate:warnEnabler.
    allowUnderscore onChangeEvaluate:warnEnabler.
    allowDollar onChangeEvaluate:warnEnabler.
"/    allowSqueakExtensions onChangeEvaluate:warnEnabler.
"/    allowQualifiedNames onChangeEvaluate:warnEnabler.

    box := DialogBox new.
    box label:(resources string:'Compiler Settings').

    y := box yPosition.
    check := box addCheckBox:(resources string:'Catch Method Redefinitions') on:catchMethodRedefs.
    check width:0.5.

    box yPosition:y.
    check := box addCheckBox:(resources string:'Catch Class Redefinitions') on:catchClassRedefs.
    check left:0.5; width:0.5.

    y := box yPosition.
    check := box addCheckBox:(resources string:'Keep History Line in Methods') on:historyLines.
    check width:0.5.
    HistoryManager isNil ifTrue:[check disable].
    box yPosition:y.
    check := box addCheckBox:(resources string:'Keep Full Class History') on:fullHistoryUpdate.
    check left:0.5; width:0.5.
    HistoryManager isNil ifTrue:[check disable] ifFalse:[check enableChannel:historyLines].

    box addPopUpList:(resources string:'FileIn Source Mode:') on:keepSource.
    keepSource selectionIndex:( keepSourceOptions indexOf:(ClassCategoryReader sourceMode) ifAbsent:1).

    box addHorizontalLine.

    box addCheckBox:(resources string:'Lazy Compilation when Autoloading') on:compileLazy.
    check := box addCheckBox:(resources string:'If Present, Load Binary Objects when Autoloading') on:loadBinaries.
    canLoadBinaries ifFalse:[
        loadBinaries value:false.
        check disable
    ].
    supportsJustInTimeCompilation ifTrue:[
        component := box 
                        addCheckBox:(resources string:'Just in Time Compilation to Machine Code') 
                        on:justInTimeCompilation.
    ].

    box addHorizontalLine.

    ObjectFileLoader notNil ifTrue:[
        compilationList := box addPopUpList:(resources string:'Stc Compilation to Machine Code') on:stcCompilation.

        thisIsADemoVersion ifFalse:[
            stcCompilation selectionIndex:( stcCompilationOptions indexOf:(Compiler stcCompilation) ifAbsent:2).

            stcSetupButt := box addComponent:(Button label:(resources string:'Stc Compilation Parameters...') 
                       action:[|manager|

                               self stcCompilerSettings.
                              ]).
        ].

        box addHorizontalLine.

        "/ if there is no compiler around,
        "/ change to compile nothing, and disable the checkBoxes
        Compiler canCreateMachineCode ifFalse:[
            stcCompilation selectionIndex:(3 min:stcCompilationOptions size).
            compilationList disable.
        ].
    ].

    y := box yPosition.

    component := box addCheckBox:(resources string:'Allow Underscore in Identifiers') on:allowUnderscore.
    component width:0.4.

    component := box addCheckBox:(resources string:'Allow Dollar in Identifiers') on:allowDollar.
    component width:0.4.

    component := box addCheckBox:(resources string:'Allow VW3 QualifiedNames') on:allowQualifiedNames.
    component width:0.4.

    component := box addCheckBox:(resources string:'Allow Squeak Extensions') on:allowSqueakExtensions.
    component width:0.4.

    component := box addCheckBox:(resources string:'Allow Dolphin Extensions') on:allowDolphinExtensions.
    component width:0.4.

    y2 := box yPosition.

    box yPosition:y.
    box leftIndent:0.

    component :=box addPopUpList:(resources string:'Constant Folding:') on:constantFolding.
    component superView left:0.5; width:0.5.
    constantFolding selectionIndex:( constantFoldingOptions indexOf:(Compiler foldConstants) ifAbsent:1).

    component := box addCheckBox:(resources string:'Allow OldStyle Assignment (_)') on:allowOldStyleAssignment.
    component left:0.5; width:0.4.

    component := box addCheckBox:(resources string:'Allow Reserved Words as Selector (self)') on:allowReservedWordsAsSelectors.
    component left:0.5; width:0.4.

    component := box addCheckBox:(resources string:'Full Debug Info') on:fullDebugSupport.
    component left:0.5; width:0.4.

    component := box addCheckBox:(resources string:'Literal Arrays are Immutable') on:immutableArrays.
    component left:0.5; width:0.4.

    box yPosition:(box yPosition max:y2).


    box addHorizontalLine.

    box addCheckBox:(resources string:'Warnings') on:warnings.
"/    box addVerticalSpace.
    oldIndent := box leftIndent.
    box leftIndent:30.

    y := box yPosition.

    warnSTXBox := box addCheckBox:(resources string:'ST/X Extensions') on:warnSTX.
    warnSTXBox width:0.4.

    warnUnderscoreBox := box addCheckBox:(resources string:'Underscores in Identifiers') on:warnUnderscore.
    warnUnderscoreBox width:0.4.

    warnDollarBox := box addCheckBox:(resources string:'Dollars in Identifiers') on:warnDollar.
    warnDollarBox width:0.4.

    warnUnusedVarsBox := box addCheckBox:(resources string:'Unused Method Variables') on:warnUnusedVars.
    warnUnusedVarsBox width:0.4.

    yMax := box yPosition.

    box yPosition:y.
    box leftIndent:0.
    warnOldStyleBox := box addCheckBox:(resources string:'OldStyle Assignment') on:warnOldStyle.
    warnOldStyleBox left:0.5; width:0.4.

    warnCommonMistakesBox := box addCheckBox:(resources string:'Common Mistakes') on:warnCommonMistakes.
    warnCommonMistakesBox left:0.5; width:0.4.

    warnCompatibilityBox := box addCheckBox:(resources string:'Possible Incompatibilities') on:warnCompatibility.
    warnCompatibilityBox left:0.5; width:0.4.

    box leftIndent:oldIndent.
    box yPosition:(yMax max: box yPosition).

    box addHorizontalLine.
    box 
        addHelpButtonFor:'Launcher/compilerSettings.html';
        addAbortAndOkButtons.

    warnEnabler value.
    box open.

    box accepted ifTrue:[
        HistoryManager notNil ifTrue:[
            HistoryManager fullHistoryUpdate:fullHistoryUpdate value.
            historyLines value ifTrue:[
                HistoryManager activate
            ] ifFalse:[
                HistoryManager deactivate
            ].
        ].
        Class catchMethodRedefinitions:catchMethodRedefs value.
        Class catchClassRedefinitions:catchClassRedefs value.
        ClassCategoryReader sourceMode:(keepSourceOptions at:keepSource selectionIndex).
        Compiler warnings:warnings value.
        Compiler warnSTXSpecials:warnSTX value.
        Compiler warnOldStyleAssignment:warnOldStyle value.
        Compiler warnUnderscoreInIdentifier:warnUnderscore value.
        Compiler warnDollarInIdentifier:warnDollar value.
        Compiler warnCommonMistakes:warnCommonMistakes value.
        Compiler warnPossibleIncompatibilities:warnCompatibility value.
        Compiler warnUnusedVars:warnUnusedVars value.
        Compiler allowUnderscoreInIdentifier:allowUnderscore value.
        Compiler allowDollarInIdentifier:allowDollar value.
        Compiler allowSqueakExtensions:allowSqueakExtensions value.
        Compiler allowDolphinExtensions:allowDolphinExtensions value.
        Compiler allowQualifiedNames:allowQualifiedNames value.
        Compiler allowOldStyleAssignment:allowOldStyleAssignment value.
        Compiler allowReservedWordsAsSelectors:allowReservedWordsAsSelectors value.

        Compiler arraysAreImmutable:immutableArrays value.
        fullDebugSupport value ifTrue:[
            Compiler lineNumberInfo:#full.
        ] ifFalse:[
            Compiler lineNumberInfo:true
        ].

        Compiler stcCompilation:(stcCompilationOptions at:stcCompilation selectionIndex).
        Compiler foldConstants:(constantFoldingOptions at:constantFolding selectionIndex).

        supportsJustInTimeCompilation ifTrue:[
            justInTimeCompilation := justInTimeCompilation value.
            justInTimeCompilation ifTrue:[
                Method allInstancesDo:[:m | m checked:false].
            ].
            ObjectMemory justInTimeCompilation:justInTimeCompilation.
            ObjectMemory fullSingleStepSupport:fullDebugSupport value.
        ].
        Autoload compileLazy:compileLazy value.
        Smalltalk loadBinaries:loadBinaries value.
    ].
    box destroy

    "Modified: / 10.9.1995 / 19:19:18 / claus"
    "Modified: / 9.9.1996 / 22:42:47 / stefan"
    "Modified: / 5.11.1998 / 14:25:59 / cg"
!

displaySettings
    "open a dialog on display related settings"

    |box listOfSizes sizeInfos
     sizes sizeNames sizeList sizeX sizeY deepIcons
     isColorMonitor useFixPalette useFixGrayPalette idx ditherStyles ditherSyms ditherList
     y component screen visual clipEncodings clipEncodingSyms clipEncodingList resources
     |

    resources := self owningClass classResources.

    listOfSizes := resources at:'LIST_OF_OFFERED_SCREEN_SIZES' default:#default.
    listOfSizes == #default ifTrue:[
        "/ nothing in resource file; offer at least some.
        sizeInfos := #(
                           ( '11.3'' (235mm x 175mm) LCD'   (235 175)    )
                           ( '17''   (325mm x 245mm)'       (325 245)    )
                           ( '19''   (340mm x 270mm)'       (340 270)    )
                           ( '20''   (350mm x 280mm)'       (350 280)    )
                           ( '21''   (365mm x 285mm)'       (365 285)    )
                       ).
    ] ifFalse:[
        sizeInfos := resources array:listOfSizes.
    ].
    sizeNames := sizeInfos collect:[:entry | entry at:1].
    sizes := sizeInfos collect:[:entry | entry at:2].

    screen := Screen current.
    visual := screen visualType.

    isColorMonitor := screen hasColors asValue.
    deepIcons := screen supportsDeepIcons asValue.
    useFixPalette := screen fixColors notNil asValue.
    useFixGrayPalette := screen fixGrayColors notNil asValue.

    sizeList := SelectionInList with:sizeNames.
    sizeX := screen widthInMillimeter asValue.
    sizeY := screen heightInMillimeter asValue.

    clipEncodingSyms := #(nil #iso8859 #jis #jis7 #sjis #euc #big5).
    clipEncodings := resources array:#('untranslated' 'iso8859' 'jis' 'jis7' 'shift-JIS' 'EUC' 'big5').
    clipEncodingList := SelectionInList new.
    clipEncodingList list:clipEncodings.
    clipEncodingList selectionIndex:(clipEncodingSyms indexOf:screen clipBoardEncoding ifAbsent:1).

    ditherList := SelectionInList new.

    (visual == #StaticGray or:[visual == #GrayScale]) ifTrue:[
        ditherStyles := #('threshold' 'ordered dither' 'error diffusion').
        ditherSyms := #(threshold ordered floydSteinberg).
    ] ifFalse:[
        visual ~~ #TrueColor ifTrue:[
            ditherStyles := #('nearest color' 'error diffusion').
            ditherSyms := #(ordered floydSteinberg).
        ]
    ].
    ditherSyms notNil ifTrue:[    
        ditherList list:ditherStyles.
        ditherList selectionIndex:(ditherSyms indexOf:(Image ditherAlgorithm) ifAbsent:#threshold).
    ].

    box := DialogBox new.
    box label:(resources string:'Display Screen Settings').

    (box addTextLabel:(resources string:'Actual Visible Screen Area:'))
        adjust:#left.

    (box addPopUpList:(resources string:'Common Sizes:') on:sizeList)
        label:'monitor size'.

    idx := sizes findFirst:[:entry |
                                ((entry at:1) = sizeX value)
                                and:[((entry at:2) = sizeY value)]
                           ].
    idx ~~ 0 ifTrue:[
        sizeList selectionIndex:idx
    ].

    sizeList onChangeEvaluate:[
                                        |idx|

                                        idx := sizeList selectionIndex.
                                        sizeX value:((sizes at:idx) at:1).
                                        sizeY value:((sizes at:idx) at:2).
                                    ].

    y := box yPosition.
    component := box addTextLabel:(resources string:'Screen Size:').
    component width:0.3; adjust:#right; borderWidth:0.

    box yPosition:y.
    component := box addInputFieldOn:nil tabable:true.
    component width:0.25; left:0.3; 
              immediateAccept:false; acceptOnLeave:false; 
              cursorMovementWhenUpdating:#beginOfLine;
              converter:(PrintConverter new initForInteger);
              model:sizeX.

    box yPosition:y.
    component := box addTextLabel:(' x ').
    component width:0.1; left:0.55; adjust:#center; borderWidth:0.

    box yPosition:y.
    component := box addInputFieldOn:nil tabable:true.
    component width:0.25; left:0.65; 
              immediateAccept:false; acceptOnLeave:false; 
              cursorMovementWhenUpdating:#beginOfLine;
              converter:(PrintConverter new initForInteger);
              model:sizeY.

    box yPosition:y.
    component := box addTextLabel:('(mm)').
    component width:0.1; left:0.9; adjust:#center; borderWidth:0.

    box addVerticalSpace; addHorizontalLine; addVerticalSpace.

    (box addTextLabel:(resources string:'Screen: Depth: %1 Visual: %2  (%3)'
                                 with:screen depth printString
                                 with:screen visualType
                                 with:screen serverVendor))
        adjust:#left.

    box addVerticalSpace; addHorizontalLine; addVerticalSpace.

    box addCheckBox:(resources string:'Color Monitor') on:isColorMonitor.

    visual == #PseudoColor ifTrue:[
        box addVerticalSpace.
        component := box addCheckBox:(resources string:'Use Fix Color Palette %1' with:'(4x8x4)') on:useFixPalette.

        box addVerticalSpace.
        component := box addCheckBox:(resources string:'Use Fix Gray Color Palette %1' with:'(32)') on:useFixGrayPalette.
    ].

    ditherSyms notNil ifTrue:[
        box addVerticalSpace.
        component := box addPopUpList:(resources string:'Image Display:') on:ditherList.
        component defaultLabel:'image display'.
        component superView horizontalLayout:#leftSpace.
    ].

    box addVerticalSpace.
    box addCheckBox:(resources string:'Allow Colored/Grayscale Icons') on:deepIcons.

    box addVerticalSpace; addHorizontalLine; addVerticalSpace.

    component := box addPopUpList:(resources string:'ClipBoard Encoding:') on:clipEncodingList.
    component superView horizontalLayout:#leftSpace.

    box addHorizontalLine.
    box 
        addHelpButtonFor:'Launcher/screenSettings.html';
        addAbortAndOkButtons.
    box open.

    box accepted ifTrue:[
        Image flushDeviceImages.

        screen visualType == #PseudoColor ifTrue:[
            useFixPalette value ifTrue:[
                Color colorAllocationFailSignal handle:[:ex |
                    self warn:'Could not allocate colors.'.
                ] do:[
                    Color getColorsRed:4 green:8 blue:4 on:screen
                ]
            ] ifFalse:[
                screen releaseFixColors
            ].

            useFixGrayPalette value ifTrue:[
                Color colorAllocationFailSignal handle:[:ex |
                    self warn:'Could not allocate colors.'.
                ] do:[
                    Color getGrayColors:32 on:screen
                ]
            ] ifFalse:[
                screen releaseFixGrayColors
            ]
        ].
        screen hasColors:isColorMonitor value.
        screen widthInMillimeter:sizeX value.
        screen heightInMillimeter:sizeY value.

        screen supportsDeepIcons:deepIcons value.
        ditherSyms notNil ifTrue:[
            Image ditherAlgorithm:(ditherSyms at:ditherList selectionIndex).
        ].

        WindowGroup activeGroup withWaitCursorDo:[
            View defaultStyle:(View defaultStyle).
        ].

        screen clipBoardEncoding:(clipEncodingSyms at:clipEncodingList selectionIndex).
    ].
    box destroy

    "Modified: / 9.9.1996 / 22:43:04 / stefan"
    "Modified: / 20.5.1999 / 18:35:21 / cg"
!

editSettings
    "open a dialog on edit settings"

    |box st80EditingMode st80DoubleClickSelectMode resources 
     tabsIs4 prevTabsIs4 searchDialogIsModal startTextDragWithControl|

    resources := self owningClass classResources.

    "/ 
    "/ extract relevant system settings ...
    "/
    st80EditingMode := UserPreferences current st80EditMode asValue.
    st80DoubleClickSelectMode := TextView st80SelectMode asValue.
    prevTabsIs4 := (ListView userDefaultTabPositions = ListView tab4Positions).
    tabsIs4 := prevTabsIs4 asValue.
    searchDialogIsModal := UserPreferences current searchDialogIsModal asValue.
    startTextDragWithControl := UserPreferences current startTextDragWithControl asValue.

    "/
    "/ create a box on those values ...
    "/
    box := DialogBox new.
    box label:(resources string:'Edit settings').

    box addCheckBox:(resources string:'Cursor has ST80 Line-end Behavior') on:st80EditingMode.
    box addCheckBox:(resources string:'Double Click Select Behavior as in ST80') on:st80DoubleClickSelectMode.
    box addCheckBox:(resources string:'Tab Stops in Multiples of 4') on:tabsIs4.
    box addCheckBox:(resources string:'SearchBox is Modal') on:searchDialogIsModal.
    box addCheckBox:(resources string:'CTRL-Key to Start TextDrag') on:startTextDragWithControl.

    box addHorizontalLine.

    box 
        addHelpButtonFor:'Launcher/editSettings.html';
        addAbortAndOkButtons.

    "/
    "/ show the box ...
    "/
    box open.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
        UserPreferences current st80EditMode:(st80EditingMode value).
        TextView st80SelectMode:(st80DoubleClickSelectMode value).
        tabsIs4 value ~~ prevTabsIs4 ifTrue:[
            ListView userDefaultTabPositions:(tabsIs4 value ifTrue:[ListView tab4Positions] ifFalse:[ListView tab8Positions]).
            ListView allSubInstancesDo:[:eachKindOfListView |
                tabsIs4 value ifTrue:[eachKindOfListView setTab4] ifFalse:[eachKindOfListView setTab8]
            ].
        ].
        UserPreferences current searchDialogIsModal:searchDialogIsModal value.
        UserPreferences current startTextDragWithControl:startTextDragWithControl value.
    ].
    box destroy

    "Created: / 6.1.1999 / 14:12:09 / cg"
    "Modified: / 6.1.1999 / 14:17:51 / cg"
!

fontSettingsFor:requestor
    "open a dialog on font related settings"

    (self fontBoxForEncoding:nil) ifTrue:[
        requestor reopenLauncher.
    ]

    "Created: 26.2.1996 / 22:52:51 / cg"
    "Modified: 8.1.1997 / 14:52:49 / cg"
!

javaSettings
    "open a dialog on settings related to the java subsystem"

    |box audio javaHome classPath oldJavaHome oldClassPath resources component
     extraFileSecurityChecks extraSocketSecurityChecks
     supportsJustInTimeCompilation 
     javaJustInTimeCompilation javaNativeCodeOptimization
     showJavaByteCode exceptionDebug nullPointerExceptionDebug pathSep|

    resources := self owningClass classResources.

    audio := JavaVM audioEnabled asValue.
    extraFileSecurityChecks := JavaVM fileOpenConfirmation asValue.
    extraSocketSecurityChecks := JavaVM socketConnectConfirmation asValue.
    (supportsJustInTimeCompilation := ObjectMemory supportsJustInTimeCompilation) ifTrue:[
        javaJustInTimeCompilation := ObjectMemory javaJustInTimeCompilation asValue.
        javaNativeCodeOptimization := ObjectMemory javaNativeCodeOptimization asValue.
    ] ifFalse:[
        javaJustInTimeCompilation := javaNativeCodeOptimization := false
    ].
    showJavaByteCode := JavaMethod forceByteCodeDisplay asValue.
    exceptionDebug := JavaVM exceptionDebug asValue.
    nullPointerExceptionDebug := JavaVM nullPointerExceptionDebug asValue.

    classPath := (Java classPath ? '').
    OperatingSystem isUNIXlike ifTrue:[
        pathSep := $;.
    ] ifFalse:[
        pathSep := $:.
    ].
    classPath := (classPath asStringWith:pathSep) asValue.
    oldClassPath := classPath copy.
    classPath := classPath asValue.

    javaHome := (Java javaHome ? '').
    oldJavaHome := javaHome copy.
    javaHome := javaHome asValue.

    box := DialogBox new.
    box label:(resources string:'Java').

    box addCheckBox:(resources string:'Audio Enabled') on:audio.
    box addCheckBox:(resources string:'Confirm file open for write') on:extraFileSecurityChecks.
    box addCheckBox:(resources string:'Confirm socket connect') on:extraSocketSecurityChecks.
    box addCheckBox:(resources string:'Debug Exceptions') on:exceptionDebug.
    box addCheckBox:(resources string:'Debug Null Pointer Exceptions') on:nullPointerExceptionDebug.
    box addHorizontalLine.
    supportsJustInTimeCompilation ifTrue:[
        box 
            addCheckBox:(resources string:'java just in time compilation to machine code') 
            on:javaJustInTimeCompilation.
        box 
            addCheckBox:(resources string:'optimize native code') 
            on:javaNativeCodeOptimization.
    ].
    box addHorizontalLine.
    box addCheckBox:(resources string:'Display java byteCode (i.e. not source)') on:showJavaByteCode.
    box addHorizontalLine.
    component := box 
                    addLabelledInputField:(resources string:'classPath:')
                    adjust:#right
                    on:classPath 
                    tabable:true
                    separateAtX:0.3.
    component acceptOnLeave:false.
    component := box 
                    addLabelledInputField:(resources string:'java home:')
                    adjust:#right
                    on:javaHome 
                    tabable:true
                    separateAtX:0.3.
    component acceptOnLeave:false.

    box addVerticalSpace.
    box addComponent:(Button 
                        label:(resources string:'Reinit VM now') 
                        action:[
                                box windowGroup withWaitCursorDo:[
"/                                    Java classPath size == 0 ifTrue:[
"/                                        Java initialize.
"/                                    ].
"/                                    Java classPath size == 0 ifTrue:[
"/                                        self warn:'No JDK found'.
"/                                    ] ifFalse:[
                                        JavaVM initializeVM
"/                                    ]
                                ]
                               ]).

    box addComponent:(Button 
                        label:(resources string:'Remove all Java classes now') 
                        action:[
                                box windowGroup withWaitCursorDo:[
                                    Java flushAllJavaResources
                                ]
                               ]).

    "/ box addHorizontalLine.

"/    box addHelpButtonFor:'Launcher/javaSettings.html'.
    box addAbortAndOkButtons.
    box open.

    box accepted ifTrue:[
        classPath value ~= oldClassPath ifTrue:[
            OperatingSystem isUNIXlike ifTrue:[
                classPath := (classPath value asCollectionOfSubstringsSeparatedBy:$:)
            ] ifFalse:[
                classPath := (classPath value asCollectionOfSubstringsSeparatedBy:$;)
            ].
            Java classPath:classPath
        ].
        Java javaHome:javaHome value.

        JavaMethod forceByteCodeDisplay:showJavaByteCode value. 
        JavaVM audioEnabled:audio value.
        JavaVM exceptionDebug:exceptionDebug value.
        JavaVM nullPointerExceptionDebug:nullPointerExceptionDebug value.
        JavaVM fileOpenConfirmation: extraFileSecurityChecks value.
        JavaVM socketConnectConfirmation: extraSocketSecurityChecks value.

        javaJustInTimeCompilation value ~~ ObjectMemory javaJustInTimeCompilation ifTrue:[
            ObjectMemory javaJustInTimeCompilation:javaJustInTimeCompilation value.
            javaJustInTimeCompilation value ifTrue:[
                JavaMethod allSubInstancesDo:[:m | m checked:false].
            ].
        ].
        javaNativeCodeOptimization value ~~ ObjectMemory javaNativeCodeOptimization ifTrue:[
            ObjectMemory javaNativeCodeOptimization:javaNativeCodeOptimization value.
        ].
    ].
    box destroy

    "Created: / 18.7.1998 / 22:32:58 / cg"
    "Modified: / 27.1.1999 / 20:16:03 / cg"
!

keyboardSettings 
    "open a dialog on keyboard related settings"

    |mappings listOfRawKeys listOfFunctions
     box l
     list1 list2 listView1 listView2 
     frame selectionForwarder macroForwarder macroTextView y resources|

    resources := self owningClass classResources.

    mappings := Screen current keyboardMap.

    listOfRawKeys := (mappings keys asArray collect:[:key | key asString]) sort.
    listOfFunctions := (mappings values asSet asArray collect:[:key | key asString]) sort.

    selectionForwarder := Plug new.
    selectionForwarder respondTo:#showFunction
                  with:[
                        |raw|
                        raw := list1 selection.
                        list2 retractInterestsFor:selectionForwarder.
                        list2 selection:(mappings at:raw asSymbol) asString.
                        list2 onChangeSend:#showRawKey to:selectionForwarder.
                       ].
    selectionForwarder respondTo:#showRawKey
                  with:[
                        |f raw|

                        f := list2 selection.
                        list1 retractInterestsFor:selectionForwarder.
                        raw := mappings keyAtValue:f asString.
                        raw isNil ifTrue:[
                            raw := mappings keyAtValue:f first.
                            raw isNil ifTrue:[
                                raw := mappings keyAtValue:f asSymbol.
                            ]
                        ].
                        list1 selection:raw.
                        list1 onChangeSend:#showFunction to:selectionForwarder.
                       ].

    macroForwarder := [
                        |f macro indent|
                        f := list2 selection.
                        (f startsWith:'Cmd') ifTrue:[
                            f := f copyFrom:4
                        ].
                        macro := UserPreferences current functionKeySequences 
                                    at:(f asSymbol) ifAbsent:nil.
                        macro notNil ifTrue:[
                            macro := macro asStringCollection.
                            indent := macro
                                         inject:99999 into:[:min :element |
                                             |stripped|

                                             stripped := element withoutLeadingSeparators.
                                             stripped size == 0 ifTrue:[
                                                 min
                                             ] ifFalse:[
                                                 min min:(element size - stripped size)
                                             ]
                                         ].
                            indent ~~ 0 ifTrue:[
                                macro := macro collect:[:line | 
                                             line size > indent ifTrue:[
                                                line copyFrom:indent+1
                                             ] ifFalse:[
                                                line
                                             ].
                                        ]
                            ].                        
                        ].
                        macroTextView contents:macro.
                       ].

    list1 := SelectionInList with:listOfRawKeys.
    list1 onChangeSend:#showFunction to:selectionForwarder.

    list2 := SelectionInList with:listOfFunctions.
    list2 onChangeSend:#showRawKey to:selectionForwarder.
    list2 onChangeEvaluate:macroForwarder.

    box := Dialog new.
    box label:(resources string:'Keyboard Mappings').

    l := box addTextLabel:(resources at:'KEY_MSG' default:'keyboard mapping:') withCRs.
    l adjust:#left; borderWidth:0.

    frame := View new.
    frame extent:300 @ 300.
    frame borderWidth:0.

    listView1 := ScrollableView for:SelectionInListView in:frame.
    listView1 model:list1.
    listView1 origin:0.0@0.0 corner:0.5@1.0; inset:2.

    listView2 := ScrollableView for:SelectionInListView in:frame.
    listView2 model:list2.
    listView2 origin:0.5@0.0 corner:1.0@1.0; inset:2.

    frame topInset:box yPosition.
    box addComponent:frame withExtent:350@200.
    box makeTabable:listView1. 
    box makeTabable:listView2. 
    frame origin:0.0@0.0 corner:1.0@0.6.

    box addVerticalSpace.

    l := box addTextLabel:(resources string:'Macro text (if any):') withCRs.
    l adjust:#left; borderWidth:0.
    l origin:0.0@0.6 corner:1.0@0.6.
    l topInset:(View viewSpacing).
    l bottomInset:(l preferredExtent y negated - View viewSpacing).

    macroTextView := HVScrollableView for:TextView miniScroller:true.
    box addComponent:macroTextView tabable:true.
    macroTextView origin:0.0@0.6 corner:1.0@1.0.
    y := box yPosition.

    box
        addHelpButtonFor:'Launcher/keyboardSetting.html';
        "addAbortButton;" 
        addOkButtonLabelled:(resources string:'Close' "'Dismiss'").

    macroTextView topInset:(l preferredExtent y + 5).
    macroTextView bottomInset:(box preferredExtent y - y).

    box open.

    box accepted ifTrue:[
        "no action yet ..."
    ].
    box destroy

    "Modified: / 9.9.1996 / 22:43:17 / stefan"
    "Modified: / 4.5.1998 / 12:40:02 / cg"
!

languageSettings 
    self languageSettingsFor:nil
!

languageSettingsFor:requestor 
    "open a dialog on language related settings"

    |listOfLanguages translatedLanguages switch box languageList flags resources|

    resources := self owningClass classResources.

    "
     get list of supported languages from the launchers resources ...
    "

    listOfLanguages := resources at:'LIST_OF_OFFERED_LANGUAGES' default:#('default').
    listOfLanguages := listOfLanguages asOrderedCollection.

    translatedLanguages := listOfLanguages collect:[:lang | |item|
                                        item := resources at:lang.
                                        item isString ifTrue:[
                                            item
                                        ] ifFalse:[
                                            item at:1
                                        ]
                                ].
    flags := listOfLanguages collect:[:lang | |item|
                                        item := resources at:lang.
                                        item isArray ifTrue:[
                                            item at:2
                                        ] ifFalse:[
                                            nil
                                        ]
                                ].
    flags := flags collect:[:nm | |img d| nm notNil ifTrue:[
                                            img := Image fromFile:nm.
                                            img isNil ifTrue:[
                                                d := Smalltalk getPackageDirectoryForPackage:'stx:goodies'.
                                                img := Image fromFile:(d construct:nm).
                                            ].
                                        ] ifFalse:[
                                            nil
                                        ]
                           ].
    listOfLanguages := listOfLanguages collect:[:nm | nm copyFrom:'LANG_' size + 1].
    languageList := translatedLanguages with:flags collect:[:lang :flag | LabelAndIcon icon:flag string:lang.].

    box := ListSelectionBox title:(resources at:'LANG_MSG' default:'Select a Language') withCRs.
    box label:(resources string:'Language Selection').
    box list:languageList.
    box initialText:(Language , '-' , LanguageTerritory).
    box action:[:newLanguage |
        WindowGroup activeGroup withWaitCursorDo:[
            |fontPref idx language oldLanguage territory enc 
             answer matchingFonts l screen|

            idx := translatedLanguages indexOf:newLanguage withoutSeparators.
            idx ~~ 0 ifTrue:[
                language := listOfLanguages at:idx
            ] ifFalse:[
                language := newLanguage
            ].
            (language includes:$-) ifTrue:[
                l := language asCollectionOfSubstringsSeparatedBy:$-.
                language := l at:1.
                territory := l at:2.
            ].
            territory isNil ifTrue:[
                territory := language copyTo:2
            ].

            "/ check if the new language needs a differently encoded font;
            "/ ask user to switch font and allow cancellation.
            "/ Otherwise, you are left with unreadable menu & button items ...

            oldLanguage := Smalltalk language.
            Smalltalk language:language asSymbol.
            ResourcePack flushCachedResourcePacks.
            "/ refetch resources ...
            resources := self owningClass classResources.
            fontPref := resources at:'PREFERRED_FONT_ENCODING' default:'iso8859*'.
            fontPref := fontPref asLowercase.    
            Smalltalk language:oldLanguage.

            switch := true.
            enc := MenuView defaultFont encoding.
            (fontPref match:enc asLowercase) ifFalse:[
                "/ look if there is one at all.
                screen := Screen current.
                matchingFonts := screen listOfAvailableFonts select:[:f | fontPref match:f encoding asLowercase].
                matchingFonts size == 0 ifTrue:[
                    "/ flush and try again - just in case, the font path has changed.
                    screen flushListOfAvailableFonts.
                    matchingFonts := screen listOfAvailableFonts select:[:f | fontPref match:f encoding asLowercase].
                ].
                matchingFonts size == 0 ifTrue:[
                    (Dialog 
                        confirm:(resources 
                                    string:'Your display does not offer any %1-encoded font.\\Change the language anyway ?\ (texts will probably be unreadable then)'
                                      with:fontPref) withCRs)
                    ifFalse:[
                        switch := false
                    ]
                ] ifFalse:[
                    answer := Dialog 
                                confirmWithCancel:(resources 
                                                        string:'menu font is not %1-encoded.\\Change it ?'
                                                        with:fontPref) withCRs
                                           labels:(resources
                                                        array:#('cancel' 'no' 'yes'))
                                           default:3.
                    answer isNil ifTrue:[
                        switch := false
                    ] ifFalse:[
                        answer ifTrue:[
                            switch := (requestor fontBoxForEncoding:fontPref)
                        ]
                    ].
                ].
            ].

            switch ifTrue:[
                Transcript showCR:'change language to ' , newLanguage , ' ...'.
                Smalltalk language:language asSymbol.
                Smalltalk languageTerritory:territory asSymbol.
                "/ ResourcePack flushCachedResourcePacks - already done by language-change
            ].
        ].
        switch ifTrue:[
            requestor reopenLauncher.
            DebugView newDebugger.
        ]
    ].    
    box
        addHelpButtonFor:'Launcher/languageSetting.html'.
    box open.
    box destroy

    "Modified: / 9.9.1996 / 22:43:27 / stefan"
    "Modified: / 16.11.2001 / 11:51:35 / cg"
!

memorySettings
    "open a dialog on objectMemory related settings"

    |box igcLimit igcFreeLimit igcFreeAmount newSpaceSize
     compressLimit
     oldIncr component fields codeLimit codeTrigger stackLimit resources
     fastMoreLimit maxOldSpace models info acceptChannel|

    acceptChannel := false asValue.

    resources := self owningClass classResources.

    "/
    "/ extract relevant system settings ...
    "/
    igcLimit := ObjectMemory incrementalGCLimit asValue.
    igcFreeLimit := ObjectMemory freeSpaceGCLimit asValue.
    igcFreeAmount := ObjectMemory freeSpaceGCAmount asValue.
    newSpaceSize := ObjectMemory newSpaceSize asValue.
    oldIncr := ObjectMemory oldSpaceIncrement asValue.
    compressLimit := ObjectMemory oldSpaceCompressLimit asValue.
    codeLimit := ObjectMemory dynamicCodeLimit asValue.
    codeTrigger := ObjectMemory dynamicCodeGCTrigger asValue.
    stackLimit := Process defaultMaximumStackSize asValue.
    fastMoreLimit := (ObjectMemory fastMoreOldSpaceLimit:-1) asValue.
    maxOldSpace := ObjectMemory maxOldSpace asValue.

    models := OrderedCollection new.
    info := OrderedCollection new.
    models add:newSpaceSize.    info add:#(number      'Size of newSpace where objects are created'                    'Size of NewSpace:' ).
    models add:fastMoreLimit.   info add:#(number      'Quickly allocate more memory (suppress GC) up to this limit'   'Quick Allocation Limit:').
    models add:maxOldSpace.     info add:#(number      'Never allocate more than this amount of memory'                'Maximum Memory Limit:').
    models add:igcLimit.        info add:#(number      'Start IGC whenever this amount has been allocated'             'Incremental GC Allocation Trigger:').
    models add:igcFreeLimit.    info add:#(number      'Start IGC whenever freespace drops below this'                 'Incremental GC Freespace Trigger:').
    models add:igcFreeAmount.   info add:#(number      'Try to keep this amount for peak requests'                     'Incremental GC Amount:').
    models add:oldIncr.         info add:#(number      'Increase oldSpace in chunks of this size'                      'Oldspace Increment:').
    models add:compressLimit.   info add:#(number      'Use 2-pass compressing GC if > 0 and more memory is in use'    'Oldspace Compress Limit:').
    models add:stackLimit.      info add:#(number      'Trigger recursionInterrupt if more stack is used by a process' 'Stack Limit:').
    models add:codeLimit.       info add:#(numberOrNil 'Flush dynamic compiled code to stay within this limit'         'Dynamic code Limit:').
    models add:codeTrigger.     info add:#(numberOrNil 'Start incremental GC whenever this amount of code has been allocated' 'Dynamic Code GC Trigger:').

    "/
    "/ create a box on those values ...
    "/
    fields := OrderedCollection new.

    box := DialogBox new.
    box label:(resources string:'Memory Manager Settings').

    (box addTextLabel:'Warning - invalid settings may result in failures or poor performance
' , 'You have been warned' allBold , '.') adjust:#left.
    box addHorizontalLine.

    models with:info do:[:m :i |
        |lbl descr conv|

        conv := i at:1.
        lbl := i at:3.
        descr := i at:2.

        component := box 
                    addLabelledInputField:(resources string:lbl)
                    adjust:#right
                    on:nil "/ newSpaceSize 
                    tabable:true
                    separateAtX:0.7.
        component acceptOnLeave:false.
"/        component converter:(PrintConverter new perform:conv).
        component model:((TypeConverter on:m) perform:conv).
        component acceptChannel:acceptChannel.
        fields add:component.

        (box addTextLabel:descr) adjust:#left.
        box addHorizontalLine.
    ].

    ObjectMemory supportsJustInTimeCompilation ifFalse:[
        (fields at:9) disable.
        (fields at:10) disable.
    ].

    box addAbortAndOkButtons.
    box
        addHelpButtonFor:'Launcher/memorySettings.html'.

    "/
    "/ show the box ...
    "/
    box open.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
        acceptChannel value:true.

        igcFreeAmount value ~~ ObjectMemory freeSpaceGCAmount ifTrue:[
            ObjectMemory freeSpaceGCAmount:igcFreeAmount value.
        ].
        igcFreeLimit value ~~ ObjectMemory freeSpaceGCLimit ifTrue:[
            ObjectMemory freeSpaceGCLimit:igcFreeLimit value.
        ].
        igcLimit value ~~ ObjectMemory incrementalGCLimit ifTrue:[
            ObjectMemory incrementalGCLimit:igcLimit value.
        ].
        newSpaceSize value ~~ ObjectMemory newSpaceSize ifTrue:[
            ObjectMemory newSpaceSize:newSpaceSize value.
        ].
        oldIncr value ~~ ObjectMemory oldSpaceIncrement ifTrue:[
            ObjectMemory oldSpaceIncrement:oldIncr value.
        ].
        stackLimit value ~~ Process defaultMaximumStackSize ifTrue:[
            Process defaultMaximumStackSize:stackLimit value.
        ].
        fastMoreLimit value ~~ (ObjectMemory fastMoreOldSpaceLimit:-1) ifTrue:[
            ObjectMemory fastMoreOldSpaceLimit:fastMoreLimit value.
        ].
        maxOldSpace value ~~ ObjectMemory maxOldSpace ifTrue:[
            ObjectMemory maxOldSpace:maxOldSpace value.
        ].
        ObjectMemory oldSpaceCompressLimit:compressLimit value.
        ObjectMemory dynamicCodeLimit:codeLimit value.
        ObjectMemory dynamicCodeGCTrigger:codeTrigger value.
    ].
    box destroy

    "Modified: 27.2.1997 / 16:50:12 / cg"
!

messageSettings
    "open a dialog on infoMessage related settings"

    |box vmInfo vmErrors displayErrors classInfos resources|

    resources := self owningClass classResources.

    vmInfo := ObjectMemory infoPrinting asValue.
    vmErrors := ObjectMemory debugPrinting asValue.
    classInfos := Object infoPrinting asValue.
    displayErrors := DeviceWorkstation errorPrinting asValue.

    box := DialogBox new.
    box label:(resources string:'Messages').

    box addCheckBox:(resources string:'VM Info Messages') on:vmInfo.
    box addCheckBox:(resources string:'VM Error Messages') on:vmErrors.
    box addHorizontalLine.

    box addCheckBox:(resources string:'Display Error Messages (Xlib, Xtlib, WinAPI ...)') on:displayErrors.
    box addCheckBox:(resources string:'Other Info Messages') on:classInfos.
    box addHorizontalLine.

    box addHelpButtonFor:'Launcher/messageSettings.html'.
    box addAbortAndOkButtons.
    box open.

    box accepted ifTrue:[
        ObjectMemory infoPrinting:vmInfo value.
        ObjectMemory debugPrinting:vmErrors value.
        Object infoPrinting:classInfos value.
        DeviceWorkstation errorPrinting:displayErrors value.
    ].
    box destroy

    "Modified: 27.1.1997 / 17:46:01 / cg"
!

miscSettings
    "open a dialog on misc other settings"

    |box pos pos2 check butt shadows takeFocus focusFollowsMouse returnFocus  
     hostNameInLabel showAccelerators 
     preemptive dynamicPrios hostNameInLabelHolder resources
     activateOnClick opaqueVariablePanelResize opaqueTableColumnResize currentUserPrefs
     beepEnabled newWindowLabelFormat|

    resources := self owningClass classResources.
    currentUserPrefs := UserPreferences current.

    "/ 
    "/ extract relevant system settings ...
    "/
    shadows := PopUpView shadows asValue.
    beepEnabled := currentUserPrefs beepEnabled asValue.

    hostNameInLabel := StandardSystemView includeHostNameInLabel.
    hostNameInLabelHolder := hostNameInLabel asValue.
    returnFocus := StandardSystemView returnFocusWhenClosingModalBoxes asValue.
    takeFocus := StandardSystemView takeFocusWhenMapped asValue.
    focusFollowsMouse := (currentUserPrefs focusFollowsMouse ? true) asValue.
    activateOnClick := (Display activateOnClick:nil) asValue.
    opaqueVariablePanelResize := currentUserPrefs opaqueVariablePanelResizing asValue.
    opaqueTableColumnResize := currentUserPrefs opaqueTableColumnResizing asValue.

    showAccelerators := MenuView showAcceleratorKeys asValue.
    preemptive := Processor isTimeSlicing asValue.
    dynamicPrios := Processor supportDynamicPriorities asValue.

    "/
    "/ create a box on those values ...
    "/
    box := DialogBox new.
    box label:(resources string:'Other settings').

    box addCheckBox:(resources string:'Shadows under PopUp Views') on:shadows.
    box addCheckBox:(resources string:'Beeper enabled') on:beepEnabled.
    box addCheckBox:(resources string:'Boxes Return Focus to Previously Active View') on:returnFocus.
    box addCheckBox:(resources string:'Views Catch Focus when Mapped') on:takeFocus.
    pos := box yPosition.
    check := box addCheckBox:(resources string:'Hostname in Window Labels') on:hostNameInLabelHolder.
    check width:0.6.
    pos2 := box yPosition.
    box yPosition:pos.
    butt := box addComponent:(Button label:(resources string:'Format...') 
               action:[
                       |newFormat|

                       newFormat := Dialog request:
                                        'Define the Format of Window Labels:\\  %1 - Label\  %2 - Hostname\  %3 - Username\  %4 - ProcessId\'  
                                           withCRs initialAnswer:StandardSystemView windowLabelFormat.

                       newFormat size > 0 ifTrue:[
                           newWindowLabelFormat := newFormat
                       ].
                      ]).
    box makeTabable:butt.
    butt left:0.6; width:0.4.
    box yPosition:(box yPosition max:pos2).

    box addCheckBox:(resources string:'Show Accelerator Keys in Menus') on:showAccelerators.
    box addCheckBox:(resources string:'Raise & Activate Windows on Click') on:activateOnClick.
    box addCheckBox:(resources string:'Focus Follows Mouse') on:focusFollowsMouse.
    box addCheckBox:(resources string:'Opaque Variable Panel Resizing') on:opaqueVariablePanelResize.
    box addCheckBox:(resources string:'Opaque Table Column Resizing') on:opaqueTableColumnResize.

    box addHorizontalLine.

    box addCheckBox:(resources string:'Preemptive Scheduling') on:preemptive.
    box leftIndent:20.
    check := box addCheckBox:(resources string:'Dynamic Priorities') on:dynamicPrios.
    check enableChannel:preemptive.
    box leftIndent:0.

    box addHorizontalLine.
    box 
        addHelpButtonFor:'Launcher/miscSettings.html';
        addAbortAndOkButtons.

    "/
    "/ show the box ...
    "/
    box open.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
        PopUpView shadows:shadows value.
        (hostNameInLabelHolder value ~= hostNameInLabel 
        or:[newWindowLabelFormat ~= StandardSystemView windowLabelFormat]) ifTrue:[ 
            StandardSystemView includeHostNameInLabel:hostNameInLabelHolder value.
            newWindowLabelFormat notNil ifTrue:[
                StandardSystemView windowLabelFormat:newWindowLabelFormat
            ].

            Screen allScreens do:[:aDisplay |
                aDisplay allViewsDo:[:aView |
                    |l|

                    aView isTopView ifTrue:[
                        l := aView label.
                        l notNil ifTrue:[
                            aView label:(l , ' '); label:l.  "/ force a change
                        ]
                    ]
                ]
            ]
        ].

        currentUserPrefs opaqueVariablePanelResizing:opaqueVariablePanelResize value.
        currentUserPrefs opaqueTableColumnResizing:opaqueTableColumnResize value.

        currentUserPrefs beepEnabled:beepEnabled value.

        StandardSystemView returnFocusWhenClosingModalBoxes:returnFocus value.
        StandardSystemView takeFocusWhenMapped:takeFocus value.
        currentUserPrefs focusFollowsMouse:focusFollowsMouse value.
        Screen current activateOnClick:(activateOnClick value).

        MenuView showAcceleratorKeys:showAccelerators value.
        Processor isTimeSlicing ~~ preemptive value ifTrue:[
            preemptive value ifTrue:[
                Processor startTimeSlicing
            ] ifFalse:[
                Processor stopTimeSlicing
            ]
        ].
        Processor supportDynamicPriorities ~~ dynamicPrios value ifTrue:[
            Processor supportDynamicPriorities:dynamicPrios value
        ].
    ].
    box destroy

    "Modified: / 9.9.1996 / 22:43:36 / stefan"
    "Modified: / 20.5.1999 / 18:33:55 / cg"
    "Modified: / 3.12.1999 / 17:11:38 / ps"
!

printerSettings
    "open a dialog on printer related settings; returns true if accepted"

    |box accepted
     possiblePrinters possibleTypes printerType printCommand 
     pageFormat landscape updater
     formatLabel formatComponent landscapeLabel landscapeComponent
     topMargin leftMargin rightMargin bottomMargin unitList unit
     topMarginComponent leftMarginComponent
     rightMarginComponent
     bottomMarginComponent supportsColor supportsColorComponent
     y y1 commandListPop component commandList row resources|

    resources := self owningClass classResources.

    possiblePrinters := PrinterStream withAllSubclasses asArray.
    possibleTypes := possiblePrinters collect:[:cls | cls printerTypeName].

    printerType := SelectionInList new list:(resources array:possibleTypes).
    printerType selectionIndex:(possiblePrinters identityIndexOf:Printer).
    printCommand := Printer printCommand asValue.

    pageFormat := SelectionInList new list:(Printer defaultPageFormats).
    pageFormat selection:(Printer pageFormat).
    landscape := Printer landscape asValue.

    topMargin := Printer topMargin asValue.
    leftMargin := Printer leftMargin asValue.
    rightMargin := Printer rightMargin asValue.
    bottomMargin := Printer bottomMargin asValue.
    supportsColor := Printer supportsColor asValue.

    box := DialogBox new.
    box label:(resources string:'Printer Settings').

"/ either use a popUpList ...
"/    box addPopUpList:(resources string:'printer type:') on:printerType.

"/ or a comboList;
"/ which one looks better ?
    y := box yPosition.
    component := box addTextLabel:(resources string:'Printer Type:').
    component width:0.25; adjust:#right; borderWidth:0.
    box yPosition:y.
    component := box addComboListOn:printerType tabable:true.
    component aspect:#selectionIndex; changeMessage:#selectionIndex:; useIndex:true.
    component width:0.75; left:0.25.
"/ end of question

    y := box yPosition.
    component := box addTextLabel:(resources string:'Print Command:').
    component width:0.25; adjust:#right; borderWidth:0.
    box yPosition:y.
    commandListPop := box addComboBoxOn:printCommand tabable:true.
"/    commandListPop := box addInputFieldOn:printCommand tabable:true.
    commandListPop width:0.75; left:0.25; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
    "/ some common print commands ...

    commandList := resources at:'PRINT_COMMANDS' ifAbsent:nil.
    commandList isNil ifTrue:[
        commandList := PrinterStream defaultCommands.
        commandList isNil ifTrue:[
            commandList := #('lpr' 
                             'lp' 
                            ).
        ]
    ].

    commandListPop list:commandList.

    box addVerticalSpace; addHorizontalLine; addVerticalSpace.

    row := OrderedCollection new.
    row add:(formatLabel := Label label:(resources string:'Page Format:')).
    formatLabel borderWidth:0.
    row add:(formatComponent := PopUpList on:pageFormat).
    formatComponent label:'unknown'.

    row add:(landscapeLabel := Label label:(resources string:'Landscape:')).
    landscapeLabel borderWidth:0.
    row add:(landscapeComponent := CheckToggle on:landscape).

    y := box yPosition.
    box
        addRow:(1 to:2)
        fromX:0
        toX:0.5
        collect:[:idx | row at:idx]
        tabable:false
        horizontalLayout:#leftSpace
        verticalLayout:#center.
    y1 := box yPosition.
    box yPosition:y.

    box
        addRow:(3 to:4)
        fromX:0.5
        toX:1.0
        collect:[:idx | row at:idx]
        tabable:false
        horizontalLayout:#leftSpace
        verticalLayout:#center.

    box yPosition:(box yPosition max:y1).

    box makeTabable:(formatComponent).
    box makeTabable:(landscapeComponent).

    box addVerticalSpace; addHorizontalLine; addVerticalSpace.

    y := box yPosition.

    topMarginComponent := box 
        addLabelledInputField:(resources string:'Top Margin:')
        adjust:#right
        on:nil "/ topMargin 
        tabable:true
        from:0.0 to:0.5
        separateAtX:0.6.
    topMarginComponent converter:(PrintConverter new initForNumber).
    topMarginComponent model:topMargin.
    y1 := box yPosition.

    box yPosition:y.
    unitList := SelectionInList with:#('inch' 'mm').
    unitList selectionIndex:1.

    component := box addComponent:(PopUpList on:unitList).
    component
        left:0.6;
        width:0.3.

    box yPosition:y1.

    leftMarginComponent := box 
        addLabelledInputField:(resources string:'Left Margin:')
        adjust:#right
        on:nil "/ leftMargin 
        tabable:true
        from:0.0 to:0.5
        separateAtX:0.6.
    leftMarginComponent converter:(PrintConverter new initForNumber).
    leftMarginComponent model:leftMargin.

    rightMarginComponent := box 
        addLabelledInputField:(resources string:'Right Margin:')
        adjust:#right
        on:nil "/ rightMargin 
        tabable:true
        from:0.0 to:0.5
        separateAtX:0.6.
    rightMarginComponent converter:(PrintConverter new initForNumber).
    rightMarginComponent model:rightMargin.

    bottomMarginComponent := box 
        addLabelledInputField:(resources string:'Bottom Margin:')
        adjust:#right
        on:nil "/ bottomMargin 
        tabable:true
        from:0.0 to:0.5
        separateAtX:0.6.
    bottomMarginComponent converter:(PrintConverter new initForNumber).
    bottomMarginComponent model:bottomMargin.

    box addHorizontalLine.
    supportsColorComponent := box addCheckBox:(resources string:'Color Printer') on:supportsColor.
    box addVerticalSpace.

    updater := [ |p fg hasPageSize hasMargins|

                       printerType selectionIndex ~~ 0 ifTrue:[
                           p := possiblePrinters at:(printerType selectionIndex).
                           hasPageSize := p supportsPageSizes. 
                           hasMargins := p supportsMargins. 
                       ] ifFalse:[
                           hasPageSize := false.
                           hasMargins := false.
                       ].
                       hasPageSize ifTrue:[
                          fg := Button new foregroundColor.
                          formatComponent enable.
                          landscapeComponent enable.

                          formatComponent label:p pageFormat.
                          pageFormat value:(p pageFormat).
                          landscape value:(p landscape).
                       ] ifFalse:[ 
                          fg := Button new disabledForegroundColor.
                          formatComponent disable.
                          landscapeComponent disable.

                          formatComponent label:'unknown'.
                          landscape value:nil.
                       ].
                       hasMargins ifTrue:[
                          unitList selectionIndex == 2 ifTrue:[
                              unit := #mm
                          ] ifFalse:[
                              unit := #inch
                          ].

                          topMargin value:(UnitConverter convert:p topMargin from:#inch to:unit).
                          leftMargin value:(UnitConverter convert:p leftMargin from:#inch to:unit).
                          rightMargin value:(UnitConverter convert:p rightMargin from:#inch to:unit).
                          bottomMargin value:(UnitConverter convert:p bottomMargin from:#inch to:unit).

                          topMarginComponent enable.
                          leftMarginComponent enable.
                          rightMarginComponent enable.
                          bottomMarginComponent enable.
                       ] ifFalse:[ 
                          topMarginComponent disable.
                          leftMarginComponent disable.
                          rightMarginComponent disable.
                          bottomMarginComponent disable.
                       ].
                       formatLabel foregroundColor:fg.
                       landscapeLabel foregroundColor:fg.

                       p notNil ifTrue:[ 
                           commandList := p defaultCommands.
                           commandList notNil ifTrue:[
                                commandListPop list:commandList 
                           ].

                           printCommand value:(p printCommand).
                       ].
                       p supportsPostscript ifFalse:[
                           supportsColorComponent disable.
                           supportsColor value:false
                       ] ifTrue:[
                           supportsColorComponent enable.
                           supportsColor value:(Printer supportsColor).
                       ]
                     ].
    unitList onChangeEvaluate:updater.
    printerType onChangeEvaluate:updater.
    updater value.

    box addHorizontalLine.
    box addVerticalSpace;
        addHelpButtonFor:'Launcher/printerSettings.html';
        addAbortAndOkButtons.
    box open.

    (accepted := box accepted) ifTrue:[
        Printer := possiblePrinters at:(printerType selectionIndex).
        Printer printCommand:printCommand value.

        Printer supportsPageSizes ifTrue:[
            Printer pageFormat:(pageFormat selection).
            Printer landscape:(landscape value).
        ].
        Printer supportsMargins ifTrue:[
            unitList selectionIndex == 2 ifTrue:[
                unit := #mm
            ] ifFalse:[
                unit := #inch
            ].
            Printer topMargin:(UnitConverter convert:topMargin value from:unit to:#inch).
            Printer leftMargin:(UnitConverter convert:leftMargin value from:unit to:#inch).
            Printer rightMargin:(UnitConverter convert:rightMargin value from:unit to:#inch).
            Printer bottomMargin:(UnitConverter convert:bottomMargin value from:unit to:#inch).
        ].
        Printer supportsPostscript ifTrue:[
            Printer supportsColor:supportsColor value.
        ].
    ].
    box destroy.
    ^ accepted

    "Modified: 9.9.1996 / 22:43:51 / stefan"
    "Modified: 28.2.1997 / 14:00:13 / cg"
!

restoreSettings
    "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.
     Will move entries over to UserPreferences over time;
     new items should always go there."

    |fileName resources|

    resources := self owningClass classResources.

    fileName := Dialog 
        requestFileName:(resources string:'restore settings from:') 
        default:'settings.stx'
        ok:(resources string:'restore') 
        abort:(resources string:'cancel') 
        pattern:'*.stx'
        fromDirectory:nil.

    (fileName size == 0) ifTrue:[
        "/ canceled
        ^ self
    ].

    self withWaitCursorDo:[
        Smalltalk fileIn:fileName.

        self reopenLauncher.
    ].

    "Modified: / 21.7.1998 / 11:37:54 / cg"
!

saveSettings
    "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."

    |fileName resources|

    resources := self 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 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"
!

sourceAndDebuggerSettings
    "open a dialog on source&debugger other settings"

    |box check butt setupButt logDoits updChanges changeFileName
     useManager hasManager cvsIsSetup
     repository repositoryHolder localSourceFirst 
     sourceCacheDir cacheEntry
     component localCheck oldIndent nm fn manager
     showErrorNotifier showVerboseStack
     syntaxColoring fullSelectorCheck autoFormat
     resources pos currentUserPrefs checkClassesWhenCheckingIn checkClassesBox|

    currentUserPrefs := UserPreferences current.

    resources := self owningClass classResources.

    "/ 
    "/ extract relevant system settings ...
    "/
    logDoits := Smalltalk logDoits asValue.
    updChanges := Class updatingChanges asValue.
    changeFileName := ObjectMemory nameForChanges asValue.

    (AbstractSourceCodeManager notNil 
    and:[AbstractSourceCodeManager isLoaded not]) ifTrue:[
        AbstractSourceCodeManager autoload.    
    ].

    hasManager := AbstractSourceCodeManager notNil
                  and:[AbstractSourceCodeManager isLoaded].

    repositoryHolder := '' asValue.
    hasManager ifTrue:[
        useManager := (manager := Smalltalk at:#SourceCodeManager) notNil asValue.
        localSourceFirst := Class tryLocalSourceFirst asValue.
        manager notNil ifTrue:[
            manager forgetDisabledModules.
            repository := manager repositoryName.
            repository notNil ifTrue:[
                repositoryHolder := repository asValue.
            ] ifFalse:[
                repositoryHolder := '' asValue.
            ].
        ].
        cvsIsSetup := true.
    ] ifFalse:[
        useManager := false.
        localSourceFirst := false.
        cvsIsSetup := false.
    ].
    cvsIsSetup := cvsIsSetup asValue.
    showErrorNotifier := (Exception emergencyHandler == AbstractLauncherApplication notifyingEmergencyHandler) asValue.
    showVerboseStack := (DebugView defaultVerboseBacktrace ? false) asValue.
    syntaxColoring := currentUserPrefs syntaxColoring asValue.
    fullSelectorCheck := currentUserPrefs fullSelectorCheck asValue.
    autoFormat := currentUserPrefs autoFormatting asValue.

    sourceCacheDir := nil asValue.
    checkClassesWhenCheckingIn := (currentUserPrefs at:#checkClassesWhenCheckingIn ifAbsent:true) asValue.

    "/
    "/ create a box on those values ...
    "/
    box := DialogBox new.
    box label:(resources string:'Source & Debugger Settings').

    box addCheckBox:(resources string:'Log compiles in Changefile') on:updChanges.
    box addCheckBox:(resources string:'Log doIts in Changefile') on:logDoits.

    component := box 
                    addLabelledInputField:(resources string:'Changefile Name:')
                    adjust:#right
                    on:changeFileName 
                    tabable:true
                    separateAtX:0.4.
    component immediateAccept:true; acceptOnLeave:false.

"/    y := box yPosition.
"/    component := box addTextLabel:(resources string:'change file name:').
"/    component width:0.5; adjust:#right; borderWidth:0.
"/    box yPosition:y.
"/    component := box addInputFieldOn:changeFileName tabable:true.
"/    component width:0.5; left:0.5; immediateAccept:true; acceptOnLeave:false.

    box addHorizontalLine.

    hasManager ifTrue:[
        pos := box yPosition.
        check := box addCheckBox:(resources string:'Sourcecode Management') on:useManager.
        check enableChannel:cvsIsSetup.
        box makeTabable:check.

        CVSSourceCodeManager notNil ifTrue:[
            check width:0.6.
            box yPosition:pos.
            setupButt := box addComponent:(Button label:(resources string:'Setup...') 
                       action:[|manager|

                               self cvsConfigurationDialog.
                               manager := (Smalltalk at:#SourceCodeManager).
                               cvsIsSetup value:manager notNil.
                               manager notNil ifTrue:[
                                    repositoryHolder value: manager repositoryName.
                                    sourceCacheDir value:(AbstractSourceCodeManager cacheDirectoryName).
                               ].
                              ]).
            setupButt enableChannel:useManager.    
            box makeTabable:setupButt.
            setupButt left:0.6; width:0.4.
        ].
        oldIndent := box leftIndent.
        box leftIndent:30.

        box addVerticalSpace:10.
"/        component := box 
"/                        addLabelledInputField:(resources string:'CVS repository:')
"/                        adjust:#right
"/                        on:repositoryHolder 
"/                        tabable:true
"/                        separateAtX:0.5.
"/        component immediateAccept:true; acceptOnLeave:false.
"/        component enableChannel:useManager.
"/        component readOnly:true. 
"/
        cacheEntry := box 
                        addLabelledInputField:(resources string:'Source Cache Dir:')
                        adjust:#right
                        on:sourceCacheDir 
                        tabable:true
                        separateAtX:0.5.
        cacheEntry immediateAccept:true; acceptOnLeave:false.
        cacheEntry enableChannel:useManager.

        pos := box yPosition.
        butt := Button label:(resources string:'Flush Cache now').
        butt action:[ box withWaitCursorDo:[ AbstractSourceCodeManager flushSourceCache ] ].
        box addComponent:butt tabable:true.
        butt left:0.6; width:0.4; leftInset:0.
        butt enableChannel:useManager.

        butt := Button label:(resources string:'Condense Cache now').
        butt action:[ box withWaitCursorDo:[ AbstractSourceCodeManager condenseSourceCache ] ].
        box addComponent:butt tabable:true.
        butt left:0.6; width:0.4; leftInset:0.
        butt enableChannel:useManager.

        localCheck := box addCheckBox:(resources string:'If Present, Use Local Source (Suppress Checkout)') on:localSourceFirst.
        localCheck enableChannel:useManager.

        checkClassesBox := box addCheckBox:(resources string:'Check for halt/error-Sends when Checking in') on:checkClassesWhenCheckingIn.
        checkClassesBox enableChannel:useManager.

        box leftIndent:oldIndent.

        (AbstractSourceCodeManager isNil 
        or:[AbstractSourceCodeManager defaultManager isNil]) ifTrue:[
            useManager value:false.
            "/ cacheEntry disable.
            "/ localCheck enable.
        ] ifFalse:[
            sourceCacheDir value:(AbstractSourceCodeManager cacheDirectoryName).
        ].
        box addHorizontalLine.
    ].

    pos := box yPosition.
    check := box addCheckBox:(resources string:'Syntax Coloring') on:syntaxColoring.
    check width:0.6.
    box yPosition:pos.
    butt := box addComponent:(Button label:(resources string:'Configure...') action:[self syntaxColorConfigurationDialog]).
    box makeTabable:butt.
    butt enableChannel:syntaxColoring.
    butt left:0.6; width:0.4.

    check := box addCheckBox:(resources string:'Immediate Selector Check') on:fullSelectorCheck.
    check enableChannel:syntaxColoring.

    pos := box yPosition.
    check := box addCheckBox:(resources string:'Auto Format') on:autoFormat.
    check width:0.6.
    box yPosition:pos.
    butt := box addComponent:(Button label:(resources string:'Configure...') action:[self formattingConfigurationDialog]).
    box makeTabable:butt.
    butt left:0.6; width:0.4.

    box addHorizontalLine.


    box addCheckBox:(resources string:'Show Error Notifier before Opening Debugger') on:showErrorNotifier.
    box addCheckBox:(resources string:'Verbose Backtrace by Default in Debugger') on:showVerboseStack.

    box addHorizontalLine.
    box 
        addHelpButtonFor:'Launcher/sourceSettings.html';
        addAbortAndOkButtons.

    box maxExtent:1000@600.

    "/
    "/ show the box ...
    "/
    box open.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
        Smalltalk logDoits:logDoits value.
        Class updateChanges:updChanges value.
        ObjectMemory nameForChanges:changeFileName value.

        (hasManager and:[useManager value]) ifTrue:[
            manager isNil ifTrue:[
                Smalltalk at:#SourceCodeManager put:(AbstractSourceCodeManager defaultManager).
                manager := Smalltalk at:#SourceCodeManager.
            ].
            Class tryLocalSourceFirst:(localSourceFirst value).

            manager notNil ifTrue:[
"/                localSourceFirst value ifFalse:[

                    nm := sourceCacheDir value.
                    nm size > 0 ifTrue:[
                        (fn := nm asFilename) exists ifFalse:[
                            (self confirm:('CVS cache directory ''' , nm , ''' does not exists\create ?' withCRs)) ifTrue:[
                                fn makeDirectory; 
                                   makeReadableForAll;
                                   makeWritableForAll;
                                   makeExecutableForAll.
                            ]
                        ].
                        (fn exists 
                        and:[fn isDirectory
                        and:[fn isReadable
                        and:[fn isWritable]]]) ifTrue:[
                            AbstractSourceCodeManager cacheDirectoryName:(sourceCacheDir value).
                        ] ifFalse:[
                            self warn:'Invalid sourceCache directory.'
                        ]
                    ]
"/                ]
            ].

            repositoryHolder notNil ifTrue:[
                repositoryHolder value size > 0 ifTrue:[
                    manager notNil ifTrue:[
                        manager initializeForRepository:repositoryHolder value.
                    ]
                ].
            ].
        ] ifFalse:[
            Smalltalk at:#SourceCodeManager put:nil
        ].

        showErrorNotifier value ifFalse:[
            Exception emergencyHandler:nil
        ] ifTrue:[
            Exception emergencyHandler:(AbstractLauncherApplication notifyingEmergencyHandler)
        ].
        DebugView defaultVerboseBacktrace:(showVerboseStack value).
        currentUserPrefs syntaxColoring:syntaxColoring value.
        currentUserPrefs at:#fullSelectorCheck put:fullSelectorCheck value.
        currentUserPrefs autoFormatting:autoFormat value.

        UserPreferences current at:#checkClassesWhenCheckingIn put:checkClassesWhenCheckingIn value.
    ].
    box destroy

    "Modified: / 9.9.1996 / 22:43:36 / stefan"
    "Created: / 17.1.1997 / 17:39:33 / cg"
    "Modified: / 16.4.1998 / 17:18:47 / ca"
    "Modified: / 13.10.1998 / 15:47:31 / cg"
!

stcCompilerSettings
    "open an extra dialog on stc-compiler related settings"

    |box      
     stcIncludes stcDefines stcOptions
     stcLibraries stcLibraryPath cc stc ccOptions   
     linkCommand linkArgs
     component t
     canLoadBinaries thisIsADemoVersion
     resources|

    resources := self owningClass classResources.

    canLoadBinaries := ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles].

    stcIncludes := Compiler stcCompilationIncludes asValue.
    stcDefines := Compiler stcCompilationDefines asValue.
    stcOptions := Compiler stcCompilationOptions asValue.
    ccOptions := Compiler ccCompilationOptions asValue.

    cc := Compiler ccPath asValue.
    stc := Compiler stcPath asValue.
    linkCommand := ObjectFileLoader linkCommand asValue.
    linkArgs := ObjectFileLoader linkArgs asValue.

    ObjectFileLoader notNil ifTrue:[
        (t := ObjectFileLoader searchedLibraries) notNil ifTrue:[
            stcLibraries := (String fromStringCollection:t separatedBy:' ') asValue.
        ].
        (t := ObjectFileLoader libPath) notNil ifTrue:[
            stcLibraryPath := t asValue.
        ]
    ].

    box := DialogBox new.
    box label:(resources string:'STC Compilation Settings').

    thisIsADemoVersion := (Smalltalk releaseIdentification = 'ST/X_free_demo_vsn').
    ObjectFileLoader notNil ifTrue:[
        thisIsADemoVersion ifFalse:[

            component := box 
                            addLabelledInputField:(resources string:'stc Command:')
                            adjust:#right
                            on:stc 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(100 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

            component := box 
                            addLabelledInputField:(resources string:'stc Options:')
                            adjust:#right
                            on:stcOptions 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(250 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

            component := box 
                            addLabelledInputField:(resources string:'cc Command:')
                            adjust:#right
                            on:cc 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(150 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

            component := box 
                            addLabelledInputField:(resources string:'cc Options:')
                            adjust:#right
                            on:ccOptions 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(250 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

            component := box 
                            addLabelledInputField:(resources string:'Include Directories:')
                            adjust:#right
                            on:stcIncludes 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(250 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

"/        box addVerticalSpace.

            component := box 
                            addLabelledInputField:(resources string:'Defines:')
                            adjust:#right
                            on:stcDefines 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(250 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

"/        box addVerticalSpace.

"/        box addVerticalSpace.

            component := box 
                            addLabelledInputField:(resources string:'Link Command:')
                            adjust:#right
                            on:linkCommand 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(250 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

            component := box 
                            addLabelledInputField:(resources string:'Link Args:')
                            adjust:#right
                            on:linkArgs 
                            tabable:true
                            separateAtX:0.3.
            component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
            component preferredExtent:(250 @ component preferredExtent y).
            canLoadBinaries ifFalse:[component disable].

            stcLibraries notNil ifTrue:[
"/            box addVerticalSpace.

                component := box 
                                addLabelledInputField:(resources string:'C-libraries:')
                                adjust:#right
                                on:stcLibraries 
                                tabable:true
                                separateAtX:0.3.
                component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
                component preferredExtent:(250 @ component preferredExtent y).
                canLoadBinaries ifFalse:[component disable].
            ].

            stcLibraryPath notNil ifTrue:[
"/            box addVerticalSpace.

                component := box 
                                addLabelledInputField:(resources string:'stc LibPath:')
                                adjust:#right
                                on:stcLibraryPath 
                                tabable:true
                                separateAtX:0.3.
                component immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
                component preferredExtent:(250 @ component preferredExtent y).
                canLoadBinaries ifFalse:[component disable].
            ].
        ].
    ].

    box 
        addHelpButtonFor:'Launcher/compilerSettings.html';
        addAbortAndOkButtons.

    box open.

    box accepted ifTrue:[
        thisIsADemoVersion  ifFalse:[
            Compiler stcCompilationIncludes:stcIncludes value.
            Compiler stcCompilationDefines:stcDefines value.
            Compiler stcCompilationOptions:stcOptions value.
            Compiler ccCompilationOptions:ccOptions value.
            Compiler ccPath:cc value.
            stc value ~= Compiler stcPath ifTrue:[
                Compiler stcPath:stc value
            ].
            ObjectFileLoader linkCommand:linkCommand value.
            ObjectFileLoader linkArgs:linkArgs value.
        ].

        ObjectFileLoader notNil ifTrue:[
            stcLibraries notNil ifTrue:[
                ObjectFileLoader searchedLibraries:(stcLibraries value asCollectionOfWords).
            ].
            stcLibraryPath notNil ifTrue:[
                ObjectFileLoader libPath:(stcLibraryPath value).
            ]
        ].
    ].
    box destroy

    "Modified: / 10.9.1995 / 19:19:18 / claus"
    "Modified: / 9.9.1996 / 22:42:47 / stefan"
    "Created: / 2.10.1998 / 16:27:49 / cg"
    "Modified: / 21.10.1998 / 19:15:10 / cg"
!

toolSettings
    "open a dialog on tool settings"

    |box resources currentUserPrefs in acceptChannel
     useNewInspector useNewChangesBrowser useNewSystemBrowser useNewVersionDiffBrowser
     useNewFileBrowser showClockInLauncher showClock launcher transcriptBufferSize |

    currentUserPrefs := UserPreferences current.

    resources := self owningClass classResources.

    "/ 
    "/ extract relevant system settings ...
    "/
    useNewInspector := currentUserPrefs useNewInspector asValue.
    useNewChangesBrowser := currentUserPrefs useNewChangesBrowser asValue.
    useNewSystemBrowser := currentUserPrefs useNewSystemBrowser asValue.
    showClockInLauncher := currentUserPrefs showClockInLauncher asValue.
    useNewVersionDiffBrowser := currentUserPrefs useNewVersionDiffBrowser asValue.
    useNewFileBrowser := currentUserPrefs useNewFileBrowser asValue.
    transcriptBufferSize := Transcript current lineLimit printString asValue.

    acceptChannel := false asValue.

    "/
    "/ create a box on those values ...
    "/
    box := DialogBox new.
    box label:(resources string:'Tool Settings').


    box addCheckBox:(resources string:'Use the New Changes Browser') on:useNewChangesBrowser.
    box addHorizontalLine.
    box addCheckBox:(resources string:'Use the New System Browser') on:useNewSystemBrowser.
    box addHorizontalLine.
    box addCheckBox:(resources string:'Use the New VersionDiff Browser') on:useNewVersionDiffBrowser.
    box addHorizontalLine.
    (Smalltalk at:#FileBrowserV2) isBehavior ifTrue:[
        box addCheckBox:(resources string:'Use the New File Browser') on:useNewFileBrowser.
        box addHorizontalLine.
    ].
    box addCheckBox:(resources string:'Use Hierarchical Inspector') on:useNewInspector.
    box addHorizontalLine.
    box addCheckBox:(resources string:'Show Clock in Launcher') on:showClockInLauncher.
    box addHorizontalLine.
    in := box 
            addLabelledInputField:(resources string:'Transcripts Buffer Size:')
            adjust:#right
            on:transcriptBufferSize 
            tabable:true
            separateAtX:0.6.
    in acceptChannel:acceptChannel.
    box addHorizontalLine.

    box 
        addHelpButtonFor:'Launcher/toolSettings.html';
        addAbortAndOkButtons.

    "/
    "/ show the box ...
    "/
    box open.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
        acceptChannel value:false; value:true.

        currentUserPrefs useNewInspector:useNewInspector value.
        currentUserPrefs useNewChangesBrowser:useNewChangesBrowser value.
        currentUserPrefs useNewSystemBrowser:useNewSystemBrowser value.
        currentUserPrefs useNewVersionDiffBrowser:useNewVersionDiffBrowser value.
        currentUserPrefs useNewFileBrowser:useNewFileBrowser value.
        (Smalltalk at:#FileBrowserV2) isBehavior ifTrue:[
            useNewFileBrowser value ifTrue:[
                FileBrowserV2 installInLauncher.
            ] ifFalse:[
                FileBrowserV2 isLoaded ifTrue:[
                    FileBrowserV2 removeFromLauncher.
                ]
            ].
        ].
        showClock := showClockInLauncher value.
        currentUserPrefs showClockInLauncher ~= showClock ifTrue:[
            currentUserPrefs showClockInLauncher:showClock.
            launcher := Transcript application.
            (launcher isKindOf:ToolApplicationModel) ifTrue:[
                showClock ifTrue:[
                    launcher startClock
                ] ifFalse:[
                    launcher stopClock
                ]
            ]
        ].

        Inspector := currentUserPrefs inspectorClassSetting.

        transcriptBufferSize := Integer readFrom:transcriptBufferSize value onError:Transcript current lineLimit.
        Transcript current lineLimit:transcriptBufferSize.

    ].
    box destroy

    "Modified: / 9.9.1996 / 22:43:36 / stefan"
    "Modified: / 16.4.1998 / 17:18:47 / ca"
    "Created: / 13.10.1998 / 15:44:36 / cg"
    "Modified: / 12.11.2001 / 15:48:54 / cg"
!

viewStyleSettings
    self viewStyleSettingsFor:nil
!

viewStyleSettingsFor:requestor 
    "open a dialog on viewStyle related settings"

    |resourceDir dir box 
     list listView scrView infoLabel infoForwarder newStyle
     someRsrcFile didApply resources listUpdater showStandardStylesOnly standardStyles|

    showStandardStylesOnly := true asValue.
    standardStyles := #(
                        'decWindows'
                        'iris' 
                        'motif' 
                        'mswindows95' 
                        'next' 
                        'normal'
                        'os2' 
                        'st80' 
                       ).

    resources := self owningClass classResources.

    "
     search resources directory for a list of .style files ...
    "
    someRsrcFile := Smalltalk getSystemFileName:('resources' asFilename constructString:'normal.style').
    someRsrcFile isNil ifTrue:[
        someRsrcFile := Smalltalk getResourceFileName:'normal.style' forPackage:'stx:libview'.
        someRsrcFile isNil ifTrue:[
            someRsrcFile := Smalltalk getResourceFileName:'styles/normal.style' forPackage:'stx:libview'.
        ].
    ].
    someRsrcFile notNil ifTrue:[
        resourceDir := someRsrcFile asFilename directoryName
    ] ifFalse:[
        resourceDir := Smalltalk getSystemFileName:'resources'.
    ].

    resourceDir isNil ifTrue:[
        self warn:'no styles found (missing ''resources'' directory)'.
        ^ self
    ].
    dir := resourceDir asFilename directoryContents.

    list := SelectionInList new.

    listUpdater := [
        |listOfStyles lastSelection|

        lastSelection := list selection.
        listOfStyles := dir select:[:aFileName | aFileName asFilename hasSuffix:'style'].
        listOfStyles := listOfStyles collect:[:aFileName | aFileName asFilename withoutSuffix name].
        Filename isCaseSensitive ifFalse:[
            listOfStyles := listOfStyles collect:[:aStyleName | aStyleName asLowercase].
        ].
        listOfStyles remove:'generic' ifAbsent:nil; remove:'mswindows3' ifAbsent:nil.
        showStandardStylesOnly value ifTrue:[
            listOfStyles := listOfStyles select:[:aStyleName | standardStyles includes:aStyleName].
        ].

        listOfStyles sort.
        list list:listOfStyles.
        list selection:lastSelection.
    ].
    listUpdater value.

    showStandardStylesOnly onChangeEvaluate:listUpdater.

    infoForwarder := [
                        |nm sheet comment|

                        comment := ''.
                        nm := list selection.
                        nm notNil ifTrue:[
                            sheet := ViewStyle fromFile:(nm , '.style').
                            comment := (sheet at:#comment ifAbsent:'') withoutSeparators.
                        ].
                        comment := comment withCRs asStringCollection.
                        comment size == 1 ifTrue:[
                            comment := comment first
                        ].
                        infoLabel label:comment
                       ].

    list onChangeEvaluate:infoForwarder.

    box := Dialog new.
    box label:(resources string:'Style Selection').

    (box addTextLabel:(resources at:'STYLE_MSG' default:'Select a Style') withCRs) adjust:#left.
    listView := SelectionInListView on:list.
    listView doubleClickAction:[:sel | box acceptChannel value:true. box hide].
    box addCheckBox:(resources string:'standard styles only') on:showStandardStylesOnly.
    scrView := box addComponent:(ScrollableView forView:listView) tabable:true.

    box addVerticalSpace.

    (infoLabel := box addTextLabel:'\\' withCRs) adjust:#centerLeft.

    box addAbortAndOkButtons.
"/ mhmh - the newLauncher does not yet handle apply (without close) correctly
"/    b := box addButton:(Button label:(resources string:'apply')).
"/    b action:[didApply := true. requestor changeViewStyleTo:(list selection)].

    (standardStyles includes:View defaultStyle) ifFalse:[
        showStandardStylesOnly value:false
    ].
    list selection:(View defaultStyle).

    box stickAtBottomWithVariableHeight:scrView.
    box stickAtBottomWithFixHeight:infoLabel.
    didApply := false.
    box open.

    box destroy.
    box accepted ifTrue:[
        ((newStyle := list selection) ~= View defaultStyle
        or:[didApply ~~ true]) ifTrue:[
            requestor notNil ifTrue:[requestor changeViewStyleTo:newStyle].
        ].
    ].

    "
     self viewStyleSettingsFor:nil
    "

    "Modified: / 14.9.1998 / 20:33:59 / cg"
! !

!AbstractLauncherApplication::LauncherDialogs class methodsFor:'dialogs - file'!

objectModuleDialog
    "opens a moduleInfo dialog"

    <resource: #programMenu >

    |allModules moduleNames
     allObjects methodObjects methodNames 
     cObjects cObjectNames
     otherObjects otherObjectNames
     box l handles unloadButton unloadAndRemoveButton
     list1 list2 listView1 listView2
     y panel 
     showBuiltIn showModules showMethods showCObjects showOthers
     moduleListUpdater check canDoIt menu
     resources middleLabel|

    resources := self owningClass classResources.

    showBuiltIn := true asValue. 
    canDoIt := ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles].

    showModules := canDoIt asValue. 
    showMethods := canDoIt asValue.
    showCObjects := canDoIt asValue.
    showOthers := canDoIt asValue.

    list1 := SelectionInList new.
    list2 := SelectionInList new.

    moduleListUpdater := [
            |l|

            list2 list:nil.

            l := Array new.
            handles := Array new.

            (showModules value or:[showBuiltIn value]) ifTrue:[
                allModules := ObjectMemory binaryModuleInfo asOrderedCollection.
                (showBuiltIn value and:[showModules value]) ifFalse:[
                    allModules := allModules select:[:i |
                        |wantToSee|

                        wantToSee := i dynamic.
                        showBuiltIn value ifTrue:[
                            wantToSee := wantToSee not
                        ].
                        wantToSee
                    ]
                ].

                "/ sorting by reverse id brings newest ones to the top (a side effect)
                allModules sort:[:a :b | (a id) > (b id)].
                moduleNames := allModules collect:[:entry | entry name].
                l := l , moduleNames.
                handles := handles , allModules.
            ].

            showMethods value ifTrue:[
                allObjects := ObjectFileLoader loadedObjectHandles.
                methodObjects := (allObjects select:[:h | h isMethodHandle]) asArray.
                methodNames := methodObjects collect:[:mH | mH method isNil ifTrue:[
                                                                'compiled method - removed' " , ' (in ' , mH pathName , ')' "
                                                            ] ifFalse:[
                                                                'compiled method ' , mH method whoString  " , ' (in ' , mH pathName , ')' "
                                                            ].
                                                     ].
                l := l , methodNames.
                handles := handles , methodObjects.
            ].

            showCObjects value ifTrue:[
                allObjects := ObjectFileLoader loadedObjectHandles.
                cObjects := (allObjects select:[:h | h isFunctionObjectHandle]) asArray.
                cObjectNames := cObjects collect:[:entry | entry pathName].
                l := l , cObjectNames.
                handles := handles , cObjects.
            ].

            showOthers value ifTrue:[
                allObjects := ObjectFileLoader loadedObjectHandles.
                otherObjects := (allObjects select:[:h | (h isFunctionObjectHandle
                                                         or:[h isMethodHandle
                                                         or:[h isClassLibHandle]]) not]) asArray.
                otherObjectNames := otherObjects collect:[:entry | entry pathName].
                l := l , otherObjectNames.
                handles := handles , otherObjects.
            ].

            showBuiltIn value ifTrue:[
                l := #('VM') , l.
                handles := #(VM) , handles.
                allModules := #(VM) , allModules.
            ].

            list1 list:l.
            unloadButton disable.
            unloadAndRemoveButton disable.
        ].

    showBuiltIn onChangeEvaluate:moduleListUpdater.
    showModules onChangeEvaluate:moduleListUpdater.
    showMethods onChangeEvaluate:moduleListUpdater.
    showCObjects onChangeEvaluate:moduleListUpdater.
    showOthers onChangeEvaluate:moduleListUpdater.

    box := Dialog new.
    box label:(resources string:'ST/X & Module Version information').

    listView1 := HVScrollableView for:SelectionInListView miniScrollerH:true.
    listView1 model:list1.
    listView1 origin:0.0@0.0 corner:1.0@0.4. "/ ; inset:2.
    listView1 action:[:sel |
        |info classNames tabs module|

        listView1 middleButtonMenu:nil.

        box withWaitCursorDo:[
            |nm fileName addr entry1 entry2 entry3 method l|

            tabs := TabulatorSpecification unit:#inch positions:#(0 2.6 3.5).

            (showModules value or:[showBuiltIn value]) ifTrue:[
                info := allModules at:sel ifAbsent:nil.
            ].
            info isNil ifTrue:[
                "/ selected a method, cObject or unknown

                module := handles at:sel.
                fileName := module pathName.

                module isMethodHandle ifTrue:[
                    middleLabel label:'contains method:'.

                    (method := module method) isNil ifTrue:[
                        nm := '** removed **'.
                    ] ifFalse:[
                        menu := PopUpMenu
                                    labels:#('inspect' 'browse')
                                    selectors:#(inspect browse).
                        menu actionAt:#inspect put:[ method inspect ].
                        menu actionAt:#browse put:[ |who|
                                                    who := method who.
                                                    UserPreferences systemBrowserClass
                                                        openInClass:(who methodClass) 
                                                        selector:(who methodSelector) 
                                                  ].
                        listView1 middleButtonMenu:menu.

                        nm := (method whoString) asText emphasizeAllWith:(#color->Color blue).
                    ].
                    entry1 := MultiColListEntry new:2 tabulatorSpecification:tabs.
                    entry1 colAt:1 put:'compiled method'; colAt:2 put:nm.

                    entry2 := MultiColListEntry new:2 tabulatorSpecification:tabs.
                    entry2 colAt:1 put:'path'; colAt:2 put:fileName.

                    entry3 := MultiColListEntry new:2 tabulatorSpecification:tabs.
                    entry3 colAt:1 put:'address'; colAt:2 put:('(16r) ' , (method code address hexPrintString leftPaddedTo:8 with:$0)).

                    list2 list:(Array with:entry1 with:entry2 with:entry3).
                ] ifFalse:[
                    (module isFunctionObjectHandle 
                    and:[module functions notEmpty]) ifTrue:[
                        middleLabel label:'contains function:'.

                        menu := PopUpMenu
                                    labels:#('inspect')
                                    selectors:#(inspect).
                        menu actionAt:#inspect put:[ module functions inspect  ].
                        listView1 middleButtonMenu:menu.

                        list2 list:((module functions select:[:f | f notNil])
                                        collect:[:f | |entry|
                                                        entry := MultiColListEntry new:2 tabulatorSpecification:tabs.
                                                        entry colAt:1 put:(f name asText emphasizeAllWith:(#color->Color blue)).
                                                        entry colAt:2 put:('address: (16r) ' , (f code address hexPrintString leftPaddedTo:8 with:$0)).
                                                        entry
                                                ]).
                    ] ifFalse:[
                        list2 list:#('nothing known about contents (no functions have been extracted)').    
                    ]
                ].

                unloadButton enable.
                unloadAndRemoveButton disable.
            ] ifFalse:[
                info == #VM ifTrue:[
                    "/ dummy entry for VM;
                    "/ show file versions in lower view.

                    middleLabel label:'contains modules:'.
                    l := (ObjectMemory getVMIdentificationStrings).
                    l := l select:[:entry | entry includesString:'$Header'].
                    l := l select:[:entry | entry includesString:',v'].
                    l := l collect:[:entry |
                        |i1 i2 file revision date listEntry|

                        listEntry := MultiColListEntry new:3 tabulatorSpecification:tabs.

                        i1 := entry indexOfSubCollection:'librun'.
                        i1 ~~ 0 ifTrue:[
                            i2 := entry indexOfSubCollection:',v' startingAt:i1.
                            i2 ~~ 0 ifTrue:[
                                file := entry copyFrom:i1+7 to:(i2-1).
                                listEntry colAt:1 put:file.

                                i1 := i2+3.
                                i2 := entry indexOfSeparatorStartingAt:i1.
                                revision := entry copyFrom:i1 to:(i2-1).
                                listEntry colAt:2 put:revision.

                                i1 := i2+1.
                                i2 := entry indexOfSeparatorStartingAt:i1.
                                date := entry copyFrom:i1 to:(i2-1).
                                listEntry colAt:3 put:date.
                            ].
                        ].
                        listEntry.
                        "/ entry
                    ].
                    list2 list:l.
                
                    unloadButton disable.
                    unloadAndRemoveButton disable.
                ] ifFalse:[
                    "/ selected a package

                    "/ fill bottom list with class-info

                    middleLabel label:'contains classes:'.
                    classNames := info classNames asSortedCollection.
                    classNames := classNames select:[:cName |
                                    |cls|

                                    cls := Smalltalk classNamed:cName.
                                    cls isNil ifTrue:[
                                        true "a removed class"
                                    ] ifFalse:[
                                        cls isPrivate not
                                    ].
                                  ].

                    classNames := classNames collect:[:cName |
                                    |cls entry rev listEntry|

                                    listEntry := MultiColListEntry new:2 tabulatorSpecification:tabs.
                                    listEntry colAt:1 put:cName.

                                    cls := Smalltalk classNamed:cName.
                                    cls isNil ifTrue:[
                                        listEntry colAt:2 put:'(class removed)'.
                                    ] ifFalse:[
                                        rev := cls binaryRevision.
                                        rev notNil ifTrue:[
                                            cls isLoaded ifFalse:[
                                                entry := '(stub for: ' , rev.
                                            ] ifTrue:[
                                                entry :='(bin: ' , rev.
                                            ].    
                                            cls revision ~= rev ifTrue:[
                                                entry := entry , ' / src: ' , (cls revision printString)
                                            ].
                                            listEntry colAt:2 put:entry , ')'
                                        ] ifFalse:[
                                           cls revision notNil ifTrue:[
                                                listEntry colAt:2 put:'(overloaded by: ' , cls revision , ')' 
                                           ]
                                        ]
                                    ].
                                    listEntry
                                  ].
                    list2 list:classNames.
                    info dynamic ifTrue:[
                        unloadButton enable.
                        unloadAndRemoveButton enable.
                    ] ifFalse:[
                        unloadButton disable.
                        unloadAndRemoveButton disable.
                    ].
                ].
            ]
        ]
    ].


    panel := HorizontalPanelView new.

    panel add:(l := Label label:'show:').
    l adjust:#left; borderWidth:0.
    panel add:(check := CheckBox label:'builtin' model:showBuiltIn).
    box makeTabable:check.
    panel add:(check := CheckBox label:'classLibs' model:showModules).
    canDoIt ifFalse:[
        check disable
    ] ifTrue:[
        box makeTabable:check.
    ].
    panel add:(check := CheckBox label:'methods' model:showMethods).
    canDoIt ifFalse:[
        check disable
    ] ifTrue:[
        box makeTabable:check.
    ].
    panel add:(check := CheckBox label:'c-objects' model:showCObjects).
    canDoIt ifFalse:[
        check disable
    ] ifTrue:[
        box makeTabable:check.
    ].
    panel add:(check := CheckBox label:'others' model:showOthers).
    canDoIt ifFalse:[
        check disable
    ] ifTrue:[
        box makeTabable:check.
    ].

    panel horizontalLayout:#fitSpace.
    "/ panel horizontalLayout:#leftSpace.

    box addComponent:panel tabable:false.

    box addVerticalSpace.
    box addComponent:listView1 tabable:true.
    listView1 topInset:(View viewSpacing + panel preferredExtent y).
    listView1 origin:0.0@0.0 corner:1.0@0.4. "/ ; inset:2.

    l := box addTextLabel:(resources string:'contains:').
    l adjust:#left; borderWidth:0.
    l origin:0.0@0.4 corner:1.0@0.4.
    l topInset:(View viewSpacing).
    l bottomInset:((l preferredExtent y) negated - View viewSpacing).
    middleLabel := l.

    listView2 := HVScrollableView for:SelectionInListView  miniScrollerH:true.
    listView2 model:list2; printItems:false.
    box addComponent:listView2 tabable:true.
    listView2 origin:0.0@0.4 corner:1.0@1.0. "/ ; inset:2.
    listView2 disable.

    unloadButton := Button label:(resources string:'unload').
    unloadButton action:[
        box withWaitCursorDo:[
            |info idx pathName|

            idx := list1 selectionIndex.
            info := allModules at:idx ifAbsent:nil.

            list1 selectionIndex:nil.

            info isNil ifTrue:[
                "/ selected a method
                "/ idx := idx - allModules size.
                pathName := (handles at:idx) pathName.

            ] ifFalse:[
                "/ selected a package
                pathName := info pathName.
            ].
            ObjectFileLoader unloadObjectFile:pathName.
            moduleListUpdater value.
            unloadButton disable.
        ]
    ].

    unloadAndRemoveButton := Button label:(resources string:'remove classes & unload').
    unloadAndRemoveButton action:[
        box withWaitCursorDo:[
            |info idx pathName|

            idx := list1 selectionIndex.
            info := allModules at:idx ifAbsent:nil.

            list1 selectionIndex:nil.

            info isNil ifTrue:[
                "/ selected a method
                "/ idx := idx - allModules size.
                pathName := (handles at:idx) pathName.

            ] ifFalse:[
                "/ selected a package
                pathName := info pathName.
            ].
            ObjectFileLoader unloadObjectFileAndRemoveClasses:pathName.
            moduleListUpdater value.
            unloadAndRemoveButton disable.
        ]
    ].

    moduleListUpdater value.

    box addButton:unloadButton.
    box addButton:unloadAndRemoveButton.
    box addAbortButtonLabelled:(resources string:'dismiss').

    y := box yPosition.
    listView2 topInset:(l preferredExtent y + 5).
    listView2 bottomInset:(box preferredExtent y - y).

    box width:(400 min:(box device width * 2 // 3)); 
        height:(450 min:(box device height - 50)).

"/  box sizeFixed:true.
    box openWithExtent:(600 min:(box device width * 2 // 3))
                       @
                       (500 min:(box device height - 50)) .

    box destroy.

    "Modified: / 17.9.1995 / 16:47:50 / claus"
    "Created: / 31.7.1998 / 15:49:45 / cg"
    "Modified: / 10.8.1998 / 11:33:22 / cg"
!

packageDialog
    "opens a package dialog"

    |allPackages packageList packageUpdater
     box listView tabs
     menu resources selectedPackage|

    resources := self owningClass classResources.

    box := Dialog new.
    box label:(resources string:'Packages').

    allPackages := Set new.
    allPackages addAll:(Smalltalk knownPackages).

    Project knownProjects do:[:package |
        allPackages add:(package name)    
    ].
    Project loadedProjects do:[:package |
        allPackages add:(package name)    
    ].
    allPackages := allPackages asOrderedCollection sort.

    packageUpdater := [
        tabs := TabulatorSpecification unit:#inch positions:#(0 4).
        packageList := allPackages collect:[:pName | |pkg entry|
                            entry := MultiColListEntry new:2 tabulatorSpecification:tabs.
                            pkg := Project projectWithId:pName asSymbol.
                            (pkg notNil and:[pkg isLoaded]) ifTrue:[
                                entry colAt:1 put:pName allBold.
                                entry colAt:2 put:'loaded'.
                            ] ifFalse:[
                                entry colAt:1 put:pName.

                                (Smalltalk allClasses
                                     contains:[:cls | cls package = pName and:[cls isLoaded not]])
                                ifTrue:[
                                    (Smalltalk allClasses
                                         contains:[:cls | cls package = pName and:[cls isLoaded]])
                                    ifTrue:[
                                        entry colAt:2 put:'loaded/autoloaded'.
                                    ] ifFalse:[
                                        entry colAt:2 put:'autoloaded'.
                                    ]
                                ]
                            ].
                            entry
                       ].
    ].
    packageUpdater value.

    listView := HVScrollableView for:SelectionInListView miniScrollerH:true.
    listView list:packageList.

    box addComponent:listView tabable:true.
    listView origin:0.0@0.0 corner:1.0@1.0.
    listView bottomInset:40.
    listView action:[:selIndex | |pkg|
                        selectedPackage := (allPackages at:selIndex) asSymbol.

                        pkg := Project projectWithId:selectedPackage.
                        (pkg notNil and:[pkg isLoaded]) ifTrue:[
                            menu disable:#load.
"/                            menu enable:#unload.
                        ] ifFalse:[
"/                            menu disable:#unload.
                            menu enable:#load.
                        ]
                    ].

    menu := PopUpMenu 
                itemList:#(
                    ('load...'    load  )
"/                    ('-'          nil   )
"/                    ('unload...'  unload)
                )
                resources:resources.
    listView middleButtonMenu:menu.
    menu actionAt:#load   put:[
                                box withWaitCursorDo:[
                                    Smalltalk loadPackage:selectedPackage.
                                    packageUpdater value.
                                ]
                              ].
"/    menu actionAt:#unload put:[
"/                                box withWaitCursorDo:[
"/                                    Smalltalk unloadPackage:selectedPackage.
"/                                    packageUpdater value.
"/                                ].
"/                              ].
    menu disable:#load.
"/    menu disable:#unload.

    box addAbortButtonLabelled:(resources string:'dismiss').

    box width:(400 min:(box device width * 2 // 3)); 
        height:(450 min:(box device height - 50)).

    box openWithExtent:(600 min:(box device width * 2 // 3))
                       @
                       (500 min:(box device height - 50)) .

    box destroy.
! !

!AbstractLauncherApplication::LauncherDialogs class methodsFor:'dialogs - private'!

cvsConfigurationDialog
    |cvsRootHolder resources defaultsList bindings dialog 
     listOfModules selectedPerModuleRoot rootsPerModule acceptChannel
     removeEnabled cvsBinDirectoryHolder|

    resources := self owningClass classResources.

    OperatingSystem isUNIXlike ifTrue:[
        defaultsList := #(
                          '/files/CVS' 
                          '/CVS' 
                          'host:/files/CVS' 
                          'host:/CVS' 
                          ':pserver:user@host:/files/CVS'
                         ).
    ] ifFalse:[
        OperatingSystem isMSDOSlike ifTrue:[
            defaultsList := #(
                              ':local:c:\files\CVS' 
                              ':local:c:\CVS' 
                              'host:/files/CVS' 
                              'host:/CVS' 
                              ':pserver:user@host:/files/CVS'
                             ).
        ] ifFalse:[
            defaultsList := #('host:/files/CVS' 'host:/CVS' ':pserver:user@host:/files/CVS').
        ]
    ].

    cvsRootHolder := CVSSourceCodeManager repositoryName ? '/files/CVS'.
    cvsRootHolder := cvsRootHolder asValue.
    rootsPerModule := Dictionary new declareAllFrom:(CVSSourceCodeManager repositoryNamesPerModule).
    cvsBinDirectoryHolder := CVSSourceCodeManager cvsBinDirectory asValue.

    bindings := IdentityDictionary new.
    bindings at:#acceptChannel put:(acceptChannel := TriggerValue new).

    bindings at:#cvsRootPrototypeList put:defaultsList.
    bindings at:#cvsRootHolder put:cvsRootHolder.
    bindings at:#perModuleRootModule put:nil asValue.
    bindings at:#perModuleRoot put:nil asValue.
    bindings at:#removeEnabled put:(removeEnabled := false asValue).
    bindings at:#listOfModules put:(listOfModules := rootsPerModule keys asList).
    bindings at:#cvsBinDirectoryHolder put:cvsBinDirectoryHolder.
    listOfModules sort.

    bindings at:#selectedPerModuleRoot put:(selectedPerModuleRoot := nil asValue).
    selectedPerModuleRoot 
             onChangeEvaluate:[
                            |module cvsRoot|

                            acceptChannel value:true.    
                            module := selectedPerModuleRoot value.
                            removeEnabled value:true.
                            cvsRoot := rootsPerModule at:module ifAbsent:''.
                            (bindings at:#perModuleRootModule) value:module.
                            (bindings at:#perModuleRoot) value:cvsRoot.
             ].

    bindings at:#help put:[
                            WindowGroup activeGroup withWaitCursorDo:[
                                HTMLDocumentView openFullOnHelpFile:'Launcher/cvsSetup.html'
                            ]
                          ].

    bindings at:#addPerModuleRoot put:[
                            |module cvsRoot|

                            acceptChannel value:true.    
                            module := (bindings at:#perModuleRootModule) value.
                            cvsRoot := (bindings at:#perModuleRoot) value.
                            (listOfModules includes:module) ifFalse:[
                                listOfModules add:module.
                                listOfModules sort.
                            ].
                            cvsRoot size > 0 ifTrue:[
                                rootsPerModule at:module put:cvsRoot.
                            ].
                          ].
    bindings at:#removePerModuleRoot put:[
                            |module|

                            acceptChannel value:true.    
                            module := (bindings at:#perModuleRootModule) value.
                            listOfModules remove:module ifAbsent:nil.
                            rootsPerModule removeKey:module ifAbsent:nil.
                            (bindings at:#perModuleRootModule) value:nil.
                            (bindings at:#perModuleRoot) value:nil.
                          ].

    dialog := SimpleDialog new.
    dialog resources:resources.
    (dialog openSpec:(self cvsSetupSpec) withBindings:bindings) ifFalse:[
        ^ self
    ].

    acceptChannel value.    

    "/
    "/ update system settings
    "/
    CVSSourceCodeManager cvsBinDirectory:cvsBinDirectoryHolder value.
    CVSSourceCodeManager initializeForRepository:cvsRootHolder value.
    CVSSourceCodeManager repositoryNamesPerModule:rootsPerModule.
!

fontBoxForEncoding:encodingMatch 
    "open a fontBox, showing fonts which match some encoding
     (used when changing to japanese ...)"

    |box y b
     labelDef buttonDef listDef menuDef textDef
     models labels allOfThem filter resources defaultButton|

    resources := self owningClass classResources.

    encodingMatch notNil ifTrue:[
        filter := [:f | f encoding notNil 
                        and:[encodingMatch match:f encoding]].
    ].

    models := OrderedCollection new.
    labels := OrderedCollection new.

    models add:(allOfThem := nil asValue).
    models add:(labelDef := Label defaultFont asValue).
    models add:(buttonDef := Button defaultFont asValue).
    models add:(listDef := SelectionInListView defaultFont asValue).
    models add:(menuDef := MenuView defaultFont asValue).
    models add:(textDef := TextView defaultFont asValue).

    box := Dialog new.
    box label:(resources string:'Font Settings').

    models
    with:(resources array:#('All' 'Labels' 'Buttons' 'Lists' 'Menus' 'Edited Text'))
    do:[:model :title |
        |y2 lbl f i|

        f := model value.

        (box addTextLabel:title) adjust:#left.

        y := box yPosition.
        b := box addComponent:(Button label:(resources string:'Change ...')) tabable:true.
        b relativeExtent:nil; extent:(b preferredExtent).
        y2 := box yPosition.
        box yPosition:y.
        i := box leftIndent.
        box leftIndent:(b widthIncludingBorder + View viewSpacing).
        (lbl := box addTextLabel:'')
            adjust:#left;
            font:(model value);
            labelChannel:(BlockValue 
                            with:[:v | |f|
                                f := v value.
                                f isNil ifTrue:[
                                    ''
                                ] ifFalse:[
                                    f userFriendlyName
                                ]
                            ]
                            argument:model).
        labels add:lbl.

        box leftIndent:i.
        box yPosition:(box yPosition max:y2).

        box addVerticalSpace; addHorizontalLine; addVerticalSpace.

        b action:[
            |f|

            f := FontPanel 
                fontFromUserInitial:(model value) 
                              title:(resources string:'Font for %1' with:title)
                             filter:filter.
            f notNil ifTrue:[
                model == allOfThem ifTrue:[
                    models do:[:m | m value:f].
                    labels do:[:l | l font:f]
                ] ifFalse:[
                    model value:f.
                    lbl font:f.
                ].
            ]
        ].
        model == allOfThem ifTrue:[
            box addVerticalSpace
        ]
    ].

    box addAbortAndOkButtons.
    defaultButton := Button label:(resources string:'Defaults').

    (DialogBox styleSheet at:'dialogBox.okAtLeft') ifTrue:[
        box addButton:defaultButton after:nil.
    ] ifFalse:[
        box addButton:defaultButton before:nil.
    ].
    defaultButton
        action:[
            "/ fetch defaults
            View readStyleSheetAndUpdateAllStyleCaches.
            labelDef value: Label defaultFont.
            buttonDef value: Button defaultFont.
            listDef value: SelectionInListView defaultFont.
            menuDef value: MenuView defaultFont.
            textDef value: TextView defaultFont.
        ].

    box open.
    box accepted ifTrue:[
        Label defaultFont:labelDef value.
        Button defaultFont:buttonDef value.
        Toggle defaultFont:buttonDef value.
        TextView withAllSubclasses do:[:cls | cls defaultFont:textDef value].
        SelectionInListView withAllSubclasses do:[:cls | cls defaultFont:listDef value].
        MenuView defaultFont:menuDef value.
        PullDownMenu defaultFont:menuDef value.
    ].
    box destroy.
    ^ box accepted

    "Created: / 27.2.1996 / 01:44:16 / cg"
    "Modified: / 17.6.1996 / 13:38:48 / stefan"
    "Modified: / 15.9.1998 / 22:04:51 / cg"
!

formattingConfigurationDialog
    |dialog 
     resources exampleText formattedText reformatAction
     reformatLocked
     oldUserPreferences
     currentUserPrefs 
     tabIndent  
     spaceAroundTemporaries emptyLineAfterTemporaries 
     spaceAfterReturnToken spaceAfterKeywordSelector cStyleBlocks
     blockArgumentsOnNewLine
     maxLengthForSingleLineBlocks resetValue bindings|

    RBFormatter isNil ifTrue:[
        ^ self warn:'Sorry, no RBFormatter class'.
    ].

    RBFormatter isLoaded ifFalse:[
        WindowGroup activeGroup withWaitCursorDo:[
            RBFormatter autoload
        ]
    ].

    resources := self owningClass classResources.
    currentUserPrefs := UserPreferences current.

    exampleText := 
'methodSelector:methodArg
    "method comment:
     some stupid code to show the current settings"

    |index|

    "/ another comment ...
    self at:index.                      "/ a message
    self at:index put:methodArg.        "/ a two arg message
    self from:1 to:index put:methodArg. "/ a three arg message
    methodArg ifTrue:[
        Transcript showCR:''hello''.      "/ condition
    ].
    methodArg ifTrue:[
        Transcript showCR:''hello''.      "/ condition
    ] ifFalse:[
        Transcript showCR:''world''.      
    ].
    [methodArg] whileTrue:[
        Transcript showCR:''hello''.      "/ looping
    ].
    [self aVeryLongConditionBlock and:[self toMakeBlockLonger]] whileTrue:[
        Transcript showCR:''hello''.      "/ long blocks
    ].
    methodArg do:[:element |
        Transcript showCR:''hello''.      "/ looping
    ].
    1 to:methodArg size do:[:index |
        Transcript showCR:''hello''.      "/ looping
    ].
    methodArg keysAndValuesDo:[:index |
        Transcript showCR:''hello''.      "/ looping
    ].
    Object errorSignal handle:[:ex |      
        ex return                         
    ] do:[                                "/ exception handling
        self someAction                   "/ blocks
    ].
    ^ self.
'.

    formattedText := '' asValue.
    reformatLocked := false.

    reformatAction := [ |tree
                         s_tabIndent s_spaceAroundTemporaries s_emptyLineAfterTemporaries
                         s_spaceAfterReturnToken s_spaceAfterKeywordSelector s_cStyleBlocks
                         s_maxLengthForSingleLineBlocks s_blockArgumentsOnNewLine|

                        reformatLocked ifFalse:[
                            "/
                            "/ temporary change the RBFormatters settings ...
                            "/
                            s_tabIndent := RBFormatter tabIndent.
                            s_spaceAroundTemporaries := RBFormatter spaceAroundTemporaries.
                            s_emptyLineAfterTemporaries := RBFormatter emptyLineAfterTemporaries.
                            s_spaceAfterReturnToken := RBFormatter spaceAfterReturnToken.
                            s_spaceAfterKeywordSelector := RBFormatter spaceAfterKeywordSelector.
                            s_cStyleBlocks := RBFormatter cStyleBlocks.
                            s_blockArgumentsOnNewLine := RBFormatter blockArgumentsOnNewLine.
                            s_maxLengthForSingleLineBlocks := RBFormatter maxLengthForSingleLineBlocks.

                            RBFormatter 
                                tabIndent:tabIndent value;
                                spaceAroundTemporaries:spaceAroundTemporaries value;
                                emptyLineAfterTemporaries:emptyLineAfterTemporaries value;
                                spaceAfterReturnToken:spaceAfterReturnToken value;
                                spaceAfterKeywordSelector:spaceAfterKeywordSelector value;
                                cStyleBlocks:cStyleBlocks value;
                                blockArgumentsOnNewLine:blockArgumentsOnNewLine value;
                                maxLengthForSingleLineBlocks:maxLengthForSingleLineBlocks value.

                            tree := RBParser 
                                        parseMethod:exampleText
                                        onError: [:aString :position | nil].
                            tree do:[:node |
                                (node ~~ tree and:[node parent isNil]) ifTrue:[
                                    self error:'No parent for node'.
                                ]
                            ].
                            formattedText value:tree printString.

                            RBFormatter 
                                tabIndent:s_tabIndent;
                                spaceAroundTemporaries:s_spaceAroundTemporaries;
                                emptyLineAfterTemporaries:s_emptyLineAfterTemporaries;
                                spaceAfterReturnToken:s_spaceAfterReturnToken;
                                spaceAfterKeywordSelector:s_spaceAfterKeywordSelector;
                                cStyleBlocks:s_cStyleBlocks;
                                blockArgumentsOnNewLine:s_blockArgumentsOnNewLine;
                                maxLengthForSingleLineBlocks:s_maxLengthForSingleLineBlocks.
                          ].
                      ].

    bindings := IdentityDictionary new.
    bindings at:#formattedText put:formattedText.

    oldUserPreferences := currentUserPrefs copy.

    tabIndent := RBFormatter tabIndent asValue.
    tabIndent onChangeEvaluate:reformatAction. 
    bindings at:#tabIndent put:tabIndent.

    spaceAroundTemporaries := RBFormatter spaceAroundTemporaries asValue.
    spaceAroundTemporaries onChangeEvaluate:reformatAction. 
    bindings at:#spaceAroundTemporaries put:spaceAroundTemporaries.

    emptyLineAfterTemporaries := RBFormatter emptyLineAfterTemporaries asValue.
    emptyLineAfterTemporaries onChangeEvaluate:reformatAction. 
    bindings at:#emptyLineAfterTemporaries put:emptyLineAfterTemporaries.

    spaceAfterReturnToken := RBFormatter spaceAfterReturnToken asValue.
    spaceAfterReturnToken onChangeEvaluate:reformatAction. 
    bindings at:#spaceAfterReturnToken put:spaceAfterReturnToken.

    spaceAfterKeywordSelector := RBFormatter spaceAfterKeywordSelector asValue.
    spaceAfterKeywordSelector onChangeEvaluate:reformatAction. 
    bindings at:#spaceAfterKeywordSelector put:spaceAfterKeywordSelector.

    cStyleBlocks := RBFormatter cStyleBlocks asValue.
    cStyleBlocks onChangeEvaluate:reformatAction. 
    bindings at:#cStyleBlocks put:cStyleBlocks.

    blockArgumentsOnNewLine := RBFormatter blockArgumentsOnNewLine asValue.
    blockArgumentsOnNewLine onChangeEvaluate:reformatAction. 
    bindings at:#blockArgumentsOnNewLine put:blockArgumentsOnNewLine.

    maxLengthForSingleLineBlocks := RBFormatter maxLengthForSingleLineBlocks asValue.
    maxLengthForSingleLineBlocks onChangeEvaluate:reformatAction. 
    bindings at:#maxLengthForSingleLineBlocks put:maxLengthForSingleLineBlocks.

    bindings at:#resetList   put:#( 'ST/X default' 'RB default' ).
    bindings at:#resetValue  put:(resetValue := nil asValue).
    resetValue onChangeEvaluate:
        [
            resetValue value == 1 ifTrue:[
                "/ ST/X defaults
                reformatLocked := true.
                tabIndent value: 4.
                spaceAfterReturnToken value: true.
                spaceAfterKeywordSelector value: false.
                spaceAroundTemporaries value: false.
                emptyLineAfterTemporaries value: true.
                cStyleBlocks value: true.
                blockArgumentsOnNewLine value:false.
                maxLengthForSingleLineBlocks value: 20.
                reformatLocked := false.
                reformatAction value.
            ].
            resetValue value == 2 ifTrue:[
                "/ RBParser defaults
                reformatLocked := true.
                tabIndent value: 8.
                spaceAfterReturnToken value: false.
                spaceAfterKeywordSelector value: true.
                spaceAroundTemporaries value: true.
                emptyLineAfterTemporaries value: false.
                cStyleBlocks value: false.
                blockArgumentsOnNewLine value:false.
                maxLengthForSingleLineBlocks value: 20.
                reformatLocked := false.
                reformatAction value.
            ].
            resetValue value:nil. "/ to force default label
        ].

    reformatAction value.

    "/
    "/ create a box on those ...
    "/
    dialog := SimpleDialog new.
    dialog postBuildBlock:[:builder |
                                (builder componentAt:#sampleTextView) 
                                    cursorMovementWhenUpdating:nil;
                                    scrollWhenUpdating:nil.
                          ].
    (dialog openFor:nil 
        spec:(self formatterDialogSpec) 
        withBindings:bindings) 
    ifTrue:[
        currentUserPrefs at:#'formatter.tabIndent' put:tabIndent value.
        currentUserPrefs at:#'formatter.spaceAroundTemporaries' put:spaceAroundTemporaries value.
        currentUserPrefs at:#'formatter.emptyLineAfterTemporaries' put:emptyLineAfterTemporaries value.
        currentUserPrefs at:#'formatter.spaceAfterReturnToken' put:spaceAfterReturnToken value.
        currentUserPrefs at:#'formatter.spaceAfterKeywordSelector' put:spaceAfterKeywordSelector value.
        currentUserPrefs at:#'formatter.cStyleBlocks' put:cStyleBlocks value.
        currentUserPrefs at:#'formatter.blockArgumentsOnNewLine' put:blockArgumentsOnNewLine value.
        currentUserPrefs at:#'formatter.maxLengthForSingleLineBlocks' put:maxLengthForSingleLineBlocks value.
        RBFormatter 
            tabIndent:tabIndent value;
            spaceAroundTemporaries:spaceAroundTemporaries value;
            emptyLineAfterTemporaries:emptyLineAfterTemporaries value;
            spaceAfterReturnToken:spaceAfterReturnToken value;
            spaceAfterKeywordSelector:spaceAfterKeywordSelector value;
            cStyleBlocks:cStyleBlocks value;
            blockArgumentsOnNewLine:blockArgumentsOnNewLine value;
            maxLengthForSingleLineBlocks:maxLengthForSingleLineBlocks value.
    ] ifFalse: [
        (UserPreferences reset; current) declareAllFrom: oldUserPreferences
    ].
!

syntaxColorConfigurationDialog
    |box frame exampleView y
     resources exampleText coloredText recolorAction
     syntaxColor syntaxColors colorMenu oldUserPreferences
     syntaxEmphasises syntaxColorSelector syntaxEmphasisSelector syntaxColoringBox
     syntaxEmphasisesBox syntaxColoringResetButton b resetList
     resetListBox currentUserPrefs|

    resources := self owningClass classResources.
    currentUserPrefs := UserPreferences current.

    exampleText := 
'methodSelector:methodArg
    "method comment:
     some stupid code to show the current settings"

    |methodVar|

    "/ another comment ...
    self at:methodArg.        "/ a message
    self fooBarBaz:methodVar. "/ a bad message
    methodVar := Array new:1.
    unknonVar := 1.           "/ a bad variable
    UnknonVar := 1.           "/ another bad variable
    "self bar:methodVar.  detect commented code easily"
    1 to:5 do:[:i | self at:i + 1].
    Transcript showCR:''some string'' , #someSymbol.
    ^ self.
'.

    coloredText := '' asValue.
    recolorAction := [ coloredText value:(SyntaxHighlighter formatMethod:exampleText in:nil) ].
    recolorAction value.

    "/
    "/ create a box on those values ...
    "/
    box := DialogBox new.
    box label:(resources string:'Syntax Colors').

    frame := View new.
    frame extent:1.0 @ 200.
    frame borderWidth:0.

    exampleView := HVScrollableView for:TextView in:frame.
    exampleView model:coloredText.
    exampleView origin:0.0@0.0 corner:1.0@1.0; inset:2.

    frame topInset:box yPosition.
    box addComponent:frame withExtent:1.0@200.
    box makeTabable:exampleView. 
    frame width:1.0.

    box addVerticalSpace.

    oldUserPreferences := currentUserPrefs copy.

    syntaxColoringBox := box addComboListOn: (syntaxColors := SelectionInList with:UserPreferences syntaxColorNames initialSelection:1).
    syntaxColorSelector    := [(syntaxColors selection replChar:$  withString: '') asLowercaseFirst asSymbol].
    syntaxEmphasisSelector := [((syntaxColorSelector value readStream upToAll: 'Color'), 'Emphasis') asLowercaseFirst asSymbol].
    syntaxColor := (currentUserPrefs perform: syntaxColorSelector value) asValue.
    colorMenu := ColorMenu new.
    colorMenu model: syntaxColor.
    syntaxColor onChangeEvaluate: 
        [currentUserPrefs at:  syntaxColorSelector value put: syntaxColor value.
         recolorAction value.].
    syntaxColors onChangeEvaluate: 
        [|eVal|
         syntaxColor value: (currentUserPrefs perform:syntaxColorSelector value).
         eVal := currentUserPrefs perform: syntaxEmphasisSelector value.
         eVal isArray ifTrue:[
            eVal = (Array with:#underwave with:#underlineColor->(Color red:100.0 green:0.0 blue:0.0)) ifTrue:[
                eVal := #'red underwave'    
            ].    
            eVal = (Array with:#bold with:#underwave with:#underlineColor->(Color red:100.0 green:0.0 blue:0.0)) ifTrue:[
                eVal := #'bold+red underwave'    
            ].    
            eVal = (Array with:#bold with:#underlineColor->(Color red:100.0 green:0.0 blue:0.0)) ifTrue:[
                eVal := #'bold+red underline'    
            ].    
            eVal = (Array with:#italic with:#underwave with:#underlineColor->(Color red:100.0 green:0.0 blue:0.0)) ifTrue:[
                eVal := #'italic+red underwave'    
            ].    
            eVal = (Array with:#italic with:#underlineColor->(Color red:100.0 green:0.0 blue:0.0)) ifTrue:[
                eVal := #'italic+red underline'    
            ].    
         ].
         syntaxEmphasises selection: eVal.
         recolorAction value.].

    syntaxEmphasises := SelectionInList 
                            with:#(
                                    normal
                                    underline
                                    #'red underline'
                                    underwave
                                    #'red underwave'
                                    bold
                                    boldUnderline
                                    #'bold+red underline'
                                    boldUnderwave
                                    #'bold+red underwave'
                                    italic
                                    italicUnderline
                                    #'italic+red underline'
                                    italicUnderwave
                                    #'italic+red underwave'
                                    reverse
                                  ) 
                            initialSelection:1.
    syntaxEmphasisesBox := box addComboListOn:syntaxEmphasises.
    syntaxEmphasises 
        onChangeEvaluate:[ |em|
            em := syntaxEmphasises selection.
            em notNil ifTrue:[
                em := em asSymbol.
                em == #'red underline' ifTrue:[ em := Array with:#underline with:(#underlineColor->Color red)].
                em == #'red underwave' ifTrue:[ em := Array with:#underwave with:(#underlineColor->Color red)].
                em == #'bold+red underline' ifTrue:[ em := Array with:#bold with:#underline with:(#underlineColor->Color red)].
                em == #'bold+red underwave' ifTrue:[ em := Array with:#bold with:#underwave with:(#underlineColor->Color red)].
                em == #'italic+red underline' ifTrue:[ em := Array with:#italic with:#underline with:(#underlineColor->Color red)].
                em == #'italic+red underwave' ifTrue:[ em := Array with:#italic with:#underwave with:(#underlineColor->Color red)].

                currentUserPrefs at: syntaxEmphasisSelector value put:em.
            ].
            recolorAction value
        ].
    syntaxColors changed:#value. "/ to force initial update of emphasis
    box addComponent:colorMenu tabable:true.

    y := box yPosition.

    b := Button new label: (resources string:'reset to:').
    b action:[
        |resetSelector|

        resetSelector := (currentUserPrefs listOfPredefinedSyntaxColoringSchemes
                             collect:[:eachEntry | eachEntry first])
                                 at:resetList selectionIndex.
        currentUserPrefs perform:resetSelector. 
        recolorAction value.
    ].
    syntaxColoringResetButton := box addComponent:b.
    box makeTabable:syntaxColoringResetButton.

    box yPosition:y.

    resetList := SelectionInList 
                            with:(currentUserPrefs listOfPredefinedSyntaxColoringSchemes
                                        collect:[:eachEntry | eachEntry second])
                            initialSelection:1.
    resetListBox := box addComboListOn:resetList.
    box makeTabable:resetListBox.

    syntaxColoringBox enable.  
    colorMenu enable.  
    syntaxEmphasisesBox enable.  
    syntaxColoringResetButton enable. 

    box 
"/        addHelpButtonFor:'Launcher/sourceSettings.html';
        addAbortAndOkButtons.

    box stickAtBottomWithVariableHeight:frame.
    box stickAtBottomWithFixHeight:syntaxColoringBox.
    box stickAtBottomWithFixHeight:syntaxEmphasisesBox.
    box stickAtBottomWithFixHeight:colorMenu.
    box stickAtBottomWithFixHeight:syntaxColoringResetButton left:0.0 right:0.5.
    box stickAtBottomWithFixHeight:resetListBox left:0.5 right:1.0.

    "/
    "/ show the box ...
    "/
    box extent:600@400.
    box openModal.

    "/
    "/ update system settings
    "/
    box accepted ifTrue:[
    ] ifFalse: [
        (UserPreferences reset; current) declareAllFrom: oldUserPreferences
    ].
    box destroy

    "Modified: / 16.4.1998 / 17:18:16 / ca"
    "Modified: / 7.7.1999 / 00:27:02 / cg"
! !

!AbstractLauncherApplication::LauncherDialogs class methodsFor:'interface specs'!

cvsSetupSpec
    "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:AbstractLauncherApplication::LauncherDialogs andSelector:#cvsSetupSpec
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #cvsSetupSpec
        #window: 
       #(#WindowSpec
          #label: 'CVS Setup'
          #name: 'CVS Setup'
          #min: #(#Point 436 316)
          #max: #(#Point 1280 1024)
          #bounds: #(#Rectangle 13 23 449 377)
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#LabelSpec
              #label: 'CVS BinDirectory:'
              #name: 'Label1'
              #layout: #(#LayoutFrame 0 0.0 36 0 40 0.25 53 0)
              #level: 0
              #translateLabel: true
              #adjust: #right
            )
           #(#InputFieldSpec
              #name: 'BinDirectoryField'
              #layout: #(#LayoutFrame 44 0.25 34 0 -1 1 56 0)
              #tabable: true
              #model: #cvsBinDirectoryHolder
              #acceptChannel: #acceptChannel
              #acceptOnPointerLeave: false
            )
           #(#DividerSpec
              #name: 'Separator3'
              #layout: #(#LayoutFrame 0 0.0 60 0 0 1.0 64 0)
            )
           #(#LabelSpec
              #label: 'CVS SourceCodeManager setup'
              #name: 'label'
              #layout: #(#LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
              #translateLabel: true
              #adjust: #left
            )
           #(#LabelSpec
              #label: 'CVSRoot default:'
              #name: 'defaultCvsRootLabel'
              #layout: #(#LayoutFrame 0 0.0 71 0 40 0.25 88 0)
              #level: 0
              #translateLabel: true
              #adjust: #right
            )
           #(#ComboBoxSpec
              #name: 'cvsRootComboBox'
              #layout: #(#LayoutFrame 44 0.25 71 0 -1 1.0 93 0)
              #tabable: true
              #model: #cvsRootHolder
              #immediateAccept: true
              #acceptOnLeave: true
              #acceptOnReturn: true
              #acceptOnTab: true
              #acceptOnLostFocus: true
              #acceptChannel: #acceptChannel
              #acceptOnPointerLeave: false
              #comboList: #cvsRootPrototypeList
            )
           #(#DividerSpec
              #name: 'Separator1'
              #layout: #(#LayoutFrame 0 0.0 96 0 0 1.0 100 0)
            )
           #(#LabelSpec
              #label: 'CVSRoot per Module:'
              #name: 'knownModulesLabel'
              #layout: #(#LayoutFrame 0 0.0 109 0 40 0.25 126 0)
              #translateLabel: true
              #adjust: #right
            )
           #(#SequenceViewSpec
              #name: 'List1'
              #layout: #(#LayoutFrame 44 0.25 104 0 -1 1 202 0)
              #tabable: true
              #model: #selectedPerModuleRoot
              #hasHorizontalScrollBar: true
              #hasVerticalScrollBar: true
              #miniScrollerHorizontal: true
              #useIndex: false
              #sequenceList: #listOfModules
            )
           #(#LabelSpec
              #label: 'Module:'
              #name: 'moduleLabel'
              #layout: #(#LayoutFrame 0 0.0 209 0 40 0.25 226 0)
              #translateLabel: true
              #adjust: #right
            )
           #(#InputFieldSpec
              #name: 'perModuleRootModuleEntryField'
              #layout: #(#LayoutFrame 44 0.25 205 0 -1 1 227 0)
              #tabable: true
              #model: #perModuleRootModule
              #acceptChannel: #acceptChannel
              #acceptOnPointerLeave: false
            )
           #(#LabelSpec
              #label: 'CVSRoot:'
              #name: 'cvsRootLabel'
              #layout: #(#LayoutFrame 0 0.0 236 0 40 0.25 253 0)
              #translateLabel: true
              #adjust: #right
            )
           #(#ComboBoxSpec
              #name: 'perModuleRootComboBox'
              #layout: #(#LayoutFrame 44 0.25 232 0 -1 1.0 254 0)
              #tabable: true
              #model: #perModuleRoot
              #immediateAccept: true
              #acceptOnLeave: true
              #acceptOnReturn: true
              #acceptOnTab: true
              #acceptOnLostFocus: true
              #acceptChannel: #acceptChannel
              #acceptOnPointerLeave: false
              #comboList: #cvsRootPrototypeList
            )
           #(#HorizontalPanelViewSpec
              #name: 'HorizontalPanel1'
              #layout: #(#LayoutFrame 44 0.25 258 0 -1 1 289 0)
              #horizontalLayout: #fitSpace
              #verticalLayout: #center
              #horizontalSpace: 3
              #verticalSpace: 3
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'Add/Apply'
                    #name: 'addButton'
                    #translateLabel: true
                    #tabable: true
                    #model: #addPerModuleRoot
                    #extent: #(#Point 136 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Remove'
                    #name: 'removeButton'
                    #translateLabel: true
                    #tabable: true
                    #model: #removePerModuleRoot
                    #enableChannel: #removeEnabled
                    #extent: #(#Point 137 22)
                  )
                 )
               
              )
            )
           #(#DividerSpec
              #name: 'Separator2'
              #layout: #(#LayoutFrame 0 0.0 -45 1 0 1.0 -34 1)
            )
           #(#HorizontalPanelViewSpec
              #name: 'buttonPanel'
              #layout: #(#LayoutFrame 0 0.0 -29 1.0 0 1.0 -3 1.0)
              #horizontalLayout: #fitSpace
              #verticalLayout: #center
              #horizontalSpace: 3
              #verticalSpace: 3
              #ignoreInvisibleComponents: true
              #reverseOrderIfOKAtLeft: true
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'Cancel'
                    #name: 'cancelButton'
                    #translateLabel: true
                    #tabable: true
                    #model: #cancel
                    #extent: #(#Point 141 21)
                  )
                 #(#ActionButtonSpec
                    #label: 'Help'
                    #name: 'helpButton'
                    #translateLabel: true
                    #tabable: true
                    #model: #help
                    #extent: #(#Point 141 21)
                  )
                 #(#ActionButtonSpec
                    #label: 'OK'
                    #name: 'okButton'
                    #translateLabel: true
                    #tabable: true
                    #model: #accept
                    #isDefault: true
                    #extent: #(#Point 142 21)
                  )
                 )
               
              )
            )
           )
         
        )
      )
!

formatterDialogSpec
    "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:AbstractLauncherApplication::LauncherDialogs andSelector:#formatterDialogSpec
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #formatterDialogSpec
        #window: 
       #(#WindowSpec
          #label: 'Formatting parameters'
          #name: 'Formatting parameters'
          #min: #(#Point 10 10)
          #max: #(#Point 1280 1024)
          #bounds: #(#Rectangle 10 406 606 989)
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#LabelSpec
              #label: 'Sample output:'
              #name: 'Label2'
              #layout: #(#LayoutFrame 0 0.0 4 0 0 1.0 26 0)
              #translateLabel: true
              #adjust: #left
            )
           #(#TextEditorSpec
              #name: 'sampleTextView'
              #layout: #(#LayoutFrame 0 0.0 30 0.0 0 1.0 -234 1.0)
              #level: -1
              #model: #formattedText
              #hasHorizontalScrollBar: true
              #hasVerticalScrollBar: true
            )
           #(#FramedBoxSpec
              #label: 'Parameters'
              #name: 'FramedBox1'
              #layout: #(#LayoutFrame 0 0.0 -225 1 0 1.0 -30 1)
              #labelPosition: #topLeft
              #translateLabel: true
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#LabelSpec
                    #label: 'Max length for single line blocks:'
                    #name: 'Label1'
                    #layout: #(#LayoutFrame 185 0.0 127 0 66 0.7 153 0)
                    #level: 0
                    #adjust: #right
                  )
                 #(#CheckBoxSpec
                    #label: 'Space around temporaries '
                    #name: 'checkBox'
                    #layout: #(#LayoutFrame 2 0 3 0 260 0 32 0)
                    #level: 0
                    #tabable: true
                    #model: #spaceAroundTemporaries
                    #translateLabel: true
                  )
                 #(#CheckBoxSpec
                    #label: 'Blank line after local var declaration'
                    #name: 'CheckBox1'
                    #layout: #(#LayoutFrame 267 0 3 0 567 0 32 0)
                    #level: 0
                    #tabable: true
                    #model: #emptyLineAfterTemporaries
                    #translateLabel: true
                  )
                 #(#CheckBoxSpec
                    #label: 'Space after ''^'''
                    #name: 'CheckBox2'
                    #layout: #(#LayoutFrame 2 0 31 0 260 0 60 0)
                    #level: 0
                    #tabable: true
                    #model: #spaceAfterReturnToken
                    #translateLabel: true
                  )
                 #(#CheckBoxSpec
                    #label: 'Space after '':'' in keywords'
                    #name: 'CheckBox3'
                    #layout: #(#LayoutFrame 267 0 31 0 567 0 60 0)
                    #level: 0
                    #tabable: true
                    #model: #spaceAfterKeywordSelector
                    #translateLabel: true
                  )
                 #(#CheckBoxSpec
                    #label: 'C-Style blocks'
                    #name: 'CheckBox4'
                    #layout: #(#LayoutFrame 2 0 59 0 260 0 88 0)
                    #level: 0
                    #tabable: true
                    #model: #cStyleBlocks
                    #translateLabel: true
                  )
                 #(#InputFieldSpec
                    #name: 'editField'
                    #layout: #(#LayoutFrame 74 0.7 93 0 -38 1.0 119 0)
                    #level: -1
                    #tabable: true
                    #model: #tabIndent
                    #type: #number
                    #immediateAccept: false
                    #acceptOnLeave: true
                    #acceptOnReturn: true
                    #acceptOnTab: true
                    #acceptOnLostFocus: true
                    #acceptOnPointerLeave: true
                  )
                 #(#LabelSpec
                    #label: 'Indent:'
                    #name: 'label'
                    #layout: #(#LayoutFrame 242 0.0 93 0 66 0.7 119 0)
                    #level: 0
                    #adjust: #right
                  )
                 #(#InputFieldSpec
                    #name: 'EntryField1'
                    #layout: #(#LayoutFrame 74 0.7 127 0 -38 1.0 153 0)
                    #level: -1
                    #tabable: true
                    #model: #maxLengthForSingleLineBlocks
                    #type: #number
                    #immediateAccept: false
                    #acceptOnLeave: true
                    #acceptOnReturn: true
                    #acceptOnTab: true
                    #acceptOnLostFocus: true
                    #acceptOnPointerLeave: true
                  )
                 #(#PopUpListSpec
                    #label: 'Reset to...'
                    #name: 'PopUpList1'
                    #layout: #(#LayoutFrame 2 0 129 0 127 0 151 0)
                    #tabable: true
                    #model: #resetValue
                    #menu: #resetList
                    #useIndex: true
                  )
                 #(#CheckBoxSpec
                    #label: 'Block args on new line'
                    #name: 'CheckBox5'
                    #layout: #(#LayoutFrame 267 0 59 0 567 0 88 0)
                    #level: 0
                    #tabable: true
                    #model: #blockArgumentsOnNewLine
                    #translateLabel: true
                  )
                 )
               
              )
            )
           #(#HorizontalPanelViewSpec
              #name: 'horizontalPanelView'
              #layout: #(#LayoutFrame 0 0.0 -35 1.0 0 1.0 0 1.0)
              #level: 0
              #horizontalLayout: #fitSpace
              #verticalLayout: #center
              #horizontalSpace: 4
              #verticalSpace: 4
              #ignoreInvisibleComponents: true
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'Cancel'
                    #name: 'button'
                    #translateLabel: true
                    #tabable: true
                    #model: #cancel
                    #useDefaultExtent: true
                  )
                 #(#ActionButtonSpec
                    #label: 'OK'
                    #name: 'Button1'
                    #translateLabel: true
                    #tabable: true
                    #model: #accept
                    #isDefault: true
                    #useDefaultExtent: true
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!AbstractLauncherApplication::SettingsDialog class methodsFor:'applications'!

addApplClass:aClass withName:aName

    ApplicationList isNil ifTrue:[
        self initialize.
    ].
    ApplicationList add:(Array with:aName with:aClass asString asSymbol)
!

applList
    ApplicationList isNil ifTrue:[
        self initialize.
    ].
    ^ ApplicationList 
!

defaultAppList
    " list of settings applications 
      format: nameString applicationClassNameMethod"

    ^ #(
        #('Tools'    #'AbstractLauncherApplication::ToolsSettingsAppl')
        #('Language' #'AbstractLauncherApplication::LanguageSettingsAppl')
        #('Keyboard Mappings' #'AbstractLauncherApplication::KbdMappingSettingsAppl')
        #('Style Selection' #'AbstractLauncherApplication::StyleSettingsAppl')

    ).
!

removeApplClass:aClass

    |index|

    ApplicationList isNil ifTrue:[
        self initialize.
    ].
    index := ApplicationList findFirst:[:el |
        el second == aClass asSymbol
    ].
    index ~~ 0 ifTrue:[
        ApplicationList removeIndex:index.
    ].
!

settingsAppListClasses

    ^ self applList collect:[:entry | entry last].
!

settingsAppListNames

    ^ self applList collect:[:entry | entry first].
! !

!AbstractLauncherApplication::SettingsDialog class methodsFor:'initialize'!

initialize

    ApplicationList := self defaultAppList.

"
    self initialize
"
! !

!AbstractLauncherApplication::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:AbstractLauncherApplication::SettingsDialog andSelector:#windowSpec
     AbstractLauncherApplication::SettingsDialog new openInterface:#windowSpec
     AbstractLauncherApplication::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 516 562)
          #menu: #mainMenu
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#NoteBookViewSpec
              #name: 'SettingsNoteBook'
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #model: #selectionHolder
              #menu: #settingsAppList
              #useIndex: true
              #canvas: #canvasHolder
              #keepCanvasAlive: true
            )
           )
         
        )
      )
! !

!AbstractLauncherApplication::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 Settings...'
                  #itemValue: #loadSettings
                  #translateLabel: true
                )
               #(#MenuItem
                  #label: 'Save Settings...'
                  #itemValue: #saveSettings
                  #translateLabel: true
                )
               #(#MenuItem
                  #label: 'Exit'
                  #itemValue: #closeRequest
                  #translateLabel: true
                )
               )
              nil
              nil
            )
          )
         )
        nil
        nil
      )
! !

!AbstractLauncherApplication::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.
! !

!AbstractLauncherApplication::SettingsDialog methodsFor:'actions'!

sendLoadRequest

    colOfInstances do:[:settInst|
        settInst loadRequest.
    ].
!

sendSaveRequest

    |oldClient|

    oldClient := self canvasHolder value application.
    oldClient notNil ifTrue:[
        oldClient saveRequest ifFalse:[^ false].
    ].
    ^ true
! !

!AbstractLauncherApplication::SettingsDialog methodsFor:'aspects'!

canvasHolder

    canvasHolder isNil ifTrue:[
        canvasHolder := ValueHolder new.
    ].
    ^ canvasHolder.
!

selection
    "get the selection
    "
    ^ selection
!

selection:something
    "set the selection; update canvas
    "
    selection ~~ something ifTrue:[

        self sendSaveRequest ifFalse:[ ^ self].
        selection := something.
        selection ~~ 0 ifTrue:[
            self canvasHolder value:((colOfInstances at:selection) window).
        ].
    ].
!

selectionHolder

    selectionHolder isNil ifTrue:[
        selectionHolder := AspectAdaptor new subject:self; forAspect:#selection.
    ].
    ^ selectionHolder.
!

settingsAppList

    ^ self class settingsAppListNames.
! !

!AbstractLauncherApplication::SettingsDialog methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

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 sendSaveRequest ifFalse:[ ^ self].
    ^ super closeRequest
!

initialize

    selectionHolder := AspectAdaptor new subject:self; forAspect:#selection.
    super initialize.
!

postBuildWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked during the initialization of your app/dialog,
     after all of the visual components have been built, 
     but BEFORE the top window is made visible.
     Add any app-specific actions here (reading files, setting up values etc.)
     See also #postOpenWith:, which is invoked after opening."

    "/ add any code here ...

    ^ super postBuildWith:aBuilder
!

postOpenWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked right after the applications window has been opened.
     Add any app-specific actions here (starting background processes etc.).
     See also #postBuildWith:, which is invoked before opening."

    "/ add any code here ...

    colOfInstances := OrderedCollection new.
    self class settingsAppListClasses do:[:cls| | className |
        className := Smalltalk classNamed:cls.
        cls isNil ifTrue:[
            Transcript showCR:'no class named:' , className
        ] ifFalse:[
            | appl window|
            appl := className new.
            window := ApplicationSubView new.
            appl createBuilder.
            window client:appl.
            
            colOfInstances add:appl.
        ]
    ].
    self selectionHolder value:1.
    ^ super postOpenWith:aBuilder
! !

!AbstractLauncherApplication::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 sendLoadRequest.
    ].
!

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"
! !

!AbstractLauncherApplication::StyleSettingsAppl class methodsFor:'defaults'!

standardStyles

    ^  #(
        'decWindows'
        'iris' 
        'motif' 
        'mswindows95' 
        'next' 
        'normal'
        'os2' 
        'st80' 
       )
! !

!AbstractLauncherApplication::StyleSettingsAppl 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:AbstractLauncherApplication::StyleSettingsAppl andSelector:#windowSpec
     AbstractLauncherApplication::StyleSettingsAppl new openInterface:#windowSpec
     AbstractLauncherApplication::StyleSettingsAppl open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: 'Style Selection'
          #name: 'Style Selection'
          #min: #(#Point 10 10)
          #max: #(#Point 1024 768)
          #bounds: #(#Rectangle 12 22 487 553)
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#LabelSpec
              #label: 'Label'
              #name: 'Label1'
              #layout: #(#LayoutFrame 0 0.0 -71 1 0 1.0 -34 1)
              #style: #(#FontDescription #helvetica #bold #roman 12)
              #translateLabel: true
              #labelChannel: #infoLabelHolder
              #resizeForLabel: true
              #adjust: #left
            )
           #(#HorizontalPanelViewSpec
              #name: 'HorizontalPanel1'
              #layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
              #horizontalLayout: #center
              #verticalLayout: #center
              #horizontalSpace: 3
              #verticalSpace: 3
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'OK'
                    #name: 'OK'
                    #translateLabel: true
                    #model: #saveSettings
                    #enableChannel: #modifiedChannel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Cancel'
                    #name: 'Cancel'
                    #translateLabel: true
                    #model: #doCancel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Help'
                    #name: 'Help'
                    #translateLabel: true
                    #model: #help
                    #extent: #(#Point 125 22)
                  )
                 )
               
              )
            )
           #(#LabelSpec
              #label: 'NoticeText'
              #name: 'Text'
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 160 0)
              #translateLabel: true
              #labelChannel: #noticeLabelHolder
              #resizeForLabel: true
              #adjust: #left
            )
           #(#CheckBoxSpec
              #label: 'standard styles only'
              #name: 'CheckBox1'
              #layout: #(#LayoutFrame 0 0.0 160 0 0 1.0 182 0)
              #model: #showStandardStylesOnly
              #translateLabel: true
            )
           #(#SequenceViewSpec
              #name: 'StyleList'
              #layout: #(#LayoutFrame 0 0.0 182 0 0 1.0 -74 1)
              #model: #selectedStyle
              #hasHorizontalScrollBar: true
              #hasVerticalScrollBar: true
              #useIndex: false
              #sequenceList: #styleList
            )
           )
         
        )
      )
! !

!AbstractLauncherApplication::StyleSettingsAppl methodsFor:'actions'!

doCancel

    self isPartOfSettinsDialog ifTrue:[
        self loadRequest.
    ].
    self closeRequest.
!

evaluateModified

    self modifiedChannel value:(self hasUnsavedChanges).
!

help

    self warn:'no help available here'.
"/    self withWaitCursorDo:[HTMLDocumentView openFullOnHelpFile:'Launcher/keyboardSetting.html'].
!

loadRequest

    self modifiedChannel value:false.
!

saveRequest
    | result |

    (self hasUnsavedChanges) ifTrue:[
        result := self confirmWithCancel:(resources string:'Save changed Tool Settings ?'). 
        result isNil ifTrue:[ ^ false].
        result ifTrue:[
            self saveSettings.
        ] 
    ].
    ^ true
!

saveSettings

    | newStyle master requestor|

    self halt.
    newStyle := self selectedStyle value.
    master := self masterApplication.
    master notNil ifTrue:[
        requestor := master requestor.
    ].
    self halt.
    self hasUnsavedChanges ifTrue:[
        self withWaitCursorDo:[
            Transcript showCR:'change style to ' , newStyle , ' ...'.
            View defaultStyle:newStyle asSymbol.
        ].
        requestor notNil ifTrue:[
            self halt.
            requestor reopenLauncher.
        ].
        DebugView newDebugger.
        self modifiedChannel value:false.
    ].
! !

!AbstractLauncherApplication::StyleSettingsAppl methodsFor:'aspects'!

infoLabelHolder

    infoLabelHolder isNil ifTrue:[
        infoLabelHolder := '' asValue.
    ].
    ^ infoLabelHolder.
!

modifiedChannel

    modifiedChannel isNil ifTrue:[
        modifiedChannel := false asValue.
    ].
    ^ modifiedChannel
!

noticeLabelHolder

    noticeLabelHolder isNil ifTrue:[
        noticeLabelHolder := '' asValue.
    ].
    ^ noticeLabelHolder.
!

selectedStyle

    selectedStyle isNil ifTrue:[
        selectedStyle := ValueHolder new.
        selectedStyle addDependent:self.
    ].
    ^ selectedStyle.
!

showStandardStylesOnly

    showStandardStylesOnly isNil ifTrue:[
        showStandardStylesOnly := true asValue.
        showStandardStylesOnly addDependent:self.
    ].
    ^ showStandardStylesOnly.
!

styleList

    styleList isNil ifTrue:[
        styleList := List new.
        styleList addDependent:self.
    ].
    ^ styleList.
! !

!AbstractLauncherApplication::StyleSettingsAppl methodsFor:'change & update'!

changeInfoLabel

    |nm sheet comment|

    comment := ''.
    nm := self selectedStyle value.
    nm notNil ifTrue:[
        sheet := ViewStyle fromFile:(nm , '.style').
        comment := (sheet at:#comment ifAbsent:'') withoutSeparators.
    ].
    comment := comment withCRs asStringCollection.
    comment size == 1 ifTrue:[
        comment := comment first
    ].
    self infoLabelHolder value:comment
!

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 showStandardStylesOnly ifTrue:[
        self updateList.
        ^ self.
    ].
    changedObject == self selectedStyle ifTrue:[
        self changeInfoLabel.
        self evaluateModified.
        ^ self.
    ].

    super update:something with:aParameter from:changedObject
!

updateList

    |listOfStyles lastSelection|

    lastSelection := self selectedStyle value.
    listOfStyles := styleDirectoryContents select:[:aFileName | aFileName asFilename hasSuffix:'style'].
    listOfStyles := listOfStyles collect:[:aFileName | aFileName asFilename withoutSuffix name].
    Filename isCaseSensitive ifFalse:[
        listOfStyles := listOfStyles collect:[:aStyleName | aStyleName asLowercase].
    ].
    listOfStyles remove:'generic' ifAbsent:nil; remove:'mswindows3' ifAbsent:nil.
    showStandardStylesOnly value ifTrue:[
        listOfStyles := listOfStyles select:[:aStyleName | self class standardStyles includes:aStyleName].
    ].

    listOfStyles sort.
    self styleList contents:listOfStyles.
    self selectedStyle value:lastSelection.
! !

!AbstractLauncherApplication::StyleSettingsAppl methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

closeRequest

    self saveRequest ifFalse:[
        ^ self
    ].

    ^ super closeRequest.
!

initialize

    |someRsrcFile resourceDir|

    resources := self class owningClass classResources.
    someRsrcFile := Smalltalk getSystemFileName:('resources' asFilename constructString:'normal.style').
    someRsrcFile isNil ifTrue:[
        someRsrcFile := Smalltalk getResourceFileName:'normal.style' forPackage:'stx:libview'.
        someRsrcFile isNil ifTrue:[
            someRsrcFile := Smalltalk getResourceFileName:'styles/normal.style' forPackage:'stx:libview'.
        ].
    ].
    someRsrcFile notNil ifTrue:[
        resourceDir := someRsrcFile asFilename directoryName
    ] ifFalse:[
        resourceDir := Smalltalk getSystemFileName:'resources'.
    ].

    resourceDir isNil ifTrue:[
        self warn:'no styles found (missing ''resources'' directory)'.
        ^ self
    ].
    styleDirectoryContents := resourceDir asFilename directoryContents.
    self updateList.
    (self class standardStyles includes:View defaultStyle) ifFalse:[
        showStandardStylesOnly value:false
    ].
    self selectedStyle value:(View defaultStyle).
    self noticeLabelHolder value:(resources at:'STYLE_MSG' default:'Select a Style') withCRs.    
    super initialize
! !

!AbstractLauncherApplication::StyleSettingsAppl methodsFor:'queries'!

hasUnsavedChanges

    ^  (self selectedStyle value ~= View defaultStyle)
! !

!AbstractLauncherApplication::ToolsSettingsAppl 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:AbstractLauncherApplication::ToolsSettingsAppl andSelector:#windowSpec
     AbstractLauncherApplication::ToolsSettingsAppl new openInterface:#windowSpec
     AbstractLauncherApplication::ToolsSettingsAppl open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: 'AbstractLauncherApplication::LauncherDialogs::ToolsSettingsAppl'
          #name: 'AbstractLauncherApplication::LauncherDialogs::ToolsSettingsAppl'
          #min: #(#Point 10 10)
          #max: #(#Point 1024 768)
          #bounds: #(#Rectangle 16 42 491 313)
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#CheckBoxSpec
              #label: 'Use the New Changes Browser'
              #name: 'ChangesBrowser'
              #layout: #(#LayoutFrame 5 0 5 0 250 0 30 0)
              #model: #useNewChangesBrowser
              #translateLabel: true
            )
           #(#DividerSpec
              #name: 'Separator1'
              #layout: #(#LayoutFrame 0 0.0 35 0 0 1 38 0)
            )
           #(#CheckBoxSpec
              #label: 'Use the New System Browser'
              #name: 'NewSystemBrowser'
              #layout: #(#LayoutFrame 250 0 5 0 0 1 30 0)
              #model: #useNewSystemBrowser
              #translateLabel: true
            )
           #(#DividerSpec
              #name: 'Separator2'
              #layout: #(#LayoutFrame 0 0.0 70 0 0 1 73 0)
            )
           #(#CheckBoxSpec
              #label: 'Use the New VersionDiff Browser'
              #name: 'VersionDiffBrowser'
              #layout: #(#LayoutFrame 5 0 40 0 250 0 65 0)
              #model: #useNewVersionDiffBrowser
              #translateLabel: true
            )
           #(#DividerSpec
              #name: 'Separator3'
              #layout: #(#LayoutFrame 0 0.0 105 0 0 1 108 0)
            )
           #(#CheckBoxSpec
              #label: 'Use the New File Browser'
              #name: 'NewFileBrowser'
              #layout: #(#LayoutFrame 250 0 40 0 0 1 65 0)
              #model: #useNewFileBrowser
              #translateLabel: true
            )
           #(#CheckBoxSpec
              #label: 'Use Hierarchical Inspector'
              #name: 'HierarchicalInspector'
              #layout: #(#LayoutFrame 5 0 75 0 250 0 100 0)
              #model: #useNewInspector
              #translateLabel: true
            )
           #(#CheckBoxSpec
              #label: 'Show Clock in Launcher'
              #name: 'Clock'
              #layout: #(#LayoutFrame 250 0 75 0 0 1 100 0)
              #model: #showClockInLauncher
              #translateLabel: true
            )
           #(#LabelSpec
              #label: '''Transcripts Buffer Size:'''
              #name: 'Label1'
              #layout: #(#LayoutFrame 9 0 133 0 154 0 155 0)
              #translateLabel: true
              #adjust: #left
            )
           #(#InputFieldSpec
              #name: 'Transcripts Buffer Size'
              #layout: #(#LayoutFrame 159 0 133 0 214 0 155 0)
              #model: #transcriptBufferSize
              #type: #number
              #immediateAccept: true
              #acceptOnReturn: true
              #acceptOnTab: true
              #acceptOnLostFocus: true
              #acceptOnPointerLeave: false
            )
           #(#HorizontalPanelViewSpec
              #name: 'HorizontalPanel1'
              #layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
              #horizontalLayout: #center
              #verticalLayout: #center
              #horizontalSpace: 3
              #verticalSpace: 3
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'OK'
                    #name: 'OK'
                    #translateLabel: true
                    #model: #saveSettings
                    #enableChannel: #modifiedChannel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Cancel'
                    #name: 'Cancel'
                    #translateLabel: true
                    #model: #doCancel
                    #extent: #(#Point 125 22)
                  )
                 #(#ActionButtonSpec
                    #label: 'Help'
                    #name: 'Help'
                    #translateLabel: true
                    #model: #help
                    #extent: #(#Point 125 22)
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!AbstractLauncherApplication::ToolsSettingsAppl methodsFor:'actions'!

doCancel

    self isPartOfSettinsDialog ifTrue:[
        self loadRequest.
    ].
    self closeRequest.
!

evaluateModified

    self modifiedChannel value:(self hasUnsavedChanges).
!

help

    self withWaitCursorDo:[HTMLDocumentView openFullOnHelpFile:'Launcher/toolSettings.html'].
!

loadRequest

    self showClockInLauncher value:currentUserPrefs showClockInLauncher.
    self transcriptBufferSize value:Transcript current lineLimit.
    self useNewChangesBrowser value:currentUserPrefs useNewChangesBrowser.
    self useNewFileBrowser value:currentUserPrefs useNewFileBrowser.
    self useNewInspector value:currentUserPrefs useNewInspector.
    self useNewSystemBrowser value:currentUserPrefs useNewSystemBrowser.
    self useNewVersionDiffBrowser value:currentUserPrefs useNewVersionDiffBrowser.
    self modifiedChannel value:false.
!

saveRequest
    | result |

    (self hasUnsavedChanges) ifTrue:[
        result := self confirmWithCancel:(resources string:'Save changed Tool Settings ?'). 
        result isNil ifTrue:[ ^ false].
        result ifTrue:[
            self saveSettings.
        ] 
    ].
    ^ true
!

saveSettings

    | showClock launcher |

    currentUserPrefs useNewInspector:self useNewInspector value.
    currentUserPrefs useNewChangesBrowser:self useNewChangesBrowser value.
    currentUserPrefs useNewSystemBrowser:self useNewSystemBrowser value.
    currentUserPrefs useNewVersionDiffBrowser:self useNewVersionDiffBrowser value.
    currentUserPrefs useNewFileBrowser:self useNewFileBrowser value.
    (Smalltalk at:#FileBrowserV2) isBehavior ifTrue:[
        self useNewFileBrowser value ifTrue:[
            FileBrowserV2 installInLauncher.
        ] ifFalse:[
            FileBrowserV2 isLoaded ifTrue:[
                FileBrowserV2 removeFromLauncher.
            ]
        ].
    ].
    showClock := self showClockInLauncher value.
    currentUserPrefs showClockInLauncher ~= showClock ifTrue:[
        currentUserPrefs showClockInLauncher:showClock.
        launcher := Transcript application.
        (launcher isKindOf:ToolApplicationModel) ifTrue:[
            showClock ifTrue:[
                launcher startClock
            ] ifFalse:[
                launcher stopClock
            ]
        ]
    ].
    Inspector := currentUserPrefs inspectorClassSetting.
    Transcript current lineLimit:self transcriptBufferSize value.
! !

!AbstractLauncherApplication::ToolsSettingsAppl methodsFor:'aspects'!

modifiedChannel

    modifiedChannel isNil ifTrue:[
        modifiedChannel := false asValue.
    ].
    ^ modifiedChannel
!

showClockInLauncher

    showClockInLauncher isNil ifTrue:[
        showClockInLauncher := currentUserPrefs showClockInLauncher asValue.
        showClockInLauncher onChangeSend:#evaluateModified to:self
    ].
    ^ showClockInLauncher.
!

transcriptBufferSize

    transcriptBufferSize isNil ifTrue:[
        transcriptBufferSize := Transcript current lineLimit asValue.
        transcriptBufferSize onChangeSend:#evaluateModified to:self
    ].
    ^ transcriptBufferSize.
!

useNewChangesBrowser

    useNewChangesBrowser isNil ifTrue:[
        useNewChangesBrowser := currentUserPrefs useNewChangesBrowser asValue.
        useNewChangesBrowser onChangeSend:#evaluateModified to:self
    ].
    ^ useNewChangesBrowser.
!

useNewFileBrowser

    useNewFileBrowser isNil ifTrue:[
        useNewFileBrowser := currentUserPrefs useNewFileBrowser asValue.
        useNewFileBrowser onChangeSend:#evaluateModified to:self
    ].
    ^ useNewFileBrowser.
!

useNewInspector

    useNewInspector isNil ifTrue:[
        useNewInspector := currentUserPrefs useNewInspector asValue.
        useNewInspector onChangeSend:#evaluateModified to:self
    ].
    ^ useNewInspector.
!

useNewSystemBrowser

    useNewSystemBrowser isNil ifTrue:[
        useNewSystemBrowser := currentUserPrefs useNewSystemBrowser asValue.
        useNewSystemBrowser onChangeSend:#evaluateModified to:self
    ].
    ^ useNewSystemBrowser.
!

useNewVersionDiffBrowser

    useNewVersionDiffBrowser isNil ifTrue:[
        useNewVersionDiffBrowser := currentUserPrefs useNewVersionDiffBrowser asValue.
        useNewVersionDiffBrowser onChangeSend:#evaluateModified to:self
    ].
    ^ useNewVersionDiffBrowser.
! !

!AbstractLauncherApplication::ToolsSettingsAppl methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

closeRequest

    self saveRequest ifFalse:[
        ^ self
    ].

    ^ super closeRequest.
!

initialize

    currentUserPrefs := UserPreferences current.
    super initialize
! !

!AbstractLauncherApplication::ToolsSettingsAppl methodsFor:'menu actions'!

menuNew
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'new' is selected."

    "/ change below and add any actions as required here ...
    self warn:'no action for ''new'' available.'.
!

menuOpen
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'open' is selected."

    "/ change below and add any actions as required here ...
    self warn:'no action for ''open'' available.'.
!

menuSave
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'save' is selected."

    "/ change below and add any actions as required here ...
    self warn:'no action for ''save'' available.'.
!

menuSaveAs
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'saveAs' is selected."

    "/ change below and add any actions as required here ...
    self warn:'no action for ''saveAs'' available.'.
!

openAboutThisApplication
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'help-about' is selected."

    "/ could open a customized aboutBox here ...
    super openAboutThisApplication
!

openDocumentation
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'help-documentation' is selected."

    "/ change below as required ...

    "/ to open an HTML viewer on some document (under 'doc/online/<language>/' ):
    HTMLDocumentView openFullOnDocumentationFile:'TOP.html'.

    "/ add application-specific help files under the 'doc/online/<language>/help/appName'
    "/ directory, and open a viewer with:
    "/ HTMLDocumentView openFullOnDocumentationFile:'help/<MyApplication>/TOP.html'.
! !

!AbstractLauncherApplication::ToolsSettingsAppl methodsFor:'queries'!

hasUnsavedChanges

    ^ ((self useNewInspector value       ~= currentUserPrefs useNewInspector)       or:[
       (self useNewChangesBrowser value  ~= currentUserPrefs useNewChangesBrowser)  or:[
       (self useNewSystemBrowser value   ~= currentUserPrefs useNewSystemBrowser)   or:[
       (self showClockInLauncher value   ~= currentUserPrefs showClockInLauncher)   or:[
       (self useNewVersionDiffBrowser value ~= currentUserPrefs useNewVersionDiffBrowser) or:[
       (self useNewFileBrowser value     ~= currentUserPrefs useNewFileBrowser) or:[
       (self transcriptBufferSize value  ~= Transcript current lineLimit)]]]]]])
! !

!AbstractLauncherApplication class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.230 2002-11-12 11:25:24 penk Exp $'
! !

AbstractLauncherApplication::SettingsDialog initialize!