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