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