StandaloneStartup.st
author Stefan Vogel <sv@exept.de>
Thu, 05 Aug 2010 15:16:45 +0200
changeset 12996 8662430ec3de
parent 12992 cad1bd395046
child 12998 c967aa65e09a
permissions -rw-r--r--
changed: #start
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
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Object subclass:#StandaloneStartup
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
10772
13bb80f40496 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10636
diff changeset
    16
	classVariableNames:'Verbose CommandLineArguments'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'System-Support'
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    21
StandaloneStartup class instanceVariableNames:'MutexHandle'
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    22
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    23
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    24
 No other class instance variables are inherited by this class.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    25
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    26
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    27
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!StandaloneStartup class methodsFor:'documentation'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
copyright
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 (c) 2006 by eXept Software AG
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
              All Rights Reserved
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 This software is furnished under a license and may be used
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 only in accordance with the terms of that license and with the
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 inclusion of the above copyright notice.   This software may not
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 be provided or otherwise made available to, or used by, any
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 other person.  No title to or ownership of the software is
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 hereby transferred.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
documentation
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    a subclassable template class for a standalone GUI-application's startup;
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    For your own stand alone programs, define a subclass of this, 
12335
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
    48
    and redefine the #main: method there.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    (of course, the other methods can also be redefined.)
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    [author:]
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        Claus Gittinger
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    [start with:]
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        <yourNamehere>Startup start
10886
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    56
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    57
    [see also:]
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    58
        Smalltalk
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    59
        GetOpt
f5ce5c02e1a7 comments
Claus Gittinger <cg@exept.de>
parents: 10773
diff changeset
    60
        ReadEvalPrintLoop
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    62
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    63
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    64
howToDealWithMultipleApplicationInstances
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    65
"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    66
    please read the comment in the corresponding ApplicationModel class-documentation method.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
    67
"
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    68
!
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    69
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    70
whichMethodsToRedefine
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    71
"
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    72
    main:argv
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    73
        thats the actual program.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    74
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    75
    suppressRCFileReading
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    76
        false here; redefine to return true, to disable the rc-file reading.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    77
        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
    78
        (if you have a user-phobia)
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
    allowDebugOption
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    81
        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
    82
        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
    83
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    84
    allowScriptingOption
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    85
        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
    86
        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
    87
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
    88
"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!StandaloneStartup class methodsFor:'initialization'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
initialize
11360
e309e560dcee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11359
diff changeset
    94
    "/ Verbose := true.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    Verbose := false.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    98
!StandaloneStartup class methodsFor:'defaults'!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
    99
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   100
allowDebugOption
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   101
    "enable/disable the --debug startup option.
11363
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   102
     The default is now false, so standAlone apps are closed by default.
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   103
     Can be redefined in subclasses to enable it"
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   104
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   105
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   106
!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   107
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   108
allowScriptingOption
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   109
    "enable/disable the --scripting startup option.
11363
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   110
     The default is now false, so standAlone apps are closed by default.
de78c218cc36 comments
Claus Gittinger <cg@exept.de>
parents: 11361
diff changeset
   111
     Can be redefined in subclasses to enable it"
