author | fm |
Tue, 05 Aug 2008 09:55:12 +0200 | |
changeset 11106 | 740c42559ef7 |
parent 11105 | 4deedf531f75 |
child 11107 | 2c1b779bc57a |
permissions | -rw-r--r-- |
9944 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic' }" |
|
13 |
||
14 |
Object subclass:#StandaloneStartup |
|
15 |
instanceVariableNames:'' |
|
10772 | 16 |
classVariableNames:'Verbose CommandLineArguments' |
9944 | 17 |
poolDictionaries:'' |
18 |
category:'System-Support' |
|
19 |
! |
|
20 |
||
11102 | 21 |
StandaloneStartup class instanceVariableNames:'MutexHandle' |
22 |
||
23 |
" |
|
24 |
No other class instance variables are inherited by this class. |
|
25 |
" |
|
26 |
! |
|
27 |
||
9944 | 28 |
!StandaloneStartup class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
a subclassable template class for a standalone GUI-application's startup; |
|
47 |
For your own stand alone programs, define a subclass of this, |
|
48 |
and redefine the #main method there. |
|
49 |
(of course, the other methods can also be redefined.) |
|
50 |
||
51 |
[author:] |
|
52 |
Claus Gittinger |
|
53 |
||
54 |
[start with:] |
|
55 |
<yourNamehere>Startup start |
|
10886 | 56 |
|
57 |
[see also:] |
|
58 |
Smalltalk |
|
59 |
GetOpt |
|
60 |
ReadEvalPrintLoop |
|
9944 | 61 |
" |
11102 | 62 |
! |
63 |
||
64 |
howToDealWithMultipleApplicationInstances |
|
65 |
" |
|
66 |
please read the comment in the corresponding ApplicationModel class-documentation method. |
|
67 |
" |
|
9944 | 68 |
! ! |
69 |
||
70 |
!StandaloneStartup class methodsFor:'initialization'! |
|
71 |
||
72 |
initialize |
|
73 |
"/ Verbose := true. |
|
74 |
Verbose := false. |
|
75 |
! ! |
|
76 |
||
77 |
!StandaloneStartup class methodsFor:'helpers'! |
|
78 |
||
79 |
redirectStandardStreams |
|
80 |
Stdout := Stderr. |
|
81 |
Transcript := Stderr. |
|
82 |
! |
|
83 |
||
84 |
verboseInfo:msg |
|
85 |
Verbose == true ifFalse:[^ self]. |
|
86 |
||
87 |
Transcript |
|
88 |
show:('%1 [info]: ' bindWith:(self applicationName)); |
|
89 |
showCR:msg |
|
90 |
||
91 |
"Modified: / 19-09-2006 / 16:30:27 / cg" |
|
92 |
! ! |
|
93 |
||
11102 | 94 |
!StandaloneStartup class methodsFor:'multiple applications support'! |
95 |
||
96 |
applicationRegistryPath |
|
97 |
"the key under which this application stores its process ID in the registry |
|
98 |
as a collection of path-components. |
|
99 |
i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored |
|
100 |
in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID. |
|
101 |
(would also be used as a relative path for a temporary lock file under unix). |
|
102 |
Used to detect if another instance of this application is already running." |
|
103 |
||
104 |
self subclassResponsibility |
|
105 |
! |
|
106 |
||
107 |
applicationUUID |
|
108 |
"answer an application-specific unique uuid. |
|
109 |
This is used as the name of some exclusive OS-resource, which is used to find out, |
|
110 |
if another instance of this application is already running. |
|
111 |
Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used." |
|
112 |
||
113 |
self subclassResponsibility |
|
114 |
! |
|
115 |
||
116 |
checkForAndExitIfAnotherApplicationInstanceIsRunning |
|
117 |
"if another instance of this application is running, |
|
118 |
send it an openFile command for my file-argument, and exit. |
|
119 |
(i.e. to let the already running application open up another window)." |
|
120 |
||
121 |
|shouldExit| |
|
122 |
||
123 |
self isAnotherApplicationInstanceRunning ifTrue:[ |
|
124 |
shouldExit := self processStartupOfASecondInstance. |
|
125 |
shouldExit ifTrue:[ |
|
126 |
self releaseApplicationMutex. |
|
127 |
Smalltalk isStandAloneApp ifTrue:[ |
|
128 |
Smalltalk exit. |
|
129 |
] |
|
130 |
]. |
|
131 |
]. |
|
132 |
! ! |
|
133 |
||
134 |
!StandaloneStartup class methodsFor:'multiple applications support-helpers'! |
|
135 |
||
136 |
applicationRegistryEntry |
|
137 |
"retrieve the registry entry in which (if present), any currently running application |
|
138 |
has left its process ID" |
|
139 |
||
140 |
|path relPathName applicationEntry softwareEntry| |
|
141 |
||
142 |
path := self applicationRegistryPath. |
|
143 |
relPathName := path asStringWith:$\. |
|
144 |
applicationEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\',relPathName. |
|
145 |
applicationEntry isNil ifTrue:[ |
|
146 |
softwareEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software'. |
|
147 |
softwareEntry isNil ifTrue:[ |
|
148 |
Transcript showCR: 'Failed to get Software entry in registry'. |
|
149 |
^ nil. |
|
150 |
]. |
|
11103 | 151 |
|
11102 | 152 |
path do:[:subKey | |
153 |
|subEntry| |
|
154 |
||
11103 | 155 |
subEntry := softwareEntry createSubKeyNamed:subKey. |
11102 | 156 |
subEntry isNil ifTrue:[ |
157 |
Transcript showCR: 'Failed to create ',subKey,' entry in registry'. |
|
158 |
^ nil. |
|
159 |
]. |
|
160 |
softwareEntry := subEntry. |
|
161 |
]. |
|
162 |
applicationEntry := softwareEntry. |
|
163 |
]. |
|
164 |
^ applicationEntry |
|
165 |
! |
|
166 |
||
167 |
currentIDKeyInRegistry |
|
168 |
^ 'CurrentID' |
|
169 |
! |
|
170 |
||
171 |
getCurrentIDFromRegistry |
|
172 |
||
173 |
|applicationEntry| |
|
174 |
||
175 |
applicationEntry := self applicationRegistryEntry. |
|
176 |
applicationEntry isNil ifTrue:[^ nil.]. |
|
177 |
^ applicationEntry valueNamed: self currentIDKeyInRegistry |
|
178 |
||
179 |
" |
|
180 |
|hWnd externalAddress| |
|
181 |
hWnd := DapasXStartup getCurrentIDFromRegistry. |
|
182 |
hWnd isEmptyOrNil ifTrue:[^ self halt.]. |
|
183 |
hWnd := hWnd asInteger. |
|
184 |
externalAddress := ExternalAddress newAddress: hWnd. |
|
185 |
Display raiseWindow:externalAddress. |
|
186 |
Display setForegroundWindow:externalAddress |
|
187 |
" |
|
188 |
! |
|
189 |
||
190 |
getIDOfRunningApplicationFromRegistryEntry |
|
191 |
|applicationEntry| |
|
192 |
||
193 |
applicationEntry := self applicationRegistryEntry. |
|
194 |
applicationEntry isNil ifTrue:[^ nil.]. |
|
195 |
^ applicationEntry valueNamed: self currentIDKeyInRegistry |
|
196 |
! |
|
197 |
||
198 |
isAnotherApplicationInstanceRunning |
|
199 |
"answer true, if another instance of mzself is currently running. |
|
200 |
For now, it only works under win32, because it uses the underlying mutex mechanism." |
|
201 |
||
11106 | 202 |
| lastErrorCode alreadyExists handleAndLastErrorCode | |
11102 | 203 |
|
204 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
205 |
handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString). |
|
206 |
MutexHandle := handleAndLastErrorCode first. |
|
207 |
lastErrorCode := handleAndLastErrorCode second. |
|
208 |
"/ self assert: lastErrorCode == 0. |
|
209 |
alreadyExists := |
|
210 |
MutexHandle isNil |
|
211 |
or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
|
212 |
or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]. |
|
213 |
||
214 |
alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle]. |
|
215 |
^ alreadyExists |
|
216 |
]. |
|
217 |
||
218 |
^ false. |
|
219 |
! |
|
220 |
||
221 |
processStartupOfASecondInstance |
|
222 |
"This is executed when I have been started as a second instance of an already running application. |
|
223 |
If I can get the currentID (i.e. windowID) of the first one and there is a command line argument with a file, |
|
224 |
send a message to the main window of the already running application, o ask it for another window. |
|
225 |
If the currentID is unknown, ask if the user wants to open a new instance of the application anyway. |
|
226 |
Return true if the first instance has been notified, and this second instance should exit." |
|
227 |
||
228 |
|currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId| |
|
229 |
||
230 |
commands := Smalltalk commandLineArguments. |
|
231 |
||
232 |
currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
|
233 |
||
234 |
"If the currentID is not found and there are arguments from the command line, |
|
235 |
we should wait in case of starting the first instance of the application |
|
236 |
with a multiple selection of files." |
|
237 |
(currentIDStringFromRegistry isEmptyOrNil and:[commands notEmptyOrNil]) ifTrue:[ |
|
238 |
Delay waitForSeconds: 2. |
|
239 |
]. |
|
240 |
||
241 |
currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
|
242 |
currentIDStringFromRegistry isEmptyOrNil ifTrue:[ |
|
243 |
^ (Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName) |
|
244 |
title: ('%1 is already open!!' bindWith:self applicationName) |
|
245 |
yesLabel: 'Continue' |
|
246 |
noLabel: 'Exit') not. |
|
247 |
]. |
|
248 |
||
249 |
currentIDFromRegistry := Integer readFrom:currentIDStringFromRegistry. |
|
250 |
||
251 |
"/ bring the other application to the foreground |
|
252 |
aWindowId := ExternalAddress newAddress: currentIDFromRegistry. |
|
253 |
Display setForegroundWindow: aWindowId. |
|
254 |
||
255 |
"Autostart for associated extension" |
|
256 |
commands notEmpty ifTrue:[ |
|
257 |
fileArg := commands last asFilename. |
|
258 |
fileArg exists ifTrue:[ |
|
259 |
self sendOpenPathCommand:(fileArg pathName) toWindowId: aWindowId. |
|
260 |
]. |
|
261 |
]. |
|
262 |
^ true |
|
263 |
! |
|
264 |
||
265 |
releaseApplicationMutex |
|
266 |
||
267 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
268 |
MutexHandle notNil ifTrue:[ |
|
269 |
OperatingSystem releaseMutex: MutexHandle. |
|
270 |
OperatingSystem primCloseHandle: MutexHandle. |
|
271 |
]. |
|
272 |
]. |
|
273 |
! |
|
274 |
||
275 |
sendCommand:message toWindowId:aWindowId |
|
276 |
"use the event send mechanism to forward a command to the already running application" |
|
277 |
||
278 |
Display |
|
279 |
sendCopyDataString: message |
|
280 |
toWindowId: aWindowId. |
|
281 |
! |
|
282 |
||
283 |
sendOpenPathCommand:pathName toWindowId:aWindowId |
|
284 |
"use the event send mechanism to forward an open-Path command to the already running application" |
|
285 |
||
286 |
self sendCommand:('openPath:', pathName) toWindowId:aWindowId. |
|
287 |
! |
|
288 |
||
289 |
writeCurrentIDIntoRegistry: currentID |
|
290 |
||
11104 | 291 |
|applicationEntry currentIDEntry| |
11102 | 292 |
|
11104 | 293 |
applicationEntry := self applicationRegistryEntry. |
294 |
applicationEntry isNil ifTrue:[^ false.]. |
|
11102 | 295 |
|
11104 | 296 |
currentIDEntry := applicationEntry createSubKeyNamed:(self currentIDKeyInRegistry). |
11102 | 297 |
currentIDEntry isNil ifTrue:[ |
298 |
Transcript showCR: 'Failed to create CurrentID entry in registry'. |
|
299 |
^ false. |
|
300 |
]. |
|
301 |
||
11104 | 302 |
^ applicationEntry valueNamed:(self currentIDKeyInRegistry) put:(currentID printString). |
11102 | 303 |
|
304 |
" |
|
305 |
| currentID returnedCurrentID | |
|
306 |
currentID := 999. |
|
307 |
DapasXStartup writeCurrentIDIntoRegistry: currentID. |
|
308 |
returnedCurrentID := DapasXStartup getCurrentIDFromRegistry. |
|
309 |
self assert: currentID = returnedCurrentID asNumber. |
|
310 |
" |
|
311 |
! ! |
|
312 |
||
9944 | 313 |
!StandaloneStartup class methodsFor:'queries'! |
314 |
||
315 |
applicationName |
|
316 |
"used in verbose messages - can be redefined in subclasses" |
|
317 |
||
318 |
|nm| |
|
319 |
||
320 |
nm := self nameWithoutPrefix. |
|
321 |
(nm endsWith:'Startup') ifTrue:[ |
|
322 |
^ nm copyWithoutLast:('Startup' size). |
|
323 |
]. |
|
324 |
(nm endsWith:'Start') ifTrue:[ |
|
325 |
^ nm copyWithoutLast:('Start' size). |
|
326 |
]. |
|
327 |
^ nm |
|
328 |
||
329 |
"Created: / 19-09-2006 / 16:26:44 / cg" |
|
330 |
! |
|
331 |
||
10040
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
332 |
isBrowserStartable |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
333 |
"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
|
334 |
|
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
335 |
^ false |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
336 |
|
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
337 |
"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
|
338 |
! |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
339 |
|
9944 | 340 |
startupFilename |
341 |
"used in verbose messages - can be redefined in subclasses" |
|
342 |
||
343 |
^ self applicationName asLowercase,'Start.rc' |
|
344 |
||
345 |
" |
|
346 |
ExpeccoStartup startupFilename |
|
347 |
" |
|
348 |
||
349 |
"Created: / 19-09-2006 / 16:38:28 / cg" |
|
350 |
! ! |
|
351 |
||
352 |
!StandaloneStartup class methodsFor:'startup'! |
|
353 |
||
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
354 |
loadPatch:fileName |
11056
e2c4a6e948b6
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
11055
diff
changeset
|
355 |
self verboseInfo:('loading patch: ',fileName baseName). |
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
356 |
Smalltalk fileIn:fileName pathName. |
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
357 |
! |
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
358 |
|
9944 | 359 |
loadPatches |
10934 | 360 |
|patchesDir| |
9944 | 361 |
|
10934 | 362 |
patchesDir := OperatingSystem pathOfSTXExecutable asFilename directory construct:'patches'. |
363 |
(patchesDir exists and:[patchesDir isDirectory]) ifTrue:[ |
|
364 |
patchesDir directoryContents sort do:[:eachFile | |
|
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
365 |
self loadPatch:(patchesDir construct:eachFile). |
9944 | 366 |
]. |
367 |
]. |
|
368 |
||
369 |
"Modified: / 19-09-2006 / 16:30:58 / cg" |
|
370 |
! |
|
371 |
||
372 |
setupSmalltalkFromArguments:argv |
|
373 |
|idx rcFilename nextArg| |
|
374 |
||
375 |
"/ Smalltalk beHeadless:true. |
|
376 |
"/ OperatingSystem disableSignal:(OperatingSystem sigHUP). |
|
377 |
"/ Smalltalk infoPrinting:true. |
|
378 |
||
379 |
(argv includes:'--help') ifTrue:[ |
|
380 |
self usage. |
|
381 |
AbortOperationRequest raise. |
|
382 |
]. |
|
383 |
||
384 |
idx := argv indexOfAny:#('--verbose' '-V'). |
|
385 |
idx ~~ 0 ifTrue:[ |
|
386 |
argv removeAtIndex:idx. |
|
387 |
Verbose := true. |
|
388 |
]. |
|
10773 | 389 |
self verboseInfo:('args: ',argv asArray printString). |
9944 | 390 |
|
391 |
idx := argv indexOfAny:#('--debug'). |
|
392 |
idx ~~ 0 ifTrue:[ |
|
393 |
argv removeAtIndex:idx. |
|
394 |
self setupToolsForDebug. |
|
395 |
] ifFalse:[ |
|
396 |
self setupToolsForNoDebug. |
|
397 |
]. |
|
398 |
||
399 |
idx := argv indexOf:'--rcFileName'. |
|
400 |
idx ~~ 0 ifTrue:[ |
|
401 |
nextArg := argv at:(idx + 1) ifAbsent:nil. |
|
402 |
(nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[ |
|
403 |
rcFilename := nextArg. |
|
404 |
argv removeAtIndex:idx+1; removeAtIndex:idx. |
|
405 |
] |
|
406 |
]. |
|
407 |
||
408 |
rcFilename isNil ifTrue:[ |
|
409 |
rcFilename := self startupFilename. |
|
410 |
]. |
|
411 |
rcFilename asFilename exists ifTrue:[ |
|
412 |
self verboseInfo:('reading ',rcFilename,'...'). |
|
413 |
rcFilename isAbsolute ifFalse:[ |
|
414 |
rcFilename := OperatingSystem pathOfSTXExecutable asFilename directory constructString:rcFilename. |
|
415 |
]. |
|
416 |
Smalltalk secureFileIn:rcFilename |
|
417 |
]. |
|
418 |
^ true |
|
419 |
||
10773 | 420 |
"Modified: / 31-10-2007 / 16:05:59 / cg" |
9944 | 421 |
! |
422 |
||
423 |
setupToolsForDebug |
|
424 |
Debugger := DebugView ? MiniDebugger. |
|
425 |
Inspector := InspectorView ? MiniInspector. |
|
426 |
self verboseInfo:('debug enabled - CTRL-C brings you into a debugger.'). |
|
427 |
||
428 |
"Created: / 19-09-2006 / 16:40:32 / cg" |
|
429 |
! |
|
430 |
||
431 |
setupToolsForNoDebug |
|
10773 | 432 |
Smalltalk isStandAloneApp ifTrue:[ |
433 |
Debugger := nil. |
|
434 |
Inspector := nil. |
|
435 |
NewLauncher := nil. |
|
436 |
self redirectStandardStreams. |
|
437 |
]. |
|
9944 | 438 |
|
439 |
"Created: / 19-09-2006 / 16:40:47 / cg" |
|
10773 | 440 |
"Modified: / 31-10-2007 / 16:18:40 / cg" |
9944 | 441 |
! |
442 |
||
443 |
start |
|
10772 | 444 |
CommandLineArguments := Smalltalk commandLineArguments. |
445 |
||
9944 | 446 |
self verboseInfo:('starting...'). |
10956 | 447 |
self verboseInfo:('args: ', CommandLineArguments asStringCollection asString). |
9944 | 448 |
|
449 |
Smalltalk isStandAloneApp ifTrue:[ |
|
450 |
self loadPatches. |
|
451 |
self verboseInfo:('setup Smalltalk'). |
|
452 |
]. |
|
10772 | 453 |
self setupSmalltalkFromArguments:CommandLineArguments. |
9944 | 454 |
self main |
455 |
||
10772 | 456 |
"Modified: / 31-10-2007 / 16:03:44 / cg" |
9944 | 457 |
! |
458 |
||
459 |
usage |
|
460 |
Stderr nextPutLine:'usage:'. |
|
461 |
Stderr nextPutLine:' ',self applicationName,' [options...]'. |
|
462 |
Stderr nextPutLine:' options:'. |
|
463 |
Stderr nextPutLine:' --help .................. output this message'. |
|
464 |
Stderr nextPutLine:' --verbose ............... verbose startup'. |
|
465 |
Stderr nextPutLine:' --debug ................. enable Debugger'. |
|
466 |
Stderr nextPutLine:' --rcFileName file ....... execute code from file on startup (default: ',self startupFilename,')'. |
|
467 |
||
468 |
"Created: / 19-09-2006 / 16:37:55 / cg" |
|
469 |
! ! |
|
470 |
||
471 |
!StandaloneStartup class methodsFor:'startup-to be redefined'! |
|
472 |
||
473 |
main |
|
474 |
self verboseInfo:('entering main'). |
|
475 |
||
10772 | 476 |
self main:CommandLineArguments. |
10636 | 477 |
|
478 |
" |
|
479 |
self main |
|
480 |
self main:#('--info') |
|
481 |
" |
|
482 |
||
10772 | 483 |
"Modified: / 31-10-2007 / 16:03:22 / cg" |
10636 | 484 |
! |
485 |
||
486 |
main:argv |
|
9944 | 487 |
self subclassResponsibility. |
488 |
||
10636 | 489 |
"/ a typical main: looks like (in a subclass): |
9944 | 490 |
|
10636 | 491 |
"/ |app fileArg| |
492 |
"/ |
|
9944 | 493 |
"/ self verboseInfo:('starting application'). |
494 |
"/ app := <someGUIApplicationModelClass> open. |
|
495 |
"/ |
|
496 |
"/ self verboseInfo:('looking for args in ',argv). |
|
497 |
"/ argv notEmptyOrNil ifTrue:[ |
|
498 |
"/ fileArg := argv last asFilename. |
|
499 |
"/ self verboseInfo:('fileArg is ',fileArg name). |
|
500 |
"/ fileArg exists ifTrue:[ |
|
501 |
"/ self verboseInfo:('file exists'). |
|
502 |
"/ |
|
503 |
"/ ( #('foo' 'bar' 'baz' ) includes:fileArg suffix) ifTrue:[ |
|
504 |
"/ self verboseInfo:('loading'). |
|
505 |
"/ |
|
506 |
"/ Error handle:[:ex | |
|
507 |
"/ self verboseInfo:'error while loading'. |
|
508 |
"/ ex suspendedContext fullPrintAll. |
|
509 |
"/ ] do:[ |
|
510 |
"/ app menuLoadFromFile:fileArg |
|
511 |
"/ ]. |
|
512 |
"/ ]. |
|
513 |
"/ ]. |
|
514 |
"/ ]. |
|
515 |
||
516 |
"Created: / 19-09-2006 / 16:48:29 / cg" |
|
517 |
! ! |
|
518 |
||
519 |
!StandaloneStartup class methodsFor:'documentation'! |
|
520 |
||
521 |
version |
|
11106 | 522 |
^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.15 2008-08-05 07:55:12 fm Exp $' |
9944 | 523 |
! ! |
524 |
||
525 |
StandaloneStartup initialize! |