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