11361
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   112
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   113
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   114
!
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   115
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   116
suppressRCFileReading
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   117
    "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
   118
     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
   119
     Can be redefined in subclasses to disable it"
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   120
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   121
    ^ false
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   122
! !
36d809458749 defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents: 11360
diff changeset
   123
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
!StandaloneStartup class methodsFor:'helpers'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
11423
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   126
printInfo:msg
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   127
    Transcript 
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   128
        show:('%1 [info]: ' bindWith:(self applicationName));
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   129
        showCR:msg
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   130
!
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   131
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
redirectStandardStreams
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    Stdout := Stderr.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    Transcript := Stderr.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
verboseInfo:msg
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    Verbose == true ifFalse:[^ self].
11423
25a27bdeff4c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11379
diff changeset
   139
    self printInfo:msg
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "Modified: / 19-09-2006 / 16:30:27 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   144
!StandaloneStartup class methodsFor:'multiple applications support'!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   145
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   146
applicationRegistryPath
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   147
    "the key under which this application stores its process ID in the registry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   148
     as a collection of path-components.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   149
     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
   150
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   151
     (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
   152
     Used to detect if another instance of this application is already running."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   153
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   154
    self subclassResponsibility
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   155
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   156
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   157
applicationUUID
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   158
    "answer an application-specific unique uuid.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   159
     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
   160
     if another instance of this application is already running.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   161
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   162
    
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   163
    self subclassResponsibility
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   164
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   165
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   166
checkForAndExitIfAnotherApplicationInstanceIsRunning
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   167
    "if another instance of this application is running,
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   168
     send it an openFile command for my file-argument, and exit.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   169
     (i.e. to let the already running application open up another window)."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   170
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   171
    |shouldExit|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   172
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   173
    self isAnotherApplicationInstanceRunning ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   174
        shouldExit := self processStartupOfASecondInstance.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   175
        shouldExit ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   176
            self releaseApplicationMutex.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   177
            Smalltalk isStandAloneApp ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   178
                Smalltalk exit.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   179
            ]
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   180
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   181
    ].
12985
4ee69c6dacde changed: #checkForAndExitIfAnotherApplicationInstanceIsRunning
Claus Gittinger <cg@exept.de>
parents: 12935
diff changeset
   182
12988
6a502f44c515 changed: #checkForAndExitIfAnotherApplicationInstanceIsRunning
Claus Gittinger <cg@exept.de>
parents: 12985
diff changeset
   183
    "Modified: / 03-08-2010 / 17:27:25 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   184
! !
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   185
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   186
!StandaloneStartup class methodsFor:'multiple applications support-helpers'!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   187
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   188
applicationRegistryEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   189
    "retrieve the registry entry in which (if present), any currently running application
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   190
     has left its process ID"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   191
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   192
    |path relPathName applicationEntry softwareEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   193
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   194
    path := self applicationRegistryPath.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   195
    relPathName := path asStringWith:$\.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   196
    applicationEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\',relPathName.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   197
    applicationEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   198
        softwareEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   199
        softwareEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   200
            Transcript showCR: 'Failed to get Software entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   201
            ^ nil.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   202
        ].
11103
aae220bd7157 changed: #applicationRegistryEntry
fm
parents: 11102
diff changeset
   203
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   204
        path do:[:subKey |
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   205
            |subEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   206
11103
aae220bd7157 changed: #applicationRegistryEntry
fm
parents: 11102
diff changeset
   207
            subEntry := softwareEntry createSubKeyNamed:subKey.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   208
            subEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   209
                Transcript showCR: 'Failed to create ',subKey,' entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   210
                ^ nil.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   211
            ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   212
            softwareEntry := subEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   213
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   214
        applicationEntry := softwareEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   215
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   216
    ^ applicationEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   217
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   218
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   219
confirmOpenNewApplicationInstance
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   220
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   221
    ^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName)
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   222
                title: ('%1 is already open!!' bindWith:self applicationName)
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   223
             yesLabel: 'Continue' 
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   224
              noLabel: 'Exit'
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   225
!
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   226
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   227
currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   228
    ^ 'CurrentID'
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   229
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   230
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   231
getCurrentIDFromRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   232
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   233
    |applicationEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   234
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   235
    applicationEntry := self applicationRegistryEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   236
    applicationEntry isNil ifTrue:[^ nil.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   237
    ^ applicationEntry valueNamed: self currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   238
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   239
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   240
     |hWnd externalAddress|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   241
     hWnd := DapasXStartup getCurrentIDFromRegistry.   
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   242
     hWnd isEmptyOrNil ifTrue:[^ self halt.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   243
     hWnd := hWnd asInteger.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   244
     externalAddress := ExternalAddress newAddress: hWnd.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   245
     Display raiseWindow:externalAddress.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   246
     Display setForegroundWindow:externalAddress
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   247
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   248
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   249
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   250
getIDOfRunningApplicationFromRegistryEntry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   251
    |applicationEntry|
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   252
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   253
    applicationEntry := self applicationRegistryEntry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   254
    applicationEntry isNil ifTrue:[^ nil.].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   255
    ^ applicationEntry valueNamed: self currentIDKeyInRegistry
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   256
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   257
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   258
isAnotherApplicationInstanceRunning
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   259
    "answer true, if another instance of mzself is currently running.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   260
     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
   261
    
11106
740c42559ef7 changed: #isAnotherApplicationInstanceRunning
fm
parents: 11105
diff changeset
   262
    | lastErrorCode alreadyExists handleAndLastErrorCode |
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   263
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   264
    OperatingSystem isMSDOSlike ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   265
        handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString).
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   266
        MutexHandle := handleAndLastErrorCode first.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   267
        lastErrorCode := handleAndLastErrorCode second.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   268
        "/ self assert: lastErrorCode == 0.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   269
        alreadyExists := 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   270
            MutexHandle isNil 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   271
            or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   272
            or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   273
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   274
        alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   275
        ^ alreadyExists
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   276
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   277
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   278
    ^ false.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   279
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   280
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   281
processStartupOfASecondInstance
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   282
    "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
   283
     If I can get the currentID (i.e. windowID) of the first one and there is a command line argument with a file, 
12935
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   284
     send a message to the main window of the already running application, to ask it for another window.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   285
     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
   286
     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
   287
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   288
    |currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded|
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   289
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   290
    commands := Smalltalk commandLineArguments.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   291
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   292
    currentIDStringFromRegistry := self getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   293
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   294
    "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
   295
     we should wait in case of starting the first instance of the application 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   296
     with a multiple selection of files."
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   297
    (currentIDStringFromRegistry isEmptyOrNil and:[commands notEmptyOrNil]) ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   298
        Delay waitForSeconds: 2.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   299
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   300
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   301
    currentIDStringFromRegistry := self getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   302
    currentIDStringFromRegistry isEmptyOrNil ifTrue:[
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   303
        ^ self confirmOpenNewApplicationInstance not.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   304
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   305
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   306
    currentIDFromRegistry := Integer readFrom:currentIDStringFromRegistry onError: 0.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   307
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   308
    "/ bring the other application to the foreground
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   309
    aWindowId := ExternalAddress newAddress: currentIDFromRegistry.
11107
2c1b779bc57a *** empty log message ***
fm
parents: 11106
diff changeset
   310
    setForegroundWindowSucceeded := Display primSetForegroundWindow: aWindowId.
11379
2cd74df95a0e changed: #processStartupOfASecondInstance
fm
parents: 11363
diff changeset
   311
"/    setForegroundWindowSucceeded ifFalse:[^ self confirmOpenNewApplicationInstance not].
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   312
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   313
    "Autostart for associated extension"
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   314
    commands notEmpty ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   315
        fileArg := commands last asFilename.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   316
        fileArg exists ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   317
            self sendOpenPathCommand:(fileArg pathName) toWindowId: aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   318
        ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   319
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   320
    ^ true
12935
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   321
49210cf2d978 comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents: 12933
diff changeset
   322
    "Modified: / 08-07-2010 / 00:47:44 / cg"
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   323
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   324
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   325
releaseApplicationMutex
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   326
12933
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   327
    (MutexHandle notNil and:[OperatingSystem isMSDOSlike]) ifTrue:[
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   328
        OperatingSystem releaseMutex: MutexHandle.
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   329
        OperatingSystem primCloseHandle: MutexHandle.
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   330
4e196c41604d changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents: 12626
diff changeset
   331
        MutexHandle := nil.
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   332
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   333
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   334
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   335
sendCommand:message toWindowId:aWindowId
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   336
    "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
   337
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   338
    Display 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   339
        sendCopyDataString: message 
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   340
        toWindowId: aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   341
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   342
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   343
sendOpenPathCommand:pathName toWindowId:aWindowId
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   344
    "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
   345
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   346
    self sendCommand:('openPath:', pathName) toWindowId:aWindowId.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   347
!
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   348
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   349
writeCurrentIDIntoRegistry: currentID
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   350
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   351
    |applicationEntry currentIDEntry|
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   352
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   353
    applicationEntry := self applicationRegistryEntry.
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   354
    applicationEntry isNil ifTrue:[^ false.].
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   355
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   356
    currentIDEntry := applicationEntry createSubKeyNamed:(self currentIDKeyInRegistry).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   357
    currentIDEntry isNil ifTrue:[
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   358
        Transcript showCR: 'Failed to create CurrentID entry in registry'.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   359
        ^ false.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   360
    ].
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   361
11104
d1a963670d67 changed: #writeCurrentIDIntoRegistry:
fm
parents: 11103
diff changeset
   362
    ^ applicationEntry valueNamed:(self currentIDKeyInRegistry) put:(currentID printString).
11102
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   363
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   364
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   365
     | currentID returnedCurrentID |
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   366
     currentID := 999.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   367
     DapasXStartup writeCurrentIDIntoRegistry: currentID.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   368
     returnedCurrentID := DapasXStartup getCurrentIDFromRegistry.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   369
     self assert: currentID = returnedCurrentID asNumber.
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   370
    "
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   371
! !
fece26c79af5 refactored
Claus Gittinger <cg@exept.de>
parents: 11056
diff changeset
   372
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
!StandaloneStartup class methodsFor:'queries'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
applicationName
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   376
    "used in verbose messages - can/should be redefined in subclasses"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    |nm|
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    nm := self nameWithoutPrefix.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    (nm endsWith:'Startup') ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
        ^ nm copyWithoutLast:('Startup' size).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    (nm endsWith:'Start') ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
        ^ nm copyWithoutLast:('Start' size).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    ^ nm
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
    "Created: / 19-09-2006 / 16:26:44 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
12523
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   392
iconInBrowserSymbol
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   393
    <resource: #programImage>
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   394
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   395
    self == StandaloneStartup ifFalse:[
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   396
        ^ #standaloneStartupIcon 
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   397
    ].
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   398
    ^ super iconInBrowserSymbol
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   399
!
df8cb7ffe5eb added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12335
diff changeset
   400
10040
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   401
isBrowserStartable
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   402
    "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
   403
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   404
    ^ false
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   405
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   406
    "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
   407
!
59d0c20b139f protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents: 9944
diff changeset
   408
12626
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   409
keepSplashWindowOpen
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   410
    "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
   411
     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
   412
     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
   413
     (calling hideSplashWindow)
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   414
     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
   415
     subclasses main: is invoked."
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   416
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   417
    ^ false
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   418
!
f85aaddaea1d added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents: 12523
diff changeset
   419
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
startupFilename
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   421
    "used in verbose messages - can/should be redefined in subclasses"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    ^ self applicationName asLowercase,'Start.rc'
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
    "
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   426
     ExpeccoStartup startupFilename -> 'expecco.rc'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    "
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
    "Created: / 19-09-2006 / 16:38:28 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
!StandaloneStartup class methodsFor:'startup'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
11055
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   434
loadPatch:fileName
11056
e2c4a6e948b6 loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 11055
diff changeset
   435
    self verboseInfo:('loading patch: ',fileName baseName).
11055
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   436
    Smalltalk fileIn:fileName pathName.
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   437
!
e600e19e2e7f loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents: 10956
diff changeset
   438
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
loadPatches
11764
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   440
    |patchesDir prevMode|
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
10934
970557a121e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10886
diff changeset
   442
    patchesDir := OperatingSystem pathOfSTXExecutable asFilename directory construct:'patches'.
970557a121e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10886
diff changeset
   443
    (patchesDir exists and:[patchesDir isDirectory]) ifTrue:[
11764
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   444
        prevMode := ClassCategoryReader sourceMode.
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   445
        ClassCategoryReader sourceMode:#discard.
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   446
        [
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   447
            patchesDir directoryContents sort do:[:eachFilenameString |
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   448
                self loadPatch:(patchesDir construct:eachFilenameString).
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   449
            ].
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   450
        ] ensure:[
89c0c60feb24 Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents: 11753
diff changeset
   451
            ClassCategoryReader sourceMode:prevMode.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    "Modified: / 19-09-2006 / 16:30:58 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
setupSmalltalkFromArguments:argv
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   459
    "handle common command line arguments:
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   460
        --help ............... print usage and exit
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   461
        --verbose (-V) ....... be verbose during startup
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   462
        --debug .............. enable debugger & inspector
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   463
        --rcFileName ......... define a startup rc-file
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   464
        --scripting portNr ... start a scripting server
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   465
        --allowHost host ..... add host to the allowed scripting hosts
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   466
    "
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   467
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   468
    |idx rcFilename nextArg debugging scripting allowedScriptingHosts portNr|
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
"/    Smalltalk beHeadless:true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
"/    OperatingSystem disableSignal:(OperatingSystem sigHUP).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
"/    Smalltalk infoPrinting:true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
    (argv includes:'--help') ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
        self usage.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
        AbortOperationRequest raise.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
    idx := argv indexOfAny:#('--verbose' '-V').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    idx ~~ 0 ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
        argv removeAtIndex:idx.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
        Verbose := true.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
    ].
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
   484
    self verboseInfo:('args: ',argv asArray printString).
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   486
    debugging := false.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   487
    (self allowDebugOption) ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   488
        idx := argv indexOfAny:#('--debug').
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   489
        idx ~~ 0 ifTrue:[
11357
0a710cf52bb4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11356
diff changeset
   490
            self verboseInfo:('debug on').
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   491
            argv removeAtIndex:idx.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   492
            debugging := true
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   493
        ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   494
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   495
    debugging ifTrue:[
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
        self setupToolsForDebug.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
    ] ifFalse:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
        self setupToolsForNoDebug.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   501
    self suppressRCFileReading ifFalse:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   502
        idx := argv indexOf:'--rcFileName'.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   503
        idx ~~ 0 ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   504
            nextArg := argv at:(idx + 1) ifAbsent:nil.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   505
            (nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   506
                rcFilename := nextArg.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   507
                argv removeAtIndex:idx+1; removeAtIndex:idx.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   508
            ]
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   509
        ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   510
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   511
        rcFilename isNil ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   512
            rcFilename := self startupFilename.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   513
        ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   514
        rcFilename asFilename exists ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   515
            self verboseInfo:('reading ',rcFilename,'...').
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   516
            rcFilename isAbsolute ifFalse:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   517
                rcFilename := OperatingSystem pathOfSTXExecutable asFilename directory constructString:rcFilename.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   518
            ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   519
            Smalltalk secureFileIn:rcFilename
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   520
        ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   523
    scripting := false.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   524
    (self allowScriptingOption) ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   525
        idx := argv indexOfAny:#('--scripting').
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   526
        idx ~~ 0 ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   527
            nextArg := argv at:(idx + 1) ifAbsent:nil.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   528
            (nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   529
                portNr := nextArg asInteger.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   530
                argv removeAtIndex:idx+1.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   531
            ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   532
            argv removeAtIndex:idx.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   533
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   534
            scripting := true
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   535
        ].
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   536
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   537
        allowedScriptingHosts := OrderedCollection new.
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   538
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   539
        idx := argv indexOfAny:#('--allowHost').
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   540
        [idx ~~ 0] whileTrue:[
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   541
            nextArg := argv at:(idx + 1) ifAbsent:nil.
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   542
            nextArg isNil ifTrue:[
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   543
                self usage.
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   544
                AbortOperationRequest raise.
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   545
            ].
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   546
            allowedScriptingHosts add:nextArg.
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   547
            idx := argv indexOfAny:#('--allowHost').
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   548
        ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
    ].
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   550
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   551
    scripting ifTrue:[
11358
c1f741e4aa34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11357
diff changeset
   552
        self verboseInfo:('scripting on').
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   553
        STXScriptingServer notNil ifTrue:[
11435
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   554
            allowedScriptingHosts do:[:eachHost | STXScriptingServer allowHost:eachHost ].
4b7e47a525df --allowHost option
Claus Gittinger <cg@exept.de>
parents: 11423
diff changeset
   555
11353
6167f1e604c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11352
diff changeset
   556
            "/ scripting on port/stdin_out/8008
6167f1e604c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11352
diff changeset
   557
            self verboseInfo:('start scripting').
6167f1e604c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11352
diff changeset
   558
            STXScriptingServer startAt:portNr
11359
587f2a2aef0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11358
diff changeset
   559
        ] ifFalse:[
587f2a2aef0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11358
diff changeset
   560
            self verboseInfo:('missing STXScriptingServer class').
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    ].
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   563
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    ^ true
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
   566
    "Modified: / 31-10-2007 / 16:05:59 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   569
setupToolsForDebug
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   570
    Debugger := DebugView ? MiniDebugger.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   571
    Inspector := InspectorView ? MiniInspector.
11736
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
   572
    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
   573
"/    self verboseInfo:('debug enabled - CTRL-C brings you into a debugger.').
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
    "Created: / 19-09-2006 / 16:40:32 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   578
setupToolsForNoDebug
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   579
    Smalltalk isStandAloneApp ifTrue:[
11600
1d98211fc0b0 also nil private classes of NewLauncher
Claus Gittinger <cg@exept.de>
parents: 11435
diff changeset
   580
        Smalltalk at:#Debugger put:nil.
1d98211fc0b0 also nil private classes of NewLauncher
Claus Gittinger <cg@exept.de>
parents: 11435
diff changeset
   581
        Smalltalk at:#Inspector put:nil.
11714
a2210199707b Fix if no NewLauncher is present
Stefan Vogel <sv@exept.de>
parents: 11610
diff changeset
   582
        NewLauncher notNil ifTrue:[
a2210199707b Fix if no NewLauncher is present
Stefan Vogel <sv@exept.de>
parents: 11610
diff changeset
   583
            NewLauncher allPrivateClasses do:[:cls |
a2210199707b Fix if no NewLauncher is present
Stefan Vogel <sv@exept.de>
parents: 11610
diff changeset
   584
                Smalltalk at:(cls name) put:nil.
a2210199707b Fix if no NewLauncher is present
Stefan Vogel <sv@exept.de>
parents: 11610
diff changeset
   585
            ].
a2210199707b Fix if no NewLauncher is present
Stefan Vogel <sv@exept.de>
parents: 11610
diff changeset
   586
            Smalltalk at:#NewLauncher put:nil.
11600
1d98211fc0b0 also nil private classes of NewLauncher
Claus Gittinger <cg@exept.de>
parents: 11435
diff changeset
   587
        ].
11736
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
   588
        Verbose ifTrue:[ 'debug disabled.' errorPrintCR ].
095ef06bd971 show debug enabled/disabled info when Verbose is true
fm
parents: 11714
diff changeset
   589
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   590
        self redirectStandardStreams.
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
   591
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
    "Created: / 19-09-2006 / 16:40:47 / cg"
10773
98a51414b27f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10772
diff changeset
   594
    "Modified: / 31-10-2007 / 16:18:40 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   597
start
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   598
    GenericException handle:[:ex |
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   599
        self verboseInfo:('Error during startup:').
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   600
        self verboseInfo:(ex description).
12996
8662430ec3de changed: #start
Stefan Vogel <sv@exept.de>
parents: 12992
diff changeset
   601
        Verbose == true ifTrue:[ex suspendedContext fullPrintAllLevels:10].
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   602
        ex reject.        
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   603
    ] do:[
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   604
        CommandLineArguments := (self additionalArgumentsFromRegistry) 
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   605
                                , Smalltalk commandLineArguments.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   607
        self verboseInfo:('starting...').
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   608
        self verboseInfo:('args: ', CommandLineArguments asStringCollection asString).
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   609
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   610
        Smalltalk isStandAloneApp ifTrue:[
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   611
            self loadPatches.
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   612
            self verboseInfo:('setup Smalltalk').
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   613
        ].
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   614
        self setupSmalltalkFromArguments:CommandLineArguments.
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   615
        self main
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
12992
cad1bd395046 changed: #start
Claus Gittinger <cg@exept.de>
parents: 12991
diff changeset
   618
    "Modified: / 04-08-2010 / 12:30:05 / cg"
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
11807
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
   621
startStartBlockProcess
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
   622
    Smalltalk startStartBlockProcess
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
   623
!
f9e3c45c53c8 Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents: 11806
diff changeset
   624
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   625
usage
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   626
    Stderr nextPutLine:'usage:'.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   627
    Stderr nextPutLine:'  ',self applicationName,' [options...]'.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   628
    Stderr nextPutLine:'    options:'.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   629
    Stderr nextPutLine:'          --help .................. output this message'.
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    Stderr nextPutLine:'          --verbose ............... verbose startup'.
11610
Claus Gittinger <cg@exept.de>
parents: 11600
diff changeset
   631
    Stderr nextPutLine:'          --noBanner .............. no splash screen'.
11352
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   632
    self allowScriptingOption ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   633
        Stderr nextPutLine:'          --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   634
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   635
    self allowDebugOption ifTrue:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   636
        Stderr nextPutLine:'          --debug ................. enable Debugger'.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   637
    ].
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   638
    self suppressRCFileReading ifFalse:[
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   639
        Stderr nextPutLine:'          --rcFileName file ....... execute code from file on startup (default: ',self startupFilename,')'.
023a07ae955c --scripting option
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   640
    ].
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    "Created: / 19-09-2006 / 16:37:55 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
!StandaloneStartup class methodsFor:'startup-to be redefined'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
12991
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   647
additionalArgumentsFromRegistry
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   648
    "can be redefined to fetch and return additional arguments from the registry 
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   649
     (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
   650
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   651
    ^ #()
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   652
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   653
    "Created: / 04-08-2010 / 12:20:27 / cg"
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   654
!
f9c0f556ea86 added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents: 12988
diff changeset
   655
11806
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
   656
isHeadless
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
   657
    "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
   658
     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
   659
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
   660
     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
   661
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
   662
    ^ false
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
   663
!
6508528f9499 Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents: 11764
diff changeset
   664
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   665
main
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   666
    self verboseInfo:('entering main').
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   667
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   668
    self main:CommandLineArguments.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   669
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   670
    "
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   671
     self main
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   672
     self main:#('--info') 
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   673
    "
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   674
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   675
    "Modified: / 31-10-2007 / 16:03:22 / cg"
10636
ba91c2d292f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10040
diff changeset
   676
!
ba91c2d292f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10040
diff changeset
   677
11355
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   678
main:argv
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   679
    self subclassResponsibility.
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   680
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   681
"/ a typical main: looks like (in a subclass):
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   682
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   683
"/    |app fileArg|
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   684
"/
2aa83c61ebd4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11354
diff changeset
   685
"/    self verboseInfo:('starting application').
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
"/    app := <someGUIApplicationModelClass> open.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
"/    self verboseInfo:('looking for args in ',argv).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
"/    argv notEmptyOrNil ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
"/        fileArg := argv last asFilename.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
"/        self verboseInfo:('fileArg is ',fileArg name).
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
"/        fileArg exists ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
"/            self verboseInfo:('file exists').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
"/            ( #('foo' 'bar' 'baz' ) includes:fileArg suffix) ifTrue:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
"/                self verboseInfo:('loading').
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
"/
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
"/                Error handle:[:ex |
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
"/                    self verboseInfo:'error while loading'.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
"/                    ex suspendedContext fullPrintAll.
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
"/                ] do:[
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
"/                    app menuLoadFromFile:fileArg
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
"/                ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
"/            ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
"/        ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
"/    ].
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
    "Created: / 19-09-2006 / 16:48:29 / cg"
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
!StandaloneStartup class methodsFor:'documentation'!
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
version
12996
8662430ec3de changed: #start
Stefan Vogel <sv@exept.de>
parents: 12992
diff changeset
   714
    ^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.48 2010-08-05 13:16:45 stefan Exp $'
12335
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
   715
!
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
   716
af9a7bc14d6a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 11807
diff changeset
   717
version_CVS
12996
8662430ec3de changed: #start
Stefan Vogel <sv@exept.de>
parents: 12992
diff changeset
   718
    ^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.48 2010-08-05 13:16:45 stefan Exp $'
9944
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
! !
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
aa3d787443ef initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
StandaloneStartup initialize!