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