StandaloneStartup.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 16:21:34 +0200
changeset 25373 f030619565e1
parent 25207 63e27a006836
permissions -rw-r--r--
#REFACTORING by stefan class: ArrayedCollection class changed: #with:
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
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
17280
3b21c1a75d39 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 16307
diff changeset
    14
"{ NameSpace: Smalltalk }"
3b21c1a75d39 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 16307
diff changeset
    15
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#StandaloneStartup
23426
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
    17
	instanceVariableNames:''
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
    18
	classVariableNames:'Verbose CommandLineArguments'
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
    19
	poolDictionaries:''
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
    20
	category:'System-Support'
9944
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
"
17280
3b21c1a75d39 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 16307
diff changeset
    48
    When smalltalk is started as IDE (stx), the show starts in Smalltalk>>start.
19517
a6553bfe0451 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19205
diff changeset
    49
    In contrast, when a standAlone app is linked, 
a6553bfe0451 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19205
diff changeset
    50
    the show starts in the startup class's start method.
a6553bfe0451 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19205
diff changeset
    51
23426
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
    52
    This class is an abstract, subclassable template for a standalone GUI-application's startup.
19517
a6553bfe0451 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19205
diff changeset
    53
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    For your own stand alone programs, define a subclass of this, 
12335
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
    55
    and redefine the #main: method there.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    (of course, the other methods can also be redefined.)
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    [author:]
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        Claus Gittinger
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    [start with:]
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        <yourNamehere>Startup start
10886
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    63
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    64
    [see also:]
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    65
        Smalltalk
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    66
        GetOpt
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    67
        ReadEvalPrintLoop
19517
a6553bfe0451 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19205
diff changeset
    68
        StandaloneStartupHeadless
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    70
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    71
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    72
howToDealWithMultipleApplicationInstances
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    73
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    74
    please read the comment in the corresponding ApplicationModel class-documentation method.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    75
"
11352
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
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    78
whichMethodsToRedefine
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    79
"
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    80
    main:argv
20428
95bc102e907a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20392
diff changeset
    81
        that's the actual program.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    82
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    83
    suppressRCFileReading
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    84
        false here; redefine to return true, to disable the rc-file reading.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    85
        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
    86
        (if you have a user-phobia)
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    87
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    88
    allowDebugOption
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    89
        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
    90
        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
    91
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    92
    allowScriptingOption
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    93
        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
    94
        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
    95
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    96
"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!StandaloneStartup class methodsFor:'initialization'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
initialize
11360
e309e560dcee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11359
diff changeset
   102
    "/ Verbose := true.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    Verbose := false.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   106
!StandaloneStartup class methodsFor:'debugging support'!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   107
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   108
dumpCoverageInformation
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   109
    "if the --coverage argument was given, dump that information now.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   110
     This is invoked via an exit block, when smalltalk terminates"
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   111
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   112
    "/ count instrumented vs. non-instrumented classes
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   113
    |nClasses nMethods 
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   114
     locOverall locExecuted locUnexecuted locInstrumented locUninstrumented
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   115
     locCovered locUncovered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   116
     nInstrumentedClasses nUninstrumentedClasses nPartiallyInstrumentedClasses
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   117
     nInstrumentedMethods nUninstrumentedMethods 
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   118
     nClassesCompletelyCovered nClassesPartiallyCovered nClassesUncovered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   119
     nMethodsCompletelyCovered nMethodsPartiallyCovered nMethodsUncovered|
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   120
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   121
    nInstrumentedClasses := nUninstrumentedClasses := nPartiallyInstrumentedClasses := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   122
    nInstrumentedMethods := nUninstrumentedMethods := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   123
    nClasses := nMethods := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   124
    locOverall := locCovered := locUncovered := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   125
    locInstrumented := locUninstrumented := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   126
    locExecuted := locUnexecuted := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   127
    nClassesCompletelyCovered := nClassesPartiallyCovered := nClassesUncovered := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   128
    nMethodsCompletelyCovered := nMethodsPartiallyCovered := nMethodsUncovered := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   129
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   130
    Smalltalk allClassesDo:[:eachClass |
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   131
        |nInstrumentedMethodsInClass nUninstrumentedMethodsInClass
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   132
         nMethodsCompletelyCoveredInClass nMethodsPartiallyCoveredInClass nMethodsUncoveredInClass
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   133
         locInstrumentedMethodsInClass locUninstrumentedMethodsInClass
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   134
         locExecutedInClass locUnexecutedInClass locPartiallyExecutedInClass|
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   135
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   136
        nMethodsCompletelyCoveredInClass := nMethodsPartiallyCoveredInClass := nMethodsUncoveredInClass := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   137
        nInstrumentedMethodsInClass := nUninstrumentedMethodsInClass := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   138
        locInstrumentedMethodsInClass := locUninstrumentedMethodsInClass := 0.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   139
        eachClass instAndClassMethodsDo:[:mthd |
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   140
            |locMethod|
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   141
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   142
            nMethods := nMethods + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   143
            locMethod := 0. "/ mthd source asCollectionOfLines size.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   144
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   145
            mthd isInstrumented ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   146
                nInstrumentedMethodsInClass := nInstrumentedMethodsInClass + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   147
                locInstrumentedMethodsInClass := locInstrumentedMethodsInClass + locMethod.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   148
                mthd hasBeenCalled ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   149
                    mthd haveAllBlocksBeenExecuted ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   150
                        "/ fully covered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   151
                        nMethodsCompletelyCoveredInClass := nMethodsCompletelyCoveredInClass + 1
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   152
                    ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   153
                        "/ partially covered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   154
                        nMethodsPartiallyCoveredInClass := nMethodsPartiallyCoveredInClass + 1
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   155
                    ]
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   156
                ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   157
                    "/ completely uncovered
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   158
                    nMethodsUncoveredInClass := nMethodsUncoveredInClass + 1
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   159
                ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   160
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   161
                nUninstrumentedMethodsInClass := nUninstrumentedMethodsInClass + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   162
                locUninstrumentedMethodsInClass := locUninstrumentedMethodsInClass + locMethod.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   163
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   164
        ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   165
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   166
        nInstrumentedMethods := nInstrumentedMethods + nInstrumentedMethodsInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   167
        nUninstrumentedMethods := nUninstrumentedMethods + nUninstrumentedMethodsInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   168
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   169
        nMethodsCompletelyCovered := nMethodsCompletelyCovered + nMethodsCompletelyCoveredInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   170
        nMethodsUncovered := nMethodsUncovered + nMethodsUncoveredInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   171
        nMethodsPartiallyCovered := nMethodsPartiallyCovered + nMethodsPartiallyCoveredInClass.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   172
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   173
        nClasses := nClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   174
        nInstrumentedMethodsInClass == 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   175
            nUninstrumentedMethodsInClass == 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   176
                "/ empty class - do not count
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   177
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   178
                "/ completely uninstrumented
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   179
                nUninstrumentedClasses := nUninstrumentedClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   180
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   181
        ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   182
            nUninstrumentedMethodsInClass == 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   183
                "/ completely instrumented
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   184
                nInstrumentedClasses := nInstrumentedClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   185
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   186
                "/ part/part
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   187
                nPartiallyInstrumentedClasses := nPartiallyInstrumentedClasses + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   188
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   189
        ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   190
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   191
        nMethodsCompletelyCoveredInClass > 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   192
            nClassesCompletelyCovered := nClassesCompletelyCovered + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   193
        ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   194
            nMethodsPartiallyCoveredInClass > 0 ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   195
                nClassesPartiallyCovered := nClassesPartiallyCovered + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   196
            ] ifFalse:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   197
                nClassesUncovered := nClassesUncovered + 1.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   198
            ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   199
        ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   200
    ].
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   201
    
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   202
    Stderr nextPutLine:'Coverage info:'.
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   203
    Stderr nextPutLine:('  Classes, overall: %1' bindWith:nClasses).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   204
    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
   205
    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
   206
    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
   207
    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
   208
    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
   209
    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
   210
    Stderr nextPutLine:('  Methods, overall: %1' bindWith:nMethods).
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   211
    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
   212
    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
   213
    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
   214
    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
   215
    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
   216
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   217
    "
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   218
     self dumpCoverageInformation
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   219
    "
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   220
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   221
    "Created: / 24-05-2011 / 17:08:46 / cg"
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   222
    "Modified: / 25-05-2011 / 00:10:51 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   223
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   224
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   225
handleCoverageMeasurementOptionsFromArguments:argv
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   226
    "handle the coverage measurement command line argument:
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   227
        --coverage 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   228
            [+/-]package: <package-pattern>       ... do / do not measure in package (regex match)
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   229
            [+/-]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
   230
            [+/-]method: <className>#<methodName> ... do / do not measure in method
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   231
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   232
     adds instrumentation code to all selected methods.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   233
    "
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
    |idx nextArg done doAdd addNames addMethodNames
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   236
     anyItem nMethodsInstrumented checkClass checkMethod coverageAction
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   237
     includedPackageNames excludedPackageNames 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   238
     includedClassNames excludedClassNames 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   239
     includedMethodNames excludedMethodNames|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   240
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   241
"
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   242
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'expeccoNET:*' '-class:' 'ExpeccoNET::ML' 'ExpeccoNET::LicenseString'  )
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   243
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'stx:*')
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   244
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'stx:libtool*')
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   245
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+class:' 'Tools::*' '-class:' 'Tools::StringSearchTool' )
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   246
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+class:' 'Tools::*Browser*'  )
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   247
 self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+method:' 'String#at:put:' 'String#at:')
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   248
"
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   249
    includedPackageNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   250
    excludedPackageNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   251
    includedClassNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   252
    excludedClassNames := Set new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   253
    includedMethodNames := Dictionary new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   254
    excludedMethodNames := Dictionary new.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   255
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   256
    idx := argv indexOfAny:#('--coverage').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   257
    idx == 0 ifTrue:[^ self ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   258
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   259
    addNames := [:collection |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   260
            [ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   261
                nextArg := argv at:idx ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   262
                nextArg notNil 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   263
                    and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) not
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   264
                    and:[ (nextArg endsWith:':') not ]]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   265
            ] whileTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   266
                collection add:nextArg.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   267
                anyItem := true.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   268
                idx := idx + 1.
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
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   271
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   272
    addMethodNames := [:collection |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   273
            |idx2 className selector|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   274
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   275
            [ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   276
                nextArg := argv at:idx ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   277
                nextArg notNil 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   278
                    and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) not]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   279
            ] whileTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   280
                idx2 := nextArg indexOf:$#.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   281
                className := nextArg copyTo:idx2-1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   282
                selector := nextArg copyFrom:idx2+1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   283
                (collection at:className ifAbsentPut:[Set new]) add:selector.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   284
                anyItem := true.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   285
                idx := idx + 1.
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
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   288
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   289
    idx := idx + 1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   290
    done := false.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   291
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   292
    [ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   293
        nextArg := argv at:idx ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   294
        done not 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   295
            and:[ nextArg notNil 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   296
            and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) ]]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   297
    ] whileTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   298
        idx := idx + 1.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   299
        doAdd := nextArg first == $+.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   300
        nextArg := nextArg copyFrom:2.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   301
        nextArg = 'package:' ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   302
            addNames value:(doAdd ifTrue:includedPackageNames ifFalse:excludedPackageNames). 
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
            nextArg = 'class:' ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   305
                addNames value:(doAdd ifTrue:includedClassNames ifFalse:excludedClassNames). 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   306
            ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   307
                nextArg = 'method:' ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   308
                    addMethodNames value:(doAdd ifTrue:includedMethodNames ifFalse:excludedMethodNames).
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   309
                ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   310
                    done := true
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   311
                ]
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
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   314
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   315
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   316
    anyItem ifFalse:[ ^ self ].
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   317
    nMethodsInstrumented := 0.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   318
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   319
    coverageAction := [:aMethod |
25207
63e27a006836 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 25117
diff changeset
   320
            (aMethod isSubclassResponsibility
63e27a006836 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 25117
diff changeset
   321
              or:[ aMethod hasPrimitiveCode 
63e27a006836 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 25117
diff changeset
   322
              or:[ (aMethod hasAnnotation:#noCoverage) 
63e27a006836 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 25117
diff changeset
   323
            ]]) ifFalse:[     
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   324
                Transcript show:'instrumenting '; showCR:aMethod.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   325
                aMethod mclass recompile:aMethod selector usingCompilerClass:InstrumentingCompiler.
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   326
                nMethodsInstrumented := nMethodsInstrumented + 1.
25207
63e27a006836 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 25117
diff changeset
   327
            ] ifTrue:[
63e27a006836 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 25117
diff changeset
   328
                "/ Transcript show:'skipped '; showCR:aMethod.
13375
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
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   331
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   332
    checkMethod := [:someMethod |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   333
            ((excludedMethodNames at:someMethod mclass name ifAbsent:#()) includes:someMethod selector) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   334
                coverageAction value:someMethod
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
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   337
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   338
    checkClass := [:someClass |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   339
            someClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   340
                checkMethod value:mthd
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
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   344
    Smalltalk allClassesDo:[:eachClass |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   345
        (includedPackageNames contains:[:somePackagePattern| somePackagePattern match:(eachClass package)]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   346
            (excludedPackageNames contains:[:somePackagePattern| somePackagePattern match:(eachClass package)]) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   347
                (excludedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   348
                    checkClass value:eachClass
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   349
                ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   350
            ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   351
        ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   352
            (includedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   353
                (excludedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   354
                    checkClass value:eachClass
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   355
                ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   356
            ] ifFalse:[ 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   357
                (Array with:eachClass theMetaclass with:eachClass) do:[:clsOrMeta |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   358
                    |selectors|
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
                    selectors := includedMethodNames at:clsOrMeta name ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   361
                    selectors notEmptyOrNil ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   362
                        selectors do:[:eachSelector |
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   363
                            coverageAction value:(clsOrMeta compiledMethodAt:eachSelector asSymbol).
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   364
                        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   365
                    ].
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
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   369
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   370
13377
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   371
    nMethodsInstrumented ifTrue:[
547eaa6ea65d changed:
Claus Gittinger <cg@exept.de>
parents: 13376
diff changeset
   372
        Transcript show:('%1 methods instrumented' bindWith:nMethodsInstrumented).
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   373
        Smalltalk addExitBlock:[ self dumpCoverageInformation ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   374
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   376
    "Created: / 24-05-2011 / 16:30:54 / cg"
22020
4a36d84543d5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21676
diff changeset
   377
    "Modified: / 16-07-2017 / 11:32:45 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   378
! !
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   379
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   380
!StandaloneStartup class methodsFor:'defaults'!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   381
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   382
allowCoverageMeasurementOption
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   383
    "enable/disable the --measureCoverage startup options.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   384
     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
   385
     Can be redefined in subclasses to enable it 
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   386
     (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
   387
13378
ed35cb03c4ed changed: #allowCoverageMeasurementOption
Claus Gittinger <cg@exept.de>
parents: 13377
diff changeset
   388
    ^ Smalltalk isStandAloneApp not
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   389
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   390
    "Created: / 24-05-2011 / 16:16:15 / cg"
13378
ed35cb03c4ed changed: #allowCoverageMeasurementOption
Claus Gittinger <cg@exept.de>
parents: 13377
diff changeset
   391
    "Modified: / 25-05-2011 / 00:21:18 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   392
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   393
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   394
allowDebugOption
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   395
    "enable/disable the --debug startup option.
11363
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   396
     Can be redefined in subclasses to enable it"
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   397
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   398
    ^ false
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
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   401
allowScriptingOption
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   402
    "enable/disable the --scripting startup option.
11363
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   403
     Can be redefined in subclasses to enable it"
11361
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
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   408
suppressRCFileReading
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   409
    "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
   410
     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
   411
     Can be redefined in subclasses to disable it"
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   412
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   413
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   414
! !
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   415
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
!StandaloneStartup class methodsFor:'helpers'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
11423
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   418
printInfo:msg
20669
4f391c2a9e9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20668
diff changeset
   419
    "print an informal message using the logger"
4f391c2a9e9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20668
diff changeset
   420
    
23672
af737017e287 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23427
diff changeset
   421
    (self applicationName,' [info]: ',msg asString) infoPrintCR.
23353
8243f9dd696d #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23210
diff changeset
   422
23672
af737017e287 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23427
diff changeset
   423
    "Modified: / 06-02-2019 / 18:38:36 / Claus Gittinger"
11423
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   424
!
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   425
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
redirectStandardStreams
20669
4f391c2a9e9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20668
diff changeset
   427
    "redirect all output for Transcript to stderr"
4f391c2a9e9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20668
diff changeset
   428
    
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
    Transcript := Stderr.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
13269
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   432
verbose
20670
5a948d181ab6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20669
diff changeset
   433
    "true iff the program was started with --verbose flag"
20669
4f391c2a9e9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20668
diff changeset
   434
    
13269
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   435
    ^ Verbose == true
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   436
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   437
    "Created: / 01-02-2011 / 15:52:47 / cg"
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   438
!
0009199731f6 added: #verbose
Claus Gittinger <cg@exept.de>
parents: 13130
diff changeset
   439
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
verboseInfo:msg
20670
5a948d181ab6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20669
diff changeset
   441
    "output some message, but only if the program was started with --verbose"
20669
4f391c2a9e9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20668
diff changeset
   442
    
18180
177321c514a9 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 18179
diff changeset
   443
    Verbose == true ifTrue:[
177321c514a9 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 18179
diff changeset
   444
        self printInfo:msg
177321c514a9 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 18179
diff changeset
   445
    ]
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    "Modified: / 19-09-2006 / 16:30:27 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
17707
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
   450
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   451
!StandaloneStartup class methodsFor:'multiple applications support'!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   452
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   453
applicationRegistryPath
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   454
    "the key under which this application stores its process ID in the registry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   455
     as a collection of path-components.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   456
     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
   457
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   458
     (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
   459
     Used to detect if another instance of this application is already running."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   460
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   461
    self subclassResponsibility
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   462
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   463
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   464
applicationUUID
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   465
    "answer an application-specific unique uuid.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   466
     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
   467
     if another instance of this application is already running.
13595
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   468
     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
   469
     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
   470
     similar possibly conflicting identifier.
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   471
     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
   472
    
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   473
    self subclassResponsibility
13595
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   474
c0db78969b83 comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents: 13580
diff changeset
   475
    "Modified (comment): / 19-08-2011 / 01:54:39 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   476
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   477
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   478
shouldReuseRunningApplication
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   479
    "answer true, if an already running application instance should be re-used"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   480
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   481
    ^ false
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   482
! !
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   483
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   484
!StandaloneStartup class methodsFor:'multiple applications support-helpers'!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   485
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   486
applicationRegistryEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   487
    "retrieve the registry entry in which (if present), any currently running application
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   488
     has left its process ID"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   489
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   490
    |path relPathName applicationEntry softwareEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   491
14321
783b5c28f912 changed: #applicationRegistryEntry
Stefan Vogel <sv@exept.de>
parents: 14048
diff changeset
   492
    OperatingSystem isMSWINDOWSlike ifFalse:[^ nil].
783b5c28f912 changed: #applicationRegistryEntry
Stefan Vogel <sv@exept.de>
parents: 14048
diff changeset
   493
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   494
    path := self applicationRegistryPath.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   495
    relPathName := path asStringWith:$\.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   496
    applicationEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\',relPathName.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   497
    applicationEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   498
        softwareEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   499
        softwareEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   500
            Transcript showCR: 'Failed to get Software entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   501
            ^ nil.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   502
        ].
11103
aae220bd7157 changed: #applicationRegistryEntry
fm
parents: 11102
diff changeset
   503
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   504
        path do:[:subKey |
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   505
            |subEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   506
11103
aae220bd7157 changed: #applicationRegistryEntry
fm
parents: 11102
diff changeset
   507
            subEntry := softwareEntry createSubKeyNamed:subKey.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   508
            subEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   509
                Transcript showCR: 'Failed to create ',subKey,' entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   510
                ^ nil.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   511
            ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   512
            softwareEntry := subEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   513
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   514
        applicationEntry := softwareEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   515
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   516
    ^ applicationEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   517
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   518
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   519
checkForAndExitIfAnotherApplicationInstanceIsRunning
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   520
    "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
   521
     send it an openFile command for my file-argument, and exit.
20537
56d8c9ceb94b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20486
diff changeset
   522
     (i.e. the already running app gets a (processOpenPathCommand:argument) message
56d8c9ceb94b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20486
diff changeset
   523
      to ask it to open up another window)."
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   524
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   525
    |shouldExit|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   526
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   527
    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
   528
    self isAnotherApplicationInstanceRunning ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   529
       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
   530
        shouldExit := self processStartupOfASecondInstance.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   531
        shouldExit ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   532
            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
   533
            self releaseApplicationMutex.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   534
            Smalltalk isStandAloneApp ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   535
                Smalltalk exit.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   536
            ]
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   537
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   538
    ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   539
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   540
    "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
   541
!
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   542
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   543
confirmOpenNewApplicationInstance
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   544
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   545
    ^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName)
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   546
                title: ('%1 is already open!!' bindWith:self applicationName)
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   547
             yesLabel: 'Continue' 
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   548
              noLabel: 'Exit'
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   549
!
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   550
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   551
currentBinaryPathKeyInRegistry
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   552
    ^ 'CurrentBinaryPath'
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   553
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   554
    "Created: / 11-10-2018 / 10:43:42 / sr"
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   555
!
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   556
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   557
currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   558
    ^ 'CurrentID'
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   559
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   560
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   561
getCurrentBinaryPathFromRegistry
23427
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   562
    "used to check if the binary of the running instance and the attaching is the same,
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   563
     if not do not attach to other version or even other installation"
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   564
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   565
    |applicationEntry val|
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   566
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   567
    applicationEntry := self applicationRegistryEntry.
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   568
    applicationEntry notNil ifTrue:[
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   569
        val := applicationEntry valueNamed:self currentBinaryPathKeyInRegistry.
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   570
        applicationEntry close.
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   571
    ].
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   572
    
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   573
    ^ val.
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   574
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   575
    "
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   576
        ExpeccoStartup writeCurrentBinaryPathIntoRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   577
        ExpeccoStartup getCurrentBinaryPathFromRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   578
        self assert:OperatingSystem pathOfSTXExecutable = ExpeccoStartup getCurrentBinaryPathFromRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   579
    "
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   580
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   581
    "Created: / 11-10-2018 / 10:47:20 / sr"
23427
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   582
    "Modified (comment): / 11-10-2018 / 16:28:53 / sr"
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   583
    "Modified: / 16-05-2019 / 19:25:17 / Stefan Vogel"
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   584
!
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   585
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   586
getCurrentIDFromRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   587
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   588
    |applicationEntry val|
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
    applicationEntry := self applicationRegistryEntry.
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   591
    applicationEntry notNil ifTrue:[
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   592
        val := applicationEntry valueNamed:self currentIDKeyInRegistry.
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   593
        applicationEntry close.
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   594
    ].
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   595
    ^ val.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   596
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   597
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   598
     |hWnd externalAddress|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   599
     hWnd := DapasXStartup getCurrentIDFromRegistry.   
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   600
     hWnd isEmptyOrNil ifTrue:[^ self halt.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   601
     hWnd := hWnd asInteger.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   602
     externalAddress := ExternalAddress newAddress: hWnd.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   603
     Display raiseWindow:externalAddress.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   604
     Display setForegroundWindow:externalAddress
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   605
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   606
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   607
    "Modified (format): / 11-10-2018 / 10:31:34 / sr"
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   608
    "Modified: / 16-05-2019 / 19:24:58 / Stefan Vogel"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   609
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   610
23426
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
   611
getIDOfRunningApplicationFromRegistryEntry
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   612
    |applicationEntry val|
23426
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
   613
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
   614
    applicationEntry := self applicationRegistryEntry.
24125
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   615
    applicationEntry notNil ifTrue:[
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   616
        val := applicationEntry valueNamed: self currentIDKeyInRegistry.
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   617
        applicationEntry close.
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   618
    ].
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   619
    ^ val.
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   620
060e01919399 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23680
diff changeset
   621
    "Modified: / 16-05-2019 / 19:24:31 / Stefan Vogel"
23426
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
   622
!
d8ce6bd803cb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23425
diff changeset
   623
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   624
isAnotherApplicationInstanceRunning
13083
66a8fb472eb5 comment/format in: #isAnotherApplicationInstanceRunning
Claus Gittinger <cg@exept.de>
parents: 12999
diff changeset
   625
    "answer true, if another instance of myself is currently running.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   626
     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
   627
    
11106
740c42559ef7 changed: #isAnotherApplicationInstanceRunning
fm
parents: 11105
diff changeset
   628
    | lastErrorCode alreadyExists handleAndLastErrorCode |
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   629
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   630
    OperatingSystem isMSDOSlike ifTrue:[
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   631
        self verboseInfo:('create mutex...').
20592
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   632
        handleAndLastErrorCode := OperatingSystem createMutexNamed:(self applicationUUID printString).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   633
        MutexHandle := handleAndLastErrorCode first.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   634
        lastErrorCode := handleAndLastErrorCode second.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   635
        "/ self assert: lastErrorCode == 0.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   636
        alreadyExists := 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   637
            MutexHandle isNil 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   638
            or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   639
            or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   640
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   641
        self verboseInfo:('alreadyExists = ',alreadyExists printString).
20592
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   642
        alreadyExists ifTrue:[
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   643
            "we do not own the Mutex, so we cannot release it"
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   644
            MutexHandle notNil ifTrue:[
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   645
                OperatingSystem primCloseHandle: MutexHandle.
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   646
                MutexHandle := nil.
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   647
            ].
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   648
        ] ifFalse:[
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   649
            "no need to wait, createMutex sets initialOwner = true"    
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   650
"/            OperatingSystem waitForSingleObject: MutexHandle.
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   651
        ].
fe2fe29df676 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 20587
diff changeset
   652
        ^ alreadyExists.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   653
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   654
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   655
    ^ false.
13083
66a8fb472eb5 comment/format in: #isAnotherApplicationInstanceRunning
Claus Gittinger <cg@exept.de>
parents: 12999
diff changeset
   656
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
   657
    "Modified: / 04-02-2011 / 00:05:51 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   658
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   659
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   660
processStartupOfASecondInstance
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   661
    "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
   662
     If I can get the currentID (i.e. windowID) of the first one and there is a command line argument with a file, 
20537
56d8c9ceb94b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20486
diff changeset
   663
     send a message (processOpenPathCommand:argument) 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
   664
     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
   665
     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
   666
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   667
    |currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded|
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   668
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
   669
    commands := CommandLineArguments.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   670
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   671
    currentIDStringFromRegistry := self getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   672
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   673
    "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
   674
     we should wait in case of starting the first instance of the application 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   675
     with a multiple selection of files."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   676
    (currentIDStringFromRegistry isEmptyOrNil and:[commands notEmptyOrNil]) ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   677
        Delay waitForSeconds: 2.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   678
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   679
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   680
    currentIDStringFromRegistry := self getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   681
    currentIDStringFromRegistry isEmptyOrNil ifTrue:[
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   682
        ^ self confirmOpenNewApplicationInstance not.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   683
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   684
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   685
    currentIDFromRegistry := Integer readFrom:currentIDStringFromRegistry onError: 0.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   686
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   687
    "/ bring the other application to the foreground
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   688
    aWindowId := ExternalAddress newAddress: currentIDFromRegistry.
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   689
    setForegroundWindowSucceeded := Display primSetForegroundWindow: aWindowId.
11379
2cd74df95a0e changed: #processStartupOfASecondInstance
fm
parents: 11363
diff changeset
   690
"/    setForegroundWindowSucceeded ifFalse:[^ self confirmOpenNewApplicationInstance not].
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   691
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   692
    "Autostart for associated extension"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   693
    commands notEmpty ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   694
        fileArg := commands last asFilename.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   695
        fileArg exists ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   696
            self sendOpenPathCommand:(fileArg pathName) toWindowId: aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   697
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   698
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   699
    ^ true
12935
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   700
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   701
    "Modified: / 08-07-2010 / 00:47:44 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   702
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   703
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   704
releaseApplicationMutex
12933
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   705
    (MutexHandle notNil and:[OperatingSystem isMSDOSlike]) ifTrue:[
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   706
        OperatingSystem releaseMutex: MutexHandle.
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   707
        OperatingSystem primCloseHandle: MutexHandle.
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   708
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   709
        MutexHandle := nil.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   710
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   711
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   712
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   713
sendCommand:message toWindowId:aWindowId
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   714
    "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
   715
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   716
    Display 
20583
9631f44a2171 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 20576
diff changeset
   717
        sendCopyData: message 
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   718
        toWindowId: aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   719
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   720
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   721
sendOpenPathCommand:pathName toWindowId:aWindowId
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   722
    "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
   723
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   724
    self sendCommand:('openPath:', pathName) toWindowId:aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   725
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   726
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   727
writeCurrentBinaryPathIntoRegistry
23427
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   728
    "used to check if the binary of the running instance and the attaching is the same,
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   729
     if not do not attach to other version or even other installation"
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   730
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   731
    |applicationEntry currentBinaryPathKeyInRegistry currentIDEntry|
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   732
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   733
    applicationEntry := self applicationRegistryEntry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   734
    applicationEntry isNil ifTrue:[
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   735
        Transcript showCR:'Failed to fetch application registry entry in registry'.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   736
        ^ false
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   737
    ].
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   738
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   739
    currentBinaryPathKeyInRegistry := self currentBinaryPathKeyInRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   740
    currentIDEntry := applicationEntry createSubKeyNamed:currentBinaryPathKeyInRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   741
    currentIDEntry isNil ifTrue:[
24415
225cd31aed1a #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 24125
diff changeset
   742
        Transcript showCR:'Failed to create %1 entry in registry' with:currentBinaryPathKeyInRegistry.
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   743
        ^ false
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   744
    ].
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   745
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   746
    ^ applicationEntry 
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   747
        valueNamed:currentBinaryPathKeyInRegistry 
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   748
        put:OperatingSystem pathOfSTXExecutable.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   749
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   750
    "
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   751
        ExpeccoStartup writeCurrentBinaryPathIntoRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   752
        ExpeccoStartup getCurrentBinaryPathFromRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   753
        self assert:OperatingSystem pathOfSTXExecutable = ExpeccoStartup getCurrentBinaryPathFromRegistry.
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   754
    "
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   755
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   756
    "Created: / 11-10-2018 / 10:45:17 / sr"
23427
63adc4d1d09f #DOCUMENTATION by sr
sr
parents: 23426
diff changeset
   757
    "Modified (comment): / 11-10-2018 / 16:29:05 / sr"
23421
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   758
!
99e827978ecc #FEATURE by sr
sr
parents: 23353
diff changeset
   759
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   760
writeCurrentIDIntoRegistry: currentID
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   761
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   762
    |applicationEntry currentIDEntry|
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   763
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   764
    applicationEntry := self applicationRegistryEntry.
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   765
    applicationEntry isNil ifTrue:[^ false.].
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   766
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   767
    currentIDEntry := applicationEntry createSubKeyNamed:(self currentIDKeyInRegistry).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   768
    currentIDEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   769
        Transcript showCR: 'Failed to create CurrentID entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   770
        ^ false.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   771
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   772
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   773
    ^ applicationEntry valueNamed:(self currentIDKeyInRegistry) put:(currentID printString).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   774
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   775
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   776
     | currentID returnedCurrentID |
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   777
     currentID := 999.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   778
     DapasXStartup writeCurrentIDIntoRegistry: currentID.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   779
     returnedCurrentID := DapasXStartup getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   780
     self assert: currentID = returnedCurrentID asNumber.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   781
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   782
! !
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   783
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
!StandaloneStartup class methodsFor:'queries'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
applicationName
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   787
    "used in verbose messages - can/should be redefined in subclasses"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
    |nm|
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
    nm := self nameWithoutPrefix.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
    (nm endsWith:'Startup') ifTrue:[
15162
f17158d75a0e Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 14977
diff changeset
   793
        ^ nm copyButLast:('Startup' size).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
    (nm endsWith:'Start') ifTrue:[
15162
f17158d75a0e Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 14977
diff changeset
   796
        ^ nm copyButLast:('Start' size).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    ^ nm
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
    "Created: / 19-09-2006 / 16:26:44 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
14544
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   803
commandLineArguments
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   804
    ^ CommandLineArguments
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   805
!
c11b4519b460 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 14321
diff changeset
   806
19518
78207b7c73fc #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19517
diff changeset
   807
isAbstract
78207b7c73fc #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19517
diff changeset
   808
    ^ self == StandaloneStartup
78207b7c73fc #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19517
diff changeset
   809
!
78207b7c73fc #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 19517
diff changeset
   810
10040
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   811
isBrowserStartable
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   812
    "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
   813
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   814
    ^ false
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   815
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   816
    "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
   817
!
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   818
12626
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   819
keepSplashWindowOpen
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   820
    "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
   821
     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
   822
     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
   823
     (calling hideSplashWindow)
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   824
     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
   825
     subclasses main: is invoked."
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   826
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   827
    ^ false
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   828
!
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   829
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   830
patchesDirectory
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   831
    "answer a directory containing patches.
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   832
     The directory needs not to be present."
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   833
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   834
    ^ OperatingSystem pathOfSTXExecutable asFilename directory construct:'patches'.
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   835
!
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   836
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
startupFilename
23425
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   838
    "used in verbose messages - can/should be redefined in subclasses.
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   839
     Only return a basename here."
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
    ^ self applicationName asLowercase,'Start.rc'
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
    "
23422
ed09984cc665 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23421
diff changeset
   844
     ExpeccoStartup startupFilename -> 'expeccoStart.rc'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    "
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
    "Created: / 19-09-2006 / 16:38:28 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
!StandaloneStartup class methodsFor:'startup'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   852
handleRCFileOptionsFromArguments:argv
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   853
    "handle rc-file command line arguments:
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   854
        --rcFileName ......... define a startup rc-file
23422
ed09984cc665 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23421
diff changeset
   855
                               (defaults to <appname>Start.rc)    
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   856
    "
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   857
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   858
    |idx nextArg rcFilename|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   859
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   860
    idx := argv indexOf:'--rcFileName'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   861
    idx ~~ 0 ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   862
        nextArg := argv at:(idx + 1) ifAbsent:nil.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   863
        (nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   864
            rcFilename := nextArg.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   865
            argv removeAtIndex:idx+1; removeAtIndex:idx.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   866
        ]
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   867
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   868
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   869
    rcFilename isNil ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   870
        rcFilename := self startupFilename.
23425
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   871
        
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   872
    ].
23425
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   873
    rcFilename notNil ifTrue:[
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   874
        rcFilename asFilename exists ifFalse:[
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   875
            rcFilename asFilename isAbsolute ifFalse:[
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   876
                rcFilename := OperatingSystem pathOfSTXExecutable asFilename directory constructString:rcFilename.
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   877
            ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   878
        ].
23425
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   879
        rcFilename asFilename exists ifTrue:[
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   880
            self verboseInfo:('reading ',rcFilename,'...').
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   881
            Smalltalk secureFileIn:rcFilename
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   882
        ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   883
    ].
23425
21edd7a6b660 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23422
diff changeset
   884
    
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   885
    "Created: / 24-05-2011 / 16:13:34 / cg"
23199
7aee2cc2ace7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22692
diff changeset
   886
    "Modified: / 06-07-2018 / 16:38:13 / Claus Gittinger"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   887
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   888
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   889
handleScriptingOptionsFromArguments:argv
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   890
    "handle scripting command line argument:
19879
eb2ba55b73bb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19590
diff changeset
   891
        --scripting portNr ... start a scripting server on port (or default, if missing)
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   892
        --allowHost host ..... add host to the allowed scripting hosts
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   893
    "
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   894
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   895
    |scripting idx nextArg portNr allowedScriptingHosts|
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   896
19881
8ba1bb8e7506 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19880
diff changeset
   897
    self verboseInfo:('handle scripting: ',argv asArray printString).
8ba1bb8e7506 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19880
diff changeset
   898
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   899
    scripting := false.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   900
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   901
    idx := argv indexOfAny:#('--scripting').
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   902
    idx ~~ 0 ifTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   903
        nextArg := argv at:(idx + 1) ifAbsent:nil.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   904
        (nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   905
            portNr := nextArg asInteger.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   906
            argv removeAtIndex:idx+1.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   907
        ].
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   908
        argv removeAtIndex:idx.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   909
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   910
        scripting := true
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   911
    ].
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   912
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   913
    allowedScriptingHosts := OrderedCollection new.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   914
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   915
    idx := argv indexOfAny:#('--allowHost').
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   916
    [idx ~~ 0] whileTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   917
        nextArg := argv at:(idx + 1) ifAbsent:nil.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   918
        nextArg isNil ifTrue:[
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   919
            self usage.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   920
            AbortOperationRequest raise.
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   921
        ].
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   922
        allowedScriptingHosts add:nextArg.
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   923
        idx := argv indexOfAny:#('--allowHost').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   924
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   925
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   926
    scripting ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   927
        self verboseInfo:('scripting on').
16131
3caa8b31823f class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15899
diff changeset
   928
        STXScriptingServer isNil ifTrue:[
16237
4df960fd7c26 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16236
diff changeset
   929
            [
4df960fd7c26 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16236
diff changeset
   930
                Smalltalk loadPackage:'stx:goodies/simpleServices'.
4df960fd7c26 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16236
diff changeset
   931
            ] on:PackageLoadError do:[:ex|
4df960fd7c26 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16236
diff changeset
   932
                self verboseInfo:('missing STXScriptingServer package (stx:goodies/simpleServices)').
4df960fd7c26 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16236
diff changeset
   933
                ^ self.
4df960fd7c26 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16236
diff changeset
   934
            ]
16131
3caa8b31823f class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15899
diff changeset
   935
        ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   936
        STXScriptingServer notNil ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   937
            allowedScriptingHosts do:[:eachHost | STXScriptingServer allowHost:eachHost ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   938
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   939
            "/ scripting on port/stdin_out/8008
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   940
            self verboseInfo:('start scripting').
19881
8ba1bb8e7506 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19880
diff changeset
   941
            STXScriptingServer server:(STXScriptingServer startAt:portNr)
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   942
        ] ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   943
            self verboseInfo:('missing STXScriptingServer class').
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   944
        ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   945
    ].
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   946
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   947
    "Created: / 24-05-2011 / 16:12:02 / cg"
13376
4d32b325003f changed:
Claus Gittinger <cg@exept.de>
parents: 13375
diff changeset
   948
    "Modified: / 24-05-2011 / 17:40:26 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   949
!
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
   950
11055
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   951
loadPatch:fileName
11056
e2c4a6e948b6 loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 11055
diff changeset
   952
    self verboseInfo:('loading patch: ',fileName baseName).
22692
9f3eab852dbb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22332
diff changeset
   953
    ^ [
16307
2a1eda5a904b class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16237
diff changeset
   954
        Smalltalk silentFileIn:fileName.
15899
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   955
    ] on:InvalidPatchError do:[:ex|
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   956
        self verboseInfo:('invalid patch: %1 error: %2'
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   957
                                 bindWith:fileName baseName with:ex messageText).
22692
9f3eab852dbb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22332
diff changeset
   958
        false.
15899
4dcd8c4200b0 class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15895
diff changeset
   959
    ].
22692
9f3eab852dbb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22332
diff changeset
   960
9f3eab852dbb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22332
diff changeset
   961
    "Modified: / 23-04-2018 / 17:08:06 / stefan"
11055
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   962
!
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   963
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
loadPatches
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   965
    "load all patches in the application's patches dir"
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   966
15504
52b934e3c98c class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15503
diff changeset
   967
    self possiblyCheckForNewPatchesOnServer.
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   968
    self loadPatchesMatching:nil.
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   969
!
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   970
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   971
loadPatchesMatching:aGlobString
15502
60b630074a16 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15162
diff changeset
   972
    "load the patches in the application's patches dir.
21499
d6d0a20ff60e #DOCUMENTATION by mawalch
mawalch
parents: 21343
diff changeset
   973
     If aGlobString is not empty or nil, only patches matching the glob
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   974
     pattern are loaded. E.g. '[0-9]*.chg'"
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   975
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   976
    |patchesDir prevMode patchesToLoad|
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
18525
6b76f94a31ae allow for patchesDirectory to return a string
Claus Gittinger <cg@exept.de>
parents: 18180
diff changeset
   978
    patchesDir := self patchesDirectory asFilename.
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   979
    patchesDir isDirectory ifTrue:[
11764
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   980
        prevMode := ClassCategoryReader sourceMode.
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   981
        ClassCategoryReader sourceMode:#discard.
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   982
        [
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   983
            patchesToLoad := patchesDir directoryContentsAsFilenames.
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   984
            patchesToLoad := patchesToLoad select:[:eachFilenameString|
21499
d6d0a20ff60e #DOCUMENTATION by mawalch
mawalch
parents: 21343
diff changeset
   985
                    eachFilenameString asFilename isRegularFile
15818
cc392ec9285c class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 15739
diff changeset
   986
                ].
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   987
            aGlobString notEmptyOrNil ifTrue:[
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   988
                patchesToLoad := patchesToLoad select:[:eachFilename|
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   989
                        aGlobString match:eachFilename baseName caseSensitive:false
13796
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   990
                    ].
b163498d6e17 added: #loadPatchesMatching:
Stefan Vogel <sv@exept.de>
parents: 13595
diff changeset
   991
            ].
15894
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   992
            (patchesToLoad sort:[:a :b | a baseName < b baseName]) do:[:patchFile |
335888decf07 class: StandaloneStartup
sr
parents: 15830
diff changeset
   993
                self loadPatch:patchFile.
11764
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   994
            ].
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   995
        ] ensure:[
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   996
            ClassCategoryReader sourceMode:prevMode.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
    "Modified: / 19-09-2006 / 16:30:58 / cg"
15827
e97e83b43873 class: StandaloneStartup
sr
parents: 15818
diff changeset
  1001
    "Modified: / 25-11-2013 / 12:27:33 / sr"
21499
d6d0a20ff60e #DOCUMENTATION by mawalch
mawalch
parents: 21343
diff changeset
  1002
    "Modified (comment): / 21-02-2017 / 14:34:28 / mawalch"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1005
loadRemainingClassLibraries
25117
95ca71f47a00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 25107
diff changeset
  1006
    "Windows only.
95ca71f47a00 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 25107
diff changeset
  1007
     To speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present).
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1008
     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
  1009
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1010
    |modulesFile dllDirectory dlls|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1011
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1012
    OperatingSystem isMSWINDOWSlike ifFalse:[^ self ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1013
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1014
    self verboseInfo:'loadRemainingClassLibraries'.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1015
    modulesFile  := self stxModulesFilename.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1016
    dllDirectory := modulesFile directory.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1017
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1018
    dlls := OrderedCollection new.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1019
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1020
    modulesFile readingLinesDo:[:eachModulesLine|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1021
        |basename dllFile|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1022
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1023
        basename := eachModulesLine withoutSeparators.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1024
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1025
        (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
  1026
            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
  1027
            dllFile := dllDirectory construct:basename.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1028
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1029
            dllFile exists ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1030
"/                self verboseInfo:('loading: ', basename).
13580
e5383cbbf032 changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents: 13378
diff changeset
  1031
"/                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
  1032
                dlls add:dllFile.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1033
            ] ifFalse:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1034
                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
  1035
            ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1036
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1037
    ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1038
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1039
    dlls notEmpty ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1040
        ObjectFileLoader loadObjectFiles:dlls.
13322
8a1d5d6205cc changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents: 13280
diff changeset
  1041
        ProjectDefinition initializeAllProjectDefinitions.
8a1d5d6205cc changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents: 13280
diff changeset
  1042
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1043
        Display notNil ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1044
            "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
  1045
            self verboseInfo:'update style caches of loaded dlls'.
12999
a5ab22c6470c changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents: 12998
diff changeset
  1046
            SimpleView readStyleSheetAndUpdateAllStyleCaches.
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1047
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1048
    ].
13580
e5383cbbf032 changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents: 13378
diff changeset
  1049
e5383cbbf032 changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents: 13378
diff changeset
  1050
    "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
  1051
!
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1052
15503
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
  1053
possiblyCheckForNewPatchesOnServer
22332
0b9d2ed54342 #DOCUMENTATION by mawalch
mawalch
parents: 22020
diff changeset
  1054
    "to be redefined in concrete applications: check for patches on a server"
15503
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
  1055
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
  1056
    "/ intentionally left blank
22332
0b9d2ed54342 #DOCUMENTATION by mawalch
mawalch
parents: 22020
diff changeset
  1057
0b9d2ed54342 #DOCUMENTATION by mawalch
mawalch
parents: 22020
diff changeset
  1058
    "Modified (comment): / 08-11-2017 / 17:59:40 / mawalch"
15503
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
  1059
!
bc9477abd6a0 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15502
diff changeset
  1060
15830
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1061
removeDebugger
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1062
    Smalltalk at:#Debugger put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1063
!
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1064
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1065
removeInspector
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1066
    Smalltalk at:#Inspector put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1067
!
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1068
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1069
removeLauncher
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1070
    NewLauncher notNil ifTrue:[
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1071
        NewLauncher allPrivateClasses do:[:cls |
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1072
            Smalltalk at:(cls name) put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1073
        ].
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1074
        Smalltalk at:#NewLauncher put:nil.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1075
    ].
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1076
!
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1077
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
setupSmalltalkFromArguments:argv
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1079
    "handle common command line arguments:
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1080
        --help ............... print usage and exit
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1081
        --verbose (-V) ....... be verbose during startup
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1082
        --debug .............. enable debugger & inspector
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1083
        --rcFileName ......... define a startup rc-file
23422
ed09984cc665 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23421
diff changeset
  1084
                               (defaults to <appname>Start.rc)    
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
  1085
        --scripting portNr ... start a scripting server
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
  1086
        --allowHost host ..... add host to the allowed scripting hosts
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1087
    "
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1088
16235
9cc3d059960d class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 16233
diff changeset
  1089
    |idx debugging baseDir|
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
"/    Smalltalk beHeadless:true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
"/    OperatingSystem disableSignal:(OperatingSystem sigHUP).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
"/    Smalltalk infoPrinting:true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    (argv includes:'--help') ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
        self usage.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
        AbortOperationRequest raise.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
    idx := argv indexOfAny:#('--verbose' '-V').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
    idx ~~ 0 ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
        argv removeAtIndex:idx.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
        Verbose := true.
23673
a6421eabb7f2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23672
diff changeset
  1104
        Object infoPrinting:true.
a6421eabb7f2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23672
diff changeset
  1105
        (Logger ? MiniLogger) notNil ifTrue:[
a6421eabb7f2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23672
diff changeset
  1106
            (Logger ? MiniLogger) loggingThreshold:(Logger ? MiniLogger) severityALL.
20486
8e25a1394997 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20428
diff changeset
  1107
        ].    
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
    ].
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
  1109
    self verboseInfo:('args: ',argv asArray printString).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1111
    debugging := false.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1112
    (self allowDebugOption) ifTrue:[
13126
8cbc00290e5b changed: #setupSmalltalkFromArguments:
Claus Gittinger <cg@exept.de>
parents: 13089
diff changeset
  1113
        idx := argv indexOf:'--debug'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1114
        idx ~~ 0 ifTrue:[
11357
0a710cf52bb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11356
diff changeset
  1115
            self verboseInfo:('debug on').
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1116
            argv removeAtIndex:idx.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1117
            debugging := true
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1118
        ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1119
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1120
    debugging ifTrue:[
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
        self setupToolsForDebug.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
    ] ifFalse:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
        self setupToolsForNoDebug.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
    ].
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1125
    baseDir := OperatingSystem pathOfSTXExecutable asFilename directory.
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1126
    baseDir baseName = 'application' ifTrue:[
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1127
        ".../work/exept/expecco/application/expecco -> .../work/"
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1128
        baseDir := baseDir directory directory directory.
21676
3f8d5056f05c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21499
diff changeset
  1129
        Smalltalk packagePath add:(baseDir pathName).
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1130
    ] ifFalse:[
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1131
        "/opt/expecco/bin/expecco -> /opt/expecco/"
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1132
        baseDir := baseDir directory.
21676
3f8d5056f05c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21499
diff changeset
  1133
        Smalltalk packagePath add:(baseDir constructString:'packages').
16236
7a8308397650 Set packagePath
Stefan Vogel <sv@exept.de>
parents: 16235
diff changeset
  1134
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1136
    (self suppressRCFileReading) ifFalse:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1137
        self handleRCFileOptionsFromArguments:argv.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1139
    (self allowScriptingOption) ifTrue:[
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1140
        self handleScriptingOptionsFromArguments:argv.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
    ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1142
    (self allowCoverageMeasurementOption) ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1143
        self handleCoverageMeasurementOptionsFromArguments:argv.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1145
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
    ^ true
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1148
    "Modified: / 24-05-2011 / 16:14:45 / cg"
21676
3f8d5056f05c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21499
diff changeset
  1149
    "Modified (format): / 31-03-2017 / 13:10:04 / cg"
23673
a6421eabb7f2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23672
diff changeset
  1150
    "Modified: / 06-02-2019 / 19:21:50 / Claus Gittinger"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1153
setupToolsForDebug
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1154
    Debugger := DebugView ? MiniDebugger.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1155
    Inspector := InspectorView ? MiniInspector.
11736
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
  1156
    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
  1157
"/    self verboseInfo:('debug enabled - CTRL-C brings you into a debugger.').
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
    "Created: / 19-09-2006 / 16:40:32 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1162
setupToolsForNoDebug
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1163
    Smalltalk isStandAloneApp ifTrue:[
15830
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1164
        self removeDebugger.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1165
        self removeInspector.
aa41c94cfc82 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 15827
diff changeset
  1166
11736
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
  1167
        Verbose ifTrue:[ 'debug disabled.' errorPrintCR ].
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1168
        self redirectStandardStreams.
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
  1169
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
    "Created: / 19-09-2006 / 16:40:47 / cg"
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
  1172
    "Modified: / 31-10-2007 / 16:18:40 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1175
start
20575
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1176
    "this is the default initial entry into a standalone program.
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1177
     It checks for any remaining shared libraries/packages which need to be
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1178
     loaded, looks for any patch-files to be applied
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1179
     and then enters into main.
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1180
     On systems, which allow for the same app to be started for multiple documents
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1181
     (i.e. windows), when clicking on a document), 
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1182
     first check if there is an already running application and tell it to open
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1183
     a window for the new document."
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1184
     
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1185
    GenericException handle:[:ex |
19590
445c1c162669 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 19518
diff changeset
  1186
        self verboseInfo:'Error during startup:'.
445c1c162669 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 19518
diff changeset
  1187
        self verboseInfo:ex description.
12996
8662430ec3de changed: #start
Stefan Vogel <sv@exept.de>
parents: 12992
diff changeset
  1188
        Verbose == true ifTrue:[ex suspendedContext fullPrintAllLevels:10].
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1189
        ex reject.        
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1190
    ] do:[
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1191
        |idx|
13127
60b2005943bb changed: #start
Claus Gittinger <cg@exept.de>
parents: 13126
diff changeset
  1192
25107
e5a2c223f111 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 25106
diff changeset
  1193
        CommandLineArguments := (self additionalArgumentsFromRegistry) , Smalltalk commandLineArguments.
23675
cb888670c53b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23674
diff changeset
  1194
19590
445c1c162669 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 19518
diff changeset
  1195
        Smalltalk showSplashMessage:'start'.
445c1c162669 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 19518
diff changeset
  1196
        self verboseInfo:'starting...'.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1198
        self verboseInfo:('args: ', CommandLineArguments asStringCollection asString).
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1199
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1200
        "--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
  1201
         but run in a separate process"
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1202
        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
  1203
        idx == 0 ifTrue:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1204
            self shouldReuseRunningApplication ifTrue:[
19590
445c1c162669 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 19518
diff changeset
  1205
                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
  1206
                "Multiple Application support:
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1207
                 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
  1208
                 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
  1209
                self checkForAndExitIfAnotherApplicationInstanceIsRunning.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1210
            ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1211
        ] ifFalse:[
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1212
            CommandLineArguments removeAtIndex:idx.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1213
        ].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1214
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1215
        "/ 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
  1216
        "/ 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
  1217
        "/ 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
  1218
        self loadRemainingClassLibraries.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1219
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1220
        Smalltalk isStandAloneApp ifTrue:[
20587
cdcab9745677 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20583
diff changeset
  1221
            self verboseInfo:'looking for patches'.
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1222
            self loadPatches.
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
  1223
        ].
20576
96eacca3debf #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20575
diff changeset
  1224
        self verboseInfo:'setup Smalltalk'.
23680
988048869494 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23676
diff changeset
  1225
        self setupSmalltalkFromArguments:CommandLineArguments.
20575
b3f2276a01eb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20566
diff changeset
  1226
        self main:CommandLineArguments
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
13280
d5bbbf1caefa changed:
Claus Gittinger <cg@exept.de>
parents: 13269
diff changeset
  1229
    "Modified: / 04-02-2011 / 00:03:47 / cg"
23680
988048869494 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 23676
diff changeset
  1230
    "Modified: / 06-02-2019 / 21:35:35 / Claus Gittinger"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1232
11807
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1233
startStartBlockProcess
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1234
    Smalltalk startStartBlockProcess
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1235
!
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
  1236
12998
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1237
stxModulesFilename
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1238
    "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
  1239
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1240
    |file|
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1241
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1242
    file := 'modules.stx' asFilename.
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1243
    file exists ifTrue:[^ file].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1244
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1245
    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
  1246
    file exists ifTrue:[^ file].
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1247
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1248
    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
  1249
!
c967aa65e09a Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 12996
diff changeset
  1250
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1251
usage
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1252
    Stderr nextPutLine:'usage: ',self applicationName,' [options...]'.
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1253
    Stderr nextPutLine:'  --help .................. output this message'.
25105
8885d4f6989b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 24415
diff changeset
  1254
    Stderr nextPutLine:'  --version ............... print version & exit'.
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1255
    Stderr nextPutLine:'  --verbose ............... verbose startup'.
17707
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
  1256
    self isHeadless ifFalse:[
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
  1257
        Stderr nextPutLine:'  --noBanner .............. no splash screen'.
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
  1258
    ].
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
  1259
    OperatingSystem isMSWINDOWSlike ifTrue:[
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
  1260
        Stderr nextPutLine:'  --newAppInstance ........ start as its own application process (do not reuse a running instance)'.
62968cb231d8 class: StandaloneStartup
Claus Gittinger <cg@exept.de>
parents: 17280
diff changeset
  1261
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1262
    self allowScriptingOption ifTrue:[
19880
997db2dc51c6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19879
diff changeset
  1263
        Stderr nextPutLine:'  --scripting <portNr> .... enable scripting via port (or stdin/stdOut, if 0. Default is 8008)'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1264
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1265
    self allowDebugOption ifTrue:[
13089
f31a89295700 changed:
Claus Gittinger <cg@exept.de>
parents: 13084
diff changeset
  1266
        Stderr nextPutLine:'  --debug ................. enable Debugger'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1267
    ].
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1268
    self allowCoverageMeasurementOption ifTrue:[
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1269
        Stderr nextPutLine:'  --coverage .............. turn on coverage measurement'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1270
        Stderr nextPutLine:'     [+/-]package: pattern ...  - include/exclude packages'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1271
        Stderr nextPutLine:'     [+/-]class: pattern ...    - include/exclude classes'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1272
        Stderr nextPutLine:'     [+/-]method: cls#sel ...   - include/exclude methods'.
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1273
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
  1274
    self suppressRCFileReading ifFalse:[
23210
953a861ee4de #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23199
diff changeset
  1275
        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
  1276
    ].
23210
953a861ee4de #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23199
diff changeset
  1277
    Stderr nextPutLine:'  --preferences <fileName> ........... read smalltalk preferences from file (instead of "~/.settings.stx")'.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1278
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
    "Created: / 19-09-2006 / 16:37:55 / cg"
13375
921f77dd800d coverage support
Claus Gittinger <cg@exept.de>
parents: 13354
diff changeset
  1280
    "Modified: / 24-05-2011 / 17:23:18 / cg"
23210
953a861ee4de #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23199
diff changeset
  1281
    "Modified: / 16-07-2018 / 12:53:04 / Claus Gittinger"
20563
11fabc4264bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20537
diff changeset
  1282
!
11fabc4264bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20537
diff changeset
  1283
11fabc4264bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20537
diff changeset
  1284
usageAndExitWith:exitCode
20566
b43ea3fc00be #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20563
diff changeset
  1285
    "show the usage message, then exit with given exitCode"
b43ea3fc00be #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20563
diff changeset
  1286
    
20563
11fabc4264bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20537
diff changeset
  1287
    self usage.
11fabc4264bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20537
diff changeset
  1288
    Smalltalk exitIfStandalone:exitCode
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1289
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
!StandaloneStartup class methodsFor:'startup-to be redefined'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1292
12991
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1293
additionalArgumentsFromRegistry
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1294
    "can be redefined to fetch and return additional arguments from the registry 
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1295
     (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
  1296
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1297
    ^ #()
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1298
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1299
    "Created: / 04-08-2010 / 12:20:27 / cg"
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1300
!
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
  1301
11806
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1302
isHeadless
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1303
    "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
  1304
     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
  1305
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1306
     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
  1307
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1308
    ^ false
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1309
!
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
  1310
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1311
main
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1312
    self verboseInfo:('entering main').
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1313
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1314
    self main:CommandLineArguments.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1315
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1316
    "
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1317
     self main
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1318
     self main:#('--info') 
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1319
    "
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1320
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1321
    "Modified: / 31-10-2007 / 16:03:22 / cg"
10636
ba91c2d292f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10040
diff changeset
  1322
!
ba91c2d292f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10040
diff changeset
  1323
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1324
main:argv
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1325
    self subclassResponsibility.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1326
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1327
"/ a typical main: looks like (in a subclass):
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1328
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1329
"/    |app fileArg|
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1330
"/
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
  1331
"/    self verboseInfo:('starting application').
14977
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1332
"/
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1333
"/    self startStartBlockProcess.
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1334
"/    Smalltalk openDisplay.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
"/    app := <someGUIApplicationModelClass> open.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
"/    self verboseInfo:('looking for args in ',argv).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
"/    argv notEmptyOrNil ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
"/        fileArg := argv last asFilename.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
"/        self verboseInfo:('fileArg is ',fileArg name).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
"/        fileArg exists ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
"/            self verboseInfo:('file exists').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
"/            ( #('foo' 'bar' 'baz' ) includes:fileArg suffix) ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
"/                self verboseInfo:('loading').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
"/                Error handle:[:ex |
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
"/                    self verboseInfo:'error while loading'.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
"/                    ex suspendedContext fullPrintAll.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
"/                ] do:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
"/                    app menuLoadFromFile:fileArg
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
"/                ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
"/            ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
"/        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
"/    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
    "Created: / 19-09-2006 / 16:48:29 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
!StandaloneStartup class methodsFor:'documentation'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
version
18525
6b76f94a31ae allow for patchesDirectory to return a string
Claus Gittinger <cg@exept.de>
parents: 18180
diff changeset
  1363
    ^ '$Header$'
12335
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
  1364
!
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
  1365
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
  1366
version_CVS
18525
6b76f94a31ae allow for patchesDirectory to return a string
Claus Gittinger <cg@exept.de>
parents: 18180
diff changeset
  1367
    ^ '$Header$'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
14977
c67d55de705e class: StandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 14544
diff changeset
  1370
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
StandaloneStartup initialize!