StandaloneStartup.st
author Stefan Vogel <sv@exept.de>
Fri, 07 Mar 2014 15:49:12 +0100
changeset 16236 7a8308397650
parent 16235 9cc3d059960d
child 16237 4df960fd7c26
permissions -rw-r--r--
Set packagePath
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
    12
'From Smalltalk/X, Version:6.2.3.0 on 07-03-2014 at 15:45:30'                   !
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
    13
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libbasic' }"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#StandaloneStartup
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
10772
13bb80f40496 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10636
diff changeset
    18
	classVariableNames:'Verbose CommandLineArguments'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'System-Support'
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    23
StandaloneStartup class instanceVariableNames:'MutexHandle'
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    24
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    25
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    26
 No other class instance variables are inherited by this class.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    27
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    28
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    29
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
!StandaloneStartup class methodsFor:'documentation'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
copyright
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 COPYRIGHT (c) 2006 by eXept Software AG
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
              All Rights Reserved
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 This software is furnished under a license and may be used
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 only in accordance with the terms of that license and with the
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 be provided or otherwise made available to, or used by, any
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 other person.  No title to or ownership of the software is
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 hereby transferred.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
documentation
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    a subclassable template class for a standalone GUI-application's startup;
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    For your own stand alone programs, define a subclass of this, 
12335
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
    50
    and redefine the #main: method there.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    (of course, the other methods can also be redefined.)
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    [author:]
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        Claus Gittinger
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    [start with:]
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        <yourNamehere>Startup start
10886
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    58
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    59
    [see also:]
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    60
        Smalltalk
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    61
        GetOpt
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    62
        ReadEvalPrintLoop
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    64
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    65
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    66
howToDealWithMultipleApplicationInstances
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    67
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    68
    please read the comment in the corresponding ApplicationModel class-documentation method.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    69
"
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    70
!
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    71
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    72
whichMethodsToRedefine
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    73
"
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    74
    main:argv
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    75
        thats the actual program.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    76
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    77
    suppressRCFileReading
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    78
        false here; redefine to return true, to disable the rc-file reading.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    79
        you loose the chance of configuration, but lock the user out from any access to any smalltalk
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    80
        (if you have a user-phobia)
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    81
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    82
    allowDebugOption
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    83
        false here; redefine to return true, to enable the --debug startup option.
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    84
        if disabled, you loose the chance of debugging, but lock the user out from any access to any smalltalk
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    85
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    86
    allowScriptingOption
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    87
        false here; redefine to return true, to enable the --scripting startup option.
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    88
        if disabled, you loose the chance of remote control, but lock the user out from any access to any smalltalk
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    89
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    90
"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!StandaloneStartup class methodsFor:'initialization'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
initialize
11360
e309e560dcee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11359
diff changeset
    96
    "/ Verbose := true.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    Verbose := false.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   100
!StandaloneStartup class methodsFor:'debugging support'!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   101
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   102
dumpCoverageInformation
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   103
    "if the --coverage argument was given, dump that information now.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   104
     This is invoked via an exit block, when smalltalk terminates"
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   105
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   106
    "/ count instrumented vs. non-instrumented classes
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   107
    |nClasses nMethods 
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   108
     locOverall locExecuted locUnexecuted locInstrumented locUninstrumented
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   109
     locCovered locUncovered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   110
     nInstrumentedClasses nUninstrumentedClasses nPartiallyInstrumentedClasses
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   111
     nInstrumentedMethods nUninstrumentedMethods 
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   112
     nClassesCompletelyCovered nClassesPartiallyCovered nClassesUncovered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   113
     nMethodsCompletelyCovered nMethodsPartiallyCovered nMethodsUncovered|
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   114
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   115
    nInstrumentedClasses := nUninstrumentedClasses := nPartiallyInstrumentedClasses := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   116
    nInstrumentedMethods := nUninstrumentedMethods := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   117
    nClasses := nMethods := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   118
    locOverall := locCovered := locUncovered := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   119
    locInstrumented := locUninstrumented := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   120
    locExecuted := locUnexecuted := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   121
    nClassesCompletelyCovered := nClassesPartiallyCovered := nClassesUncovered := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   122
    nMethodsCompletelyCovered := nMethodsPartiallyCovered := nMethodsUncovered := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   123
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   124
    Smalltalk allClassesDo:[:eachClass |
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   125
        |nInstrumentedMethodsInClass nUninstrumentedMethodsInClass
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   126
         nMethodsCompletelyCoveredInClass nMethodsPartiallyCoveredInClass nMethodsUncoveredInClass
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   127
         locInstrumentedMethodsInClass locUninstrumentedMethodsInClass
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   128
         locExecutedInClass locUnexecutedInClass locPartiallyExecutedInClass|
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   129
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   130
        nMethodsCompletelyCoveredInClass := nMethodsPartiallyCoveredInClass := nMethodsUncoveredInClass := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   131
        nInstrumentedMethodsInClass := nUninstrumentedMethodsInClass := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   132
        locInstrumentedMethodsInClass := locUninstrumentedMethodsInClass := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   133
        eachClass instAndClassMethodsDo:[:mthd |
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   134
            |locMethod|
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   135
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   136
            nMethods := nMethods + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   137
            locMethod := 0. "/ mthd source asCollectionOfLines size.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   138
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   139
            mthd isInstrumented ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   140
                nInstrumentedMethodsInClass := nInstrumentedMethodsInClass + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   141
                locInstrumentedMethodsInClass := locInstrumentedMethodsInClass + locMethod.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   142
                mthd hasBeenCalled ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   143
                    mthd haveAllBlocksBeenExecuted ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   144
                        "/ fully covered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   145
                        nMethodsCompletelyCoveredInClass := nMethodsCompletelyCoveredInClass + 1
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   146
                    ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   147
                        "/ partially covered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   148
                        nMethodsPartiallyCoveredInClass := nMethodsPartiallyCoveredInClass + 1
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   149
                    ]
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   150
                ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   151
                    "/ completely uncovered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   152
                    nMethodsUncoveredInClass := nMethodsUncoveredInClass + 1
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   153
                ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   154
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   155
                nUninstrumentedMethodsInClass := nUninstrumentedMethodsInClass + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   156
                locUninstrumentedMethodsInClass := locUninstrumentedMethodsInClass + locMethod.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   157
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   158
        ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   159
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   160
        nInstrumentedMethods := nInstrumentedMethods + nInstrumentedMethodsInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   161
        nUninstrumentedMethods := nUninstrumentedMethods + nUninstrumentedMethodsInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   162
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   163
        nMethodsCompletelyCovered := nMethodsCompletelyCovered + nMethodsCompletelyCoveredInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   164
        nMethodsUncovered := nMethodsUncovered + nMethodsUncoveredInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   165
        nMethodsPartiallyCovered := nMethodsPartiallyCovered + nMethodsPartiallyCoveredInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   166
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   167
        nClasses := nClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   168
        nInstrumentedMethodsInClass == 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   169
            nUninstrumentedMethodsInClass == 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   170
                "/ empty class - do not count
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   171
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   172
                "/ completely uninstrumented
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   173
                nUninstrumentedClasses := nUninstrumentedClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   174
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   175
        ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   176
            nUninstrumentedMethodsInClass == 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   177
                "/ completely instrumented
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   178
                nInstrumentedClasses := nInstrumentedClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   179
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   180
                "/ part/part
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   181
                nPartiallyInstrumentedClasses := nPartiallyInstrumentedClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   182
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   183
        ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   184
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   185
        nMethodsCompletelyCoveredInClass > 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   186
            nClassesCompletelyCovered := nClassesCompletelyCovered + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   187
        ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   188
            nMethodsPartiallyCoveredInClass > 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   189
                nClassesPartiallyCovered := nClassesPartiallyCovered + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   190
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   191
                nClassesUncovered := nClassesUncovered + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   192
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   193
        ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   194
    ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   195
    
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   196
    Stderr nextPutLine:'Coverage info:'.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   197
    Stderr nextPutLine:('  Classes, overall: %1' bindWith:nClasses).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   198
    Stderr nextPutLine:('  Classes, instrumented: %1 (%2%%)' bindWith:nInstrumentedClasses with:((nInstrumentedClasses / nClasses * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   199
    Stderr nextPutLine:('  Classes, uninstrumented: %1 (%2%%)' bindWith:nUninstrumentedClasses with:((nUninstrumentedClasses / nClasses * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   200
    Stderr nextPutLine:('  Classes, partially instrumented: %1 (%2%%)' bindWith:nPartiallyInstrumentedClasses with:((nPartiallyInstrumentedClasses / nClasses * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   201
    Stderr nextPutLine:('  Classes, covered: %1 (%2%%)' bindWith:nClassesCompletelyCovered with:((nClassesCompletelyCovered / nClasses * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   202
    Stderr nextPutLine:('  Classes, partially covered: %1 (%2%%)' bindWith:nClassesPartiallyCovered with:((nClassesPartiallyCovered / nClasses * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   203
    Stderr nextPutLine:('  Classes, uncovered: %1 (%2%%)' bindWith:nClassesUncovered with:((nClassesUncovered / nClasses * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   204
    Stderr nextPutLine:('  Methods, overall: %1' bindWith:nMethods).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   205
    Stderr nextPutLine:('  Methods, instrumented: %1 (%2%%)' bindWith:nInstrumentedMethods with:((nInstrumentedMethods / nMethods * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   206
    Stderr nextPutLine:('  Methods, uninstrumented: %1 (%2%%)' bindWith:nUninstrumentedMethods with:((nUninstrumentedMethods / nMethods * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   207
    Stderr nextPutLine:('  Methods, covered: %1 (%2%%)' bindWith:nMethodsCompletelyCovered with:((nMethodsCompletelyCovered / nMethods * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   208
    Stderr nextPutLine:('  Methods, partially covered: %1 (%2%%)' bindWith:nMethodsPartiallyCovered with:((nMethodsPartiallyCovered / nMethods * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   209
    Stderr nextPutLine:('  Methods, uncovered: %1 (%2%%)' bindWith:nMethodsUncovered with:((nMethodsUncovered / nMethods * 100) asFixedPoint:1)).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   210
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   211
    "
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   212
     self dumpCoverageInformation
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   213
    "
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   214
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   215
    "Created: / 24-05-2011 / 17:08:46 / cg"
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   216
    "Modified: / 25-05-2011 / 00:10:51 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   217
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   218
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   219
handleCoverageMeasurementOptionsFromArguments:argv
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   220
    "handle the coverage measurement command line argument:
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   221
        --coverage 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   222
            [+/-]package: <package-pattern>       ... do / do not measure in package (regex match)
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   223
            [+/-]class: <class-pattern>           ... do / do not measure in class (regex match, including nameSpace)
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   224
            [+/-]method: <className>#<methodName> ... do / do not measure in method
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   225
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   226
     adds instrumentation code to all selected methods.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   227
    "
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   228
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   229
    |idx nextArg done doAdd addNames addMethodNames
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   230
     anyItem nMethodsInstrumented checkClass checkMethod coverageAction
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   231
     includedPackageNames excludedPackageNames 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   232
     includedClassNames excludedClassNames 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   233
     includedMethodNames excludedMethodNames|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   234
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   235
"
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   236
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'expeccoNET:*' '-class:' 'ExpeccoNET::ML' 'ExpeccoNET::LicenseString'  )
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   237
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'stx:*')
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   238
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'stx:libtool*')
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   239
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+class:' 'Tools::*' '-class:' 'Tools::StringSearchTool' )
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   240
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+class:' 'Tools::*Browser*'  )
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   241
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+method:' 'String#at:put:' 'String#at:')
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   242
"
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   243
    includedPackageNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   244
    excludedPackageNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   245
    includedClassNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   246
    excludedClassNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   247
    includedMethodNames := Dictionary new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   248
    excludedMethodNames := Dictionary new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   249
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   250
    idx := argv indexOfAny:#('--coverage').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   251
    idx == 0 ifTrue:[^ self ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   252
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   253
    addNames := [:collection |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   254
            [ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   255
                nextArg := argv at:idx ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   256
                nextArg notNil 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   257
                    and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) not
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   258
                    and:[ (nextArg endsWith:':') not ]]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   259
            ] whileTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   260
                collection add:nextArg.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   261
                anyItem := true.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   262
                idx := idx + 1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   263
            ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   264
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   265
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   266
    addMethodNames := [:collection |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   267
            |idx2 className selector|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   268
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   269
            [ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   270
                nextArg := argv at:idx ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   271
                nextArg notNil 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   272
                    and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) not]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   273
            ] whileTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   274
                idx2 := nextArg indexOf:$#.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   275
                className := nextArg copyTo:idx2-1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   276
                selector := nextArg copyFrom:idx2+1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   277
                (collection at:className ifAbsentPut:[Set new]) add:selector.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   278
                anyItem := true.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   279
                idx := idx + 1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   280
            ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   281
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   282
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   283
    idx := idx + 1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   284
    done := false.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   285
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   286
    [ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   287
        nextArg := argv at:idx ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   288
        done not 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   289
            and:[ nextArg notNil 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   290
            and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) ]]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   291
    ] whileTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   292
        idx := idx + 1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   293
        doAdd := nextArg first == $+.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   294
        nextArg := nextArg copyFrom:2.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   295
        nextArg = 'package:' ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   296
            addNames value:(doAdd ifTrue:includedPackageNames ifFalse:excludedPackageNames). 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   297
        ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   298
            nextArg = 'class:' ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   299
                addNames value:(doAdd ifTrue:includedClassNames ifFalse:excludedClassNames). 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   300
            ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   301
                nextArg = 'method:' ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   302
                    addMethodNames value:(doAdd ifTrue:includedMethodNames ifFalse:excludedMethodNames).
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   303
                ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   304
                    done := true
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   305
                ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   306
            ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   307
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   308
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   309
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   310
    anyItem ifFalse:[ ^ self ].
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   311
    nMethodsInstrumented := 0.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   312
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   313
    coverageAction := [:aMethod |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   314
            ((aMethod sends:#subclassResponsibility) not
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   315
            and:[ aMethod hasPrimitiveCode not ]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   316
                Transcript show:'instrumenting '; showCR:aMethod.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   317
                aMethod mclass recompile:aMethod selector usingCompilerClass:InstrumentingCompiler.
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   318
                nMethodsInstrumented := nMethodsInstrumented + 1.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   319
            ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   320
                Transcript show:'skipped '; showCR:aMethod.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   321
            ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   322
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   323
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   324
    checkMethod := [:someMethod |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   325
            ((excludedMethodNames at:someMethod mclass name ifAbsent:#()) includes:someMethod selector) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   326
                coverageAction value:someMethod
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   327
            ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   328
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   329
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   330
    checkClass := [:someClass |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   331
            someClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   332
                checkMethod value:mthd
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   333
            ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   334
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   335
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   336
    Smalltalk allClassesDo:[:eachClass |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   337
        (includedPackageNames contains:[:somePackagePattern| somePackagePattern match:(eachClass package)]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   338
            (excludedPackageNames contains:[:somePackagePattern| somePackagePattern match:(eachClass package)]) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   339
                (excludedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   340
                    checkClass value:eachClass
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   341
                ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   342
            ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   343
        ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   344
            (includedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   345
                (excludedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   346
                    checkClass value:eachClass
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   347
                ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   348
            ] ifFalse:[ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   349
                (Array with:eachClass theMetaclass with:eachClass) do:[:clsOrMeta |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   350
                    |selectors|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   351
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   352
                    selectors := includedMethodNames at:clsOrMeta name ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   353
                    selectors notEmptyOrNil ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   354
                        selectors do:[:eachSelector |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   355
                            coverageAction value:(clsOrMeta compiledMethodAt:eachSelector asSymbol).
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   356
                        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   357
                    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   358
                ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   359
            ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   360
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   361
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   362
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   363
    nMethodsInstrumented ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   364
        Transcript show:('%1 methods instrumented' bindWith:nMethodsInstrumented).
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   365
        Smalltalk addExitBlock:[ self dumpCoverageInformation ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   366
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   367
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   368
    "Created: / 24-05-2011 / 16:30:54 / cg"
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   369
    "Modified: / 24-05-2011 / 18:16:29 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   370
! !
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   371
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   372
!StandaloneStartup class methodsFor:'defaults'!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   373
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   374
allowCoverageMeasurementOption
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   375
    "enable/disable the --measureCoverage startup options.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   376
     The default is false, so standAlone apps do not support coverage measurements by default.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   377
     Can be redefined in subclasses to enable it 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   378
     (but will need the libcomp and possibly the programming/oom packages to be present)"
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   379
13378
ed35cb03c4ed changed: #allowCoverageMeasurementOption
Claus Gittinger <cg@exept.de>
parents: 13377
diff changeset
   380
    ^ Smalltalk isStandAloneApp not
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   381
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   382
    "Created: / 24-05-2011 / 16:16:15 / cg"
13378
ed35cb03c4ed changed: #allowCoverageMeasurementOption
Claus Gittinger <cg@exept.de>
parents: 13377
diff changeset
   383
    "Modified: / 25-05-2011 / 00:21:18 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   384
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   385
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   386
allowDebugOption
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   387
    "enable/disable the --debug startup option.
11363
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   388
     Can be redefined in subclasses to enable it"
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   389
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   390
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   391
!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   392
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   393
allowScriptingOption
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   394
    "enable/disable the --scripting startup option.
11363
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   395
     Can be redefined in subclasses to enable it"
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   396
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   397
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   398
!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   399
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   400
suppressRCFileReading
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   401
    "enable/disable the rc-file reading (and also the --rcFileName option).
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   402
     If suppressed, there is no chance to interfere with the startup.
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   403
     Can be redefined in subclasses to disable it"
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   404
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   405
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   406
! !
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   407
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
!StandaloneStartup class methodsFor:'helpers'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
11423
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   410
printInfo:msg
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   411
    Transcript 
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   412
        show:('%1 [info]: ' bindWith:(self applicationName));
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   413
        showCR:msg
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   414
!
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   415
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
redirectStandardStreams
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    Stdout := Stderr.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    Transcript := Stderr.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
13269
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   421
verbose
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   422
    ^ Verbose == true
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   423
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   424
    "Created: / 01-02-2011 / 15:52:47 / cg"
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   425
!
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   426
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
verboseInfo:msg
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    Verbose == true ifFalse:[^ self].
11423
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   429
    self printInfo:msg
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
    "Modified: / 19-09-2006 / 16:30:27 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   434
!StandaloneStartup class methodsFor:'multiple applications support'!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   435
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   436
applicationRegistryPath
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   437
    "the key under which this application stores its process ID in the registry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   438
     as a collection of path-components.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   439
     i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   440
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   441
     (would also be used as a relative path for a temporary lock file under unix).
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   442
     Used to detect if another instance of this application is already running."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   443
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   444
    self subclassResponsibility
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   445
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   446
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   447
applicationUUID
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   448
    "answer an application-specific unique uuid.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   449
     This is used as the name of some exclusive OS-resource, which is used to find out,
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   450
     if another instance of this application is already running.
13595
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   451
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used.
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   452
     If redefined, please return a real UUID (i.e. UUID fromString:'.....') and not a string or 
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   453
     similar possibly conflicting identifier.
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   454
     You can paste a fresh worldwide unique id via the editor's more-misc-paste UUID menuFunction."
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   455
    
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   456
    self subclassResponsibility
13595
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   457
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   458
    "Modified (comment): / 19-08-2011 / 01:54:39 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   459
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   460
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   461
shouldReuseRunningApplication
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   462
    "answer true, if an already running application instance should be re-used"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   463
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   464
    ^ false
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   465
! !
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   466
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   467
!StandaloneStartup class methodsFor:'multiple applications support-helpers'!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   468
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   469
applicationRegistryEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   470
    "retrieve the registry entry in which (if present), any currently running application
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   471
     has left its process ID"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   472
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   473
    |path relPathName applicationEntry softwareEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   474
14321
783b5c28f912 changed: #applicationRegistryEntry
Stefan Vogel <sv@exept.de>
parents: 14048
diff changeset
   475
    OperatingSystem isMSWINDOWSlike ifFalse:[^ nil].
783b5c28f912 changed: #applicationRegistryEntry
Stefan Vogel <sv@exept.de>
parents: 14048
diff changeset
   476
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   477
    path := self applicationRegistryPath.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   478
    relPathName := path asStringWith:$\.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   479
    applicationEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\',relPathName.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   480
    applicationEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   481
        softwareEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   482
        softwareEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   483
            Transcript showCR: 'Failed to get Software entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   484
            ^ nil.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   485
        ].
11103
aae220bd7157 changed: #applicationRegistryEntry
fm
parents: 11102
diff changeset
   486
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   487
        path do:[:subKey |
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   488
            |subEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   489
11103
aae220bd7157 changed: #applicationRegistryEntry
fm
parents: 11102
diff changeset
   490
            subEntry := softwareEntry createSubKeyNamed:subKey.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   491
            subEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   492
                Transcript showCR: 'Failed to create ',subKey,' entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   493
                ^ nil.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   494
            ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   495
            softwareEntry := subEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   496
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   497
        applicationEntry := softwareEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   498
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   499
    ^ applicationEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   500
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   501
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   502
checkForAndExitIfAnotherApplicationInstanceIsRunning
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   503
    "if another instance of this application is running,
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   504
     send it an openFile command for my file-argument, and exit.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   505
     (i.e. to let the already running application open up another window)."
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   506
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   507
    |shouldExit|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   508
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   509
    self verboseInfo:('check for another app').
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   510
    self isAnotherApplicationInstanceRunning ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   511
       self verboseInfo:('other app is running').
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   512
        shouldExit := self processStartupOfASecondInstance.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   513
        shouldExit ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   514
            self verboseInfo:('yes; go away').
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   515
            self releaseApplicationMutex.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   516
            Smalltalk isStandAloneApp ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   517
                Smalltalk exit.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   518
            ]
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   519
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   520
    ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   521
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   522
    "Modified: / 04-02-2011 / 00:04:31 / cg"
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   523
!
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   524
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   525
confirmOpenNewApplicationInstance
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   526
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   527
    ^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName)
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   528
                title: ('%1 is already open!!' bindWith:self applicationName)
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   529
             yesLabel: 'Continue' 
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   530
              noLabel: 'Exit'
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   531
!
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   532
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   533
currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   534
    ^ 'CurrentID'
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   535
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   536
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   537
getCurrentIDFromRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   538
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   539
    |applicationEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   540
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   541
    applicationEntry := self applicationRegistryEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   542
    applicationEntry isNil ifTrue:[^ nil.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   543
    ^ applicationEntry valueNamed: self currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   544
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   545
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   546
     |hWnd externalAddress|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   547
     hWnd := DapasXStartup getCurrentIDFromRegistry.   
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   548
     hWnd isEmptyOrNil ifTrue:[^ self halt.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   549
     hWnd := hWnd asInteger.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   550
     externalAddress := ExternalAddress newAddress: hWnd.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   551
     Display raiseWindow:externalAddress.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   552
     Display setForegroundWindow:externalAddress
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   553
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   554
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   555
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   556
getIDOfRunningApplicationFromRegistryEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   557
    |applicationEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   558
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   559
    applicationEntry := self applicationRegistryEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   560
    applicationEntry isNil ifTrue:[^ nil.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   561
    ^ applicationEntry valueNamed: self currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   562
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   563
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   564
isAnotherApplicationInstanceRunning
13083
66a8fb472eb5 comment/format in: #isAnotherApplicationInstanceRunning
Claus Gittinger <cg@exept.de>
parents: 12999
diff changeset
   565
    "answer true, if another instance of myself is currently running.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   566
     For now, it only works under win32, because it uses the underlying mutex mechanism."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   567
    
11106
740c42559ef7 changed: #isAnotherApplicationInstanceRunning
fm
parents: 11105
diff changeset
   568
    | lastErrorCode alreadyExists handleAndLastErrorCode |
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   569
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   570
    OperatingSystem isMSDOSlike ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   571
        self verboseInfo:('create mutex...').
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   572
        handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString).
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   573
        MutexHandle := handleAndLastErrorCode first.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   574
        lastErrorCode := handleAndLastErrorCode second.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   575
        "/ self assert: lastErrorCode == 0.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   576
        alreadyExists := 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   577
            MutexHandle isNil 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   578
            or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   579
            or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   580
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   581
        self verboseInfo:('alreadyExists = ',alreadyExists printString).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   582
        alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   583
        ^ alreadyExists
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   584
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   585
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   586
    ^ false.
13083
66a8fb472eb5 comment/format in: #isAnotherApplicationInstanceRunning
Claus Gittinger <cg@exept.de>
parents: 12999
diff changeset
   587
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   588
    "Modified: / 04-02-2011 / 00:05:51 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   589
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   590
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   591
processStartupOfASecondInstance
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   592
    "This is executed when I have been started as a second instance of an already running application.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   593
     If I can get the currentID (i.e. windowID) of the first one and there is a command line argument with a file, 
12935
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   594
     send a message to the main window of the already running application, to ask it for another window.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   595
     If the currentID is unknown, ask if the user wants to open a new instance of the application anyway.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   596
     Return true if the first instance has been notified, and this second instance should exit."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   597
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   598
    |currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded|
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   599
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   600
    commands := CommandLineArguments.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   601
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   602
    currentIDStringFromRegistry := self getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   603
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   604
    "If the currentID is not found and there are arguments from the command line, 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   605
     we should wait in case of starting the first instance of the application 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   606
     with a multiple selection of files."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   607
    (currentIDStringFromRegistry isEmptyOrNil and:[commands notEmptyOrNil]) ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   608
        Delay waitForSeconds: 2.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   609
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   610
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   611
    currentIDStringFromRegistry := self getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   612
    currentIDStringFromRegistry isEmptyOrNil ifTrue:[
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   613
        ^ self confirmOpenNewApplicationInstance not.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   614
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   615
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   616
    currentIDFromRegistry := Integer readFrom:currentIDStringFromRegistry onError: 0.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   617
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   618
    "/ bring the other application to the foreground
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   619
    aWindowId := ExternalAddress newAddress: currentIDFromRegistry.
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   620
    setForegroundWindowSucceeded := Display primSetForegroundWindow: aWindowId.
11379
2cd74df95a0e changed: #processStartupOfASecondInstance
fm
parents: 11363
diff changeset
   621
"/    setForegroundWindowSucceeded ifFalse:[^ self confirmOpenNewApplicationInstance not].
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   622
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   623
    "Autostart for associated extension"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   624
    commands notEmpty ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   625
        fileArg := commands last asFilename.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   626
        fileArg exists ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   627
            self sendOpenPathCommand:(fileArg pathName) toWindowId: aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   628
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   629
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   630
    ^ true
12935
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   631
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   632
    "Modified: / 08-07-2010 / 00:47:44 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   633
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   634
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   635
releaseApplicationMutex
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   636
12933
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   637
    (MutexHandle notNil and:[OperatingSystem isMSDOSlike]) ifTrue:[
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   638
        OperatingSystem releaseMutex: MutexHandle.
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   639
        OperatingSystem primCloseHandle: MutexHandle.
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   640
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   641
        MutexHandle := nil.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   642
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   643
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   644
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   645
sendCommand:message toWindowId:aWindowId
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   646
    "use the event send mechanism to forward a command to the already running application"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   647
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   648
    Display 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   649
        sendCopyDataString: message 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   650
        toWindowId: aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   651
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   652
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   653
sendOpenPathCommand:pathName toWindowId:aWindowId
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   654
    "use the event send mechanism to forward an open-Path command to the already running application"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   655
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   656
    self sendCommand:('openPath:', pathName) toWindowId:aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   657
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   658
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   659
writeCurrentIDIntoRegistry: currentID
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   660
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   661
    |applicationEntry currentIDEntry|
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   662
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   663
    applicationEntry := self applicationRegistryEntry.
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   664
    applicationEntry isNil ifTrue:[^ false.].
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   665
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   666
    currentIDEntry := applicationEntry createSubKeyNamed:(self currentIDKeyInRegistry).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   667
    currentIDEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   668
        Transcript showCR: 'Failed to create CurrentID entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   669
        ^ false.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   670
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   671
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   672
    ^ applicationEntry valueNamed:(self currentIDKeyInRegistry) put:(currentID printString).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   673
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   674
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   675
     | currentID returnedCurrentID |
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   676
     currentID := 999.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   677
     DapasXStartup writeCurrentIDIntoRegistry: currentID.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   678
     returnedCurrentID := DapasXStartup getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   679
     self assert: currentID = returnedCurrentID asNumber.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   680
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   681
! !
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   682
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
!StandaloneStartup class methodsFor:'queries'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
applicationName
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   686
    "used in verbose messages - can/should be redefined in subclasses"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
    |nm|
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
    nm := self nameWithoutPrefix.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
    (nm endsWith:'Startup') ifTrue:[
15162
f17158d75a0e Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 14977
diff changeset
   692
        ^ nm copyButLast:('Startup' size).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
    (nm endsWith:'Start') ifTrue:[
15162
f17158d75a0e Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 14977
diff changeset
   695
        ^ nm copyButLast:('Start' size).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
    ^ nm
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
    "Created: / 19-09-2006 / 16:26:44 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
14544
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   702
commandLineArguments
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   703
    ^ CommandLineArguments
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   704
!
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   705
12523
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   706
iconInBrowserSymbol
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   707
    <resource: #programImage>
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   708
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   709
    self == StandaloneStartup ifFalse:[
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   710
        ^ #standaloneStartupIcon 
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   711
    ].
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   712
    ^ super iconInBrowserSymbol
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   713
!
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   714
10040
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   715
isBrowserStartable
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   716
    "do not allow clicking on me in the browser"
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   717
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   718
    ^ false
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   719
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   720
    "Created: / 06-10-2006 / 11:33:13 / cg"
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   721
!
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   722
12626
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   723
keepSplashWindowOpen
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   724
    "if true is returned here, the splashWindow is not closed and will be still open
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   725
     when the main: method is invoked. This allows for plugin-loads etc. to be shown in the
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   726
     splash screen. However, my subclass's main: has to make sure that the splashScreen is closed.
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   727
     (calling hideSplashWindow)
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   728
     The default is false here which means that the splashWindow will be already closed when the
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   729
     subclasses main: is invoked."
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   730
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   731
    ^ false
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   732
!
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   733
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   734
patchesDirectory
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   735
    "answer a directory containing patches.
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   736
     The directory needs not to be present."
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   737
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   738
    ^ OperatingSystem pathOfSTXExecutable asFilename directory construct:'patches'.
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   739
!
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   740
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
startupFilename
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   742
    "used in verbose messages - can/should be redefined in subclasses"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
    ^ self applicationName asLowercase,'Start.rc'
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
    "
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   747
     ExpeccoStartup startupFilename -> 'expecco.rc'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
    "
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
    "Created: / 19-09-2006 / 16:38:28 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
!StandaloneStartup class methodsFor:'startup'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   755
handleRCFileOptionsFromArguments:argv
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   756
    "handle rc-file command line arguments:
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   757
        --rcFileName ......... define a startup rc-file
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   758
    "
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   759
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   760
    |idx nextArg rcFilename|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   761
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   762
    idx := argv indexOf:'--rcFileName'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   763
    idx ~~ 0 ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   764
        nextArg := argv at:(idx + 1) ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   765
        (nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   766
            rcFilename := nextArg.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   767
            argv removeAtIndex:idx+1; removeAtIndex:idx.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   768
        ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   769
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   770
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   771
    rcFilename isNil ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   772
        rcFilename := self startupFilename.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   773
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   774
    rcFilename asFilename exists ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   775
        self verboseInfo:('reading ',rcFilename,'...').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   776
        rcFilename isAbsolute ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   777
            rcFilename := OperatingSystem pathOfSTXExecutable asFilename directory constructString:rcFilename.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   778
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   779
        Smalltalk secureFileIn:rcFilename
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   780
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   781
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   782
    "Created: / 24-05-2011 / 16:13:34 / cg"
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   783
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   784
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   785
handleScriptingOptionsFromArguments:argv
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   786
    "handle scripting command line argument:
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   787
        --scripting portNr ... start a scripting server
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   788
        --allowHost host ..... add host to the allowed scripting hosts
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   789
    "
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   790
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   791
    |scripting idx nextArg portNr allowedScriptingHosts|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   792
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   793
    scripting := false.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   794
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   795
    idx := argv indexOfAny:#('--scripting').
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   796
    idx ~~ 0 ifTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   797
        nextArg := argv at:(idx + 1) ifAbsent:nil.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   798
        (nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   799
            portNr := nextArg asInteger.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   800
            argv removeAtIndex:idx+1.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   801
        ].
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   802
        argv removeAtIndex:idx.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   803
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   804
        scripting := true
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   805
    ].
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   806
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   807
    allowedScriptingHosts := OrderedCollection new.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   808
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   809
    idx := argv indexOfAny:#('--allowHost').
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   810
    [idx ~~ 0] whileTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   811
        nextArg := argv at:(idx + 1) ifAbsent:nil.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   812
        nextArg isNil ifTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   813
            self usage.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   814
            AbortOperationRequest raise.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   815
        ].
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   816
        allowedScriptingHosts add:nextArg.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   817
        idx := argv indexOfAny:#('--allowHost').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   818
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   819
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   820
    scripting ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   821
        self verboseInfo:('scripting on').
16131
3caa8b31823f class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15899
diff changeset
   822
        STXScriptingServer isNil ifTrue:[
3caa8b31823f class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15899
diff changeset
   823
            Smalltalk loadPackage:'stx:goodies/simpleServices'.
3caa8b31823f class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15899
diff changeset
   824
        ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   825
        STXScriptingServer notNil ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   826
            allowedScriptingHosts do:[:eachHost | STXScriptingServer allowHost:eachHost ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   827
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   828
            "/ scripting on port/stdin_out/8008
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   829
            self verboseInfo:('start scripting').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   830
            STXScriptingServer startAt:portNr
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   831
        ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   832
            self verboseInfo:('missing STXScriptingServer class').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   833
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   834
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   835
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   836
    "Created: / 24-05-2011 / 16:12:02 / cg"
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   837
    "Modified: / 24-05-2011 / 17:40:26 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   838
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   839
11055
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   840
loadPatch:fileName
11056
e2c4a6e948b6 loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 11055
diff changeset
   841
    self verboseInfo:('loading patch: ',fileName baseName).
15899
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   842
    [
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   843
        Smalltalk silentFileIn:fileName pathName.
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   844
    ] on:InvalidPatchError do:[:ex|
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   845
        self verboseInfo:('invalid patch: %1 error: %2'
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   846
                                 bindWith:fileName baseName with:ex messageText).
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   847
        ^ false.
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   848
    ].
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   849
    ^ true
11055
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   850
!
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   851
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
loadPatches
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   853
    "load all patches in the application's patches dir"
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   854
15504
52b934e3c98c class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15503
diff changeset
   855
    self possiblyCheckForNewPatchesOnServer.
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   856
    self loadPatchesMatching:nil.
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   857
!
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   858
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   859
loadPatchesMatching:aGlobString
15502
60b630074a16 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15162
diff changeset
   860
    "load the patches in the application's patches dir.
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   861
     If aGlobString ist not empty or nil, only patches matching the glob
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   862
     pattern are loaded. E.g. '[0-9]*.chg'"
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   863
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   864
    |patchesDir prevMode patchesToLoad|
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   866
    patchesDir := self patchesDirectory.
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   867
    patchesDir isDirectory ifTrue:[
11764
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   868
        prevMode := ClassCategoryReader sourceMode.
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   869
        ClassCategoryReader sourceMode:#discard.
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   870
        [
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   871
            patchesToLoad := patchesDir directoryContentsAsFilenames.
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   872
            patchesToLoad := patchesToLoad select:[:eachFilenameString|
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   873
                    eachFilenameString asFilename isRegularFile 
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   874
                ].
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   875
            aGlobString notEmptyOrNil ifTrue:[
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   876
                patchesToLoad := patchesToLoad select:[:eachFilename|
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   877
                        aGlobString match:eachFilename baseName caseSensitive:false
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   878
                    ].
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   879
            ].
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   880
            (patchesToLoad sort:[:a :b | a baseName < b baseName]) do:[:patchFile |
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   881
                self loadPatch:patchFile.
11764
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   882
            ].
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   883
        ] ensure:[
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   884
            ClassCategoryReader sourceMode:prevMode.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
    "Modified: / 19-09-2006 / 16:30:58 / cg"
15827
e97e83b43873 class: StandaloneStartup
sr
parents: 15818
diff changeset
   889
    "Modified: / 25-11-2013 / 12:27:33 / sr"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   892
loadRemainingClassLibraries
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   893
    "To speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present).
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   894
     Now, load all skipped libs (the ones marked with '*') from modules.stx."
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   895
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   896
    |modulesFile dllDirectory dlls|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   897
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   898
    OperatingSystem isMSWINDOWSlike ifFalse:[^ self ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   899
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   900
    self verboseInfo:'loadRemainingClassLibraries'.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   901
    modulesFile  := self stxModulesFilename.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   902
    dllDirectory := modulesFile directory.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   903
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   904
    dlls := OrderedCollection new.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   905
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   906
    modulesFile readingLinesDo:[:eachModulesLine|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   907
        |basename dllFile|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   908
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   909
        basename := eachModulesLine withoutSeparators.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   910
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   911
        (basename notEmpty and:[basename first == $*]) ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   912
            basename := (basename copyFrom:2) withoutSeparators, '.dll'.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   913
            dllFile := dllDirectory construct:basename.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   914
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   915
            dllFile exists ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   916
"/                self verboseInfo:('loading: ', basename).
13580
e5383cbbf032 changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents: 13378
diff changeset
   917
"/                Smalltalk showSplashMessage:('loading ', basename).
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   918
                dlls add:dllFile.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   919
            ] ifFalse:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   920
                self verboseInfo:( '**** cannot resolve: ', basename).
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   921
            ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   922
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   923
    ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   924
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   925
    dlls notEmpty ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   926
        ObjectFileLoader loadObjectFiles:dlls.
13322
8a1d5d6205cc changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents: 13280
diff changeset
   927
        ProjectDefinition initializeAllProjectDefinitions.
8a1d5d6205cc changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents: 13280
diff changeset
   928
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   929
        Display notNil ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   930
            "New view classes may have been loaded - have to update their styles"
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   931
            self verboseInfo:'update style caches of loaded dlls'.
12999
a5ab22c6470c changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents: 12998
diff changeset
   932
            SimpleView readStyleSheetAndUpdateAllStyleCaches.
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   933
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   934
    ].
13580
e5383cbbf032 changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents: 13378
diff changeset
   935
e5383cbbf032 changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents: 13378
diff changeset
   936
    "Modified: / 11-08-2011 / 17:23:55 / cg"
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   937
!
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   938
15503
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
   939
possiblyCheckForNewPatchesOnServer
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
   940
    "to be redefined in concrete applications: check fo patches on a server"
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
   941
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
   942
    "/ intentionally left blank
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
   943
!
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
   944
15830
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   945
removeDebugger
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   946
    Smalltalk at:#Debugger put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   947
!
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   948
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   949
removeInspector
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   950
    Smalltalk at:#Inspector put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   951
!
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   952
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   953
removeLauncher
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   954
    NewLauncher notNil ifTrue:[
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   955
        NewLauncher allPrivateClasses do:[:cls |
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   956
            Smalltalk at:(cls name) put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   957
        ].
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   958
        Smalltalk at:#NewLauncher put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   959
    ].
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   960
!
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
   961
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
setupSmalltalkFromArguments:argv
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   963
    "handle common command line arguments:
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   964
        --help ............... print usage and exit
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   965
        --verbose (-V) ....... be verbose during startup
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   966
        --debug .............. enable debugger & inspector
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   967
        --rcFileName ......... define a startup rc-file
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   968
        --scripting portNr ... start a scripting server
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   969
        --allowHost host ..... add host to the allowed scripting hosts
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   970
    "
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   971
16235
9cc3d059960d class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16233
diff changeset
   972
    |idx debugging baseDir|
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
"/    Smalltalk beHeadless:true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
"/    OperatingSystem disableSignal:(OperatingSystem sigHUP).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
"/    Smalltalk infoPrinting:true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
    (argv includes:'--help') ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
        self usage.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
        AbortOperationRequest raise.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    idx := argv indexOfAny:#('--verbose' '-V').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
    idx ~~ 0 ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
        argv removeAtIndex:idx.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
        Verbose := true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
    ].
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
   988
    self verboseInfo:('args: ',argv asArray printString).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   990
    debugging := false.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   991
    (self allowDebugOption) ifTrue:[
13126
8cbc00290e5b changed: #setupSmalltalkFromArguments:
Claus Gittinger <cg@exept.de>
parents: 13089
diff changeset
   992
        idx := argv indexOf:'--debug'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   993
        idx ~~ 0 ifTrue:[
11357
0a710cf52bb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11356
diff changeset
   994
            self verboseInfo:('debug on').
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   995
            argv removeAtIndex:idx.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   996
            debugging := true
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   997
        ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   998
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   999
    debugging ifTrue:[
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
        self setupToolsForDebug.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
    ] ifFalse:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
        self setupToolsForNoDebug.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
    ].
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1004
    baseDir := OperatingSystem pathOfSTXExecutable asFilename directory.
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1005
    baseDir baseName = 'application' ifTrue:[
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1006
        ".../work/exept/expecco/application/expecco -> .../work/"
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1007
        baseDir := baseDir directory directory directory.
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1008
        Smalltalk packagePath 
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1009
                    add:(baseDir pathName).
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1010
    ] ifFalse:[
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1011
        "/opt/expecco/bin/expecco -> /opt/expecco/"
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1012
        baseDir := baseDir directory.
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1013
        Smalltalk packagePath 
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1014
                    add:(baseDir constructString:'packages').
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1015
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1017
    (self suppressRCFileReading) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1018
        self handleRCFileOptionsFromArguments:argv.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1020
    (self allowScriptingOption) ifTrue:[
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1021
        self handleScriptingOptionsFromArguments:argv.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
    ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1023
    (self allowCoverageMeasurementOption) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1024
        self handleCoverageMeasurementOptionsFromArguments:argv.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1026
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    ^ true
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1029
    "Modified: / 24-05-2011 / 16:14:45 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1032
setupToolsForDebug
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1033
    Debugger := DebugView ? MiniDebugger.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1034
    Inspector := InspectorView ? MiniInspector.
11736
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
  1035
    Verbose ifTrue:[ 'debug enabled - CTRL-C brings you into a debugger.' errorPrintCR ].
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
  1036
"/    self verboseInfo:('debug enabled - CTRL-C brings you into a debugger.').
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
    "Created: / 19-09-2006 / 16:40:32 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1041
setupToolsForNoDebug
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1042
    Smalltalk isStandAloneApp ifTrue:[
15830
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1043
        self removeDebugger.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1044
        self removeInspector.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1045
11736
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
  1046
        Verbose ifTrue:[ 'debug disabled.' errorPrintCR ].
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1047
        self redirectStandardStreams.
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
  1048
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
    "Created: / 19-09-2006 / 16:40:47 / cg"
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
  1051
    "Modified: / 31-10-2007 / 16:18:40 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1054
start
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1055
    GenericException handle:[:ex |
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1056
        self verboseInfo:('Error during startup:').
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1057
        self verboseInfo:(ex description).
12996
8662430ec3de changed: #start
Stefan Vogel <sv@exept.de>
parents: 12992
diff changeset
  1058
        Verbose == true ifTrue:[ex suspendedContext fullPrintAllLevels:10].
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1059
        ex reject.        
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1060
    ] do:[
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1061
        |idx|
13127
60b2005943bb changed: #start
Claus Gittinger <cg@exept.de>
parents: 13126
diff changeset
  1062
13130
1aa18e8d0e26 splashmessage
Claus Gittinger <cg@exept.de>
parents: 13127
diff changeset
  1063
        Smalltalk showSplashMessage:('start').
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1064
        self verboseInfo:('starting...').
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1065
        CommandLineArguments := (self additionalArgumentsFromRegistry) 
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1066
                                , Smalltalk commandLineArguments.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1068
        self verboseInfo:('args: ', CommandLineArguments asStringCollection asString).
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1069
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1070
        "--newAppInstance - do not reuse an existing application instance,
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1071
         but run in a separate process"
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1072
        idx := CommandLineArguments indexOfAny:#('--newAppInstance').
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1073
        idx == 0 ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1074
            self shouldReuseRunningApplication ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
  1075
                self verboseInfo:('should reuse app').
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1076
                "Multiple Application support:
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1077
                 if another expecco is running, ask it to open another window for me.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1078
                 If that is the case, the following function will not return, but instead exit."
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1079
                self checkForAndExitIfAnotherApplicationInstanceIsRunning.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1080
            ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1081
        ] ifFalse:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1082
            CommandLineArguments removeAtIndex:idx.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1083
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1084
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1085
        "/ Arrive here, if no other application is running.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1086
        "/ to speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present).
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1087
        "/ now, load all skipped libs from modules.stx.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1088
        self loadRemainingClassLibraries.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1089
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1090
        Smalltalk isStandAloneApp ifTrue:[
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1091
            self loadPatches.
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1092
            self verboseInfo:('setup Smalltalk').
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1093
        ].
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1094
        self setupSmalltalkFromArguments:CommandLineArguments.
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1095
        self main
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
  1098
    "Modified: / 04-02-2011 / 00:03:47 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
11807
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1101
startStartBlockProcess
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1102
    Smalltalk startStartBlockProcess
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1103
!
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1104
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1105
stxModulesFilename
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1106
    "answer the Filename of modules.stx"
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1107
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1108
    |file|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1109
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1110
    file := 'modules.stx' asFilename.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1111
    file exists ifTrue:[^ file].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1112
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1113
    file := OperatingSystem pathOfSTXExecutable asFilename directory construct:'modules.stx'.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1114
    file exists ifTrue:[^ file].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1115
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1116
    self error:'cannot find: modules.stx'.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1117
!
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1118
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1119
usage
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1120
    Stderr nextPutLine:'usage: ',self applicationName,' [options...]'.
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1121
    Stderr nextPutLine:'  --help .................. output this message'.
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1122
    Stderr nextPutLine:'  --verbose ............... verbose startup'.
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1123
    Stderr nextPutLine:'  --noBanner .............. no splash screen'.
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1124
    Stderr nextPutLine:'  --newAppInstance ........ start as its own application process (do not reuse a running instance)'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1125
    self allowScriptingOption ifTrue:[
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1126
        Stderr nextPutLine:'  --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1127
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1128
    self allowDebugOption ifTrue:[
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1129
        Stderr nextPutLine:'  --debug ................. enable Debugger'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1130
    ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1131
    self allowCoverageMeasurementOption ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1132
        Stderr nextPutLine:'  --coverage .............. turn on coverage measurement'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1133
        Stderr nextPutLine:'     [+/-]package: pattern ...  - include/exclude packages'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1134
        Stderr nextPutLine:'     [+/-]class: pattern ...    - include/exclude classes'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1135
        Stderr nextPutLine:'     [+/-]method: cls#sel ...   - include/exclude methods'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1136
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1137
    self suppressRCFileReading ifFalse:[
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1138
        Stderr nextPutLine:'  --rcFileName file ....... execute code from file on startup (default: ',self startupFilename,')'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1139
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
    "Created: / 19-09-2006 / 16:37:55 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1142
    "Modified: / 24-05-2011 / 17:23:18 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
!StandaloneStartup class methodsFor:'startup-to be redefined'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
12991
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1147
additionalArgumentsFromRegistry
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1148
    "can be redefined to fetch and return additional arguments from the registry 
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1149
     (or other .ini file). These are added to the beginning of the command line arguments."
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1150
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1151
    ^ #()
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1152
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1153
    "Created: / 04-08-2010 / 12:20:27 / cg"
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1154
!
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1155
11806
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1156
isHeadless
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1157
    "this is invoked early by Smalltalk>>mainStartup, to ask if I like to
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1158
     have a Display or if I am a non-GUI headless application.
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1159
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1160
     Redefine in subclass, if your application is a non-GUI application"
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1161
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1162
    ^ false
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1163
!
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1164
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1165
main
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1166
    self verboseInfo:('entering main').
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1167
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1168
    self main:CommandLineArguments.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1169
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1170
    "
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1171
     self main
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1172
     self main:#('--info') 
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1173
    "
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1174
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1175
    "Modified: / 31-10-2007 / 16:03:22 / cg"
10636
ba91c2d292f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10040
diff changeset
  1176
!
ba91c2d292f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10040
diff changeset
  1177
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1178
main:argv
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1179
    self subclassResponsibility.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1180
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1181
"/ a typical main: looks like (in a subclass):
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1182
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1183
"/    |app fileArg|
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1184
"/
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1185
"/    self verboseInfo:('starting application').
14977
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1186
"/
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1187
"/    self startStartBlockProcess.
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1188
"/    Smalltalk openDisplay.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
"/    app := <someGUIApplicationModelClass> open.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
"/    self verboseInfo:('looking for args in ',argv).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
"/    argv notEmptyOrNil ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
"/        fileArg := argv last asFilename.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
"/        self verboseInfo:('fileArg is ',fileArg name).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
"/        fileArg exists ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
"/            self verboseInfo:('file exists').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
"/            ( #('foo' 'bar' 'baz' ) includes:fileArg suffix) ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
"/                self verboseInfo:('loading').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
"/                Error handle:[:ex |
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
"/                    self verboseInfo:'error while loading'.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
"/                    ex suspendedContext fullPrintAll.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
"/                ] do:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
"/                    app menuLoadFromFile:fileArg
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
"/                ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
"/            ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
"/        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
"/    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
    "Created: / 19-09-2006 / 16:48:29 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
!StandaloneStartup class methodsFor:'documentation'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
version
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1217
    ^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.86 2014-03-07 14:49:12 stefan Exp $'
12335
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
  1218
!
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
  1219
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
  1220
version_CVS
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1221
    ^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.86 2014-03-07 14:49:12 stefan Exp $'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
14977
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1224
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
StandaloneStartup initialize!