author | Claus Gittinger <cg@exept.de> |
Fri, 19 Aug 2011 15:11:30 +0200 | |
changeset 2157 | a0c2ac13f6c6 |
parent 2151 | c0b6570c6f9b |
child 2162 | 415c8bb27655 |
permissions | -rw-r--r-- |
545 | 1 |
" |
2151 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
|
4 |
SWING Research Group, Czech Technical University in Prague |
|
5 |
||
6 |
Parts of the code written by Claus Gittinger are under following |
|
7 |
license: |
|
545 | 8 |
|
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
2151 | 15 |
|
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed: |
|
17 |
||
18 |
Permission is hereby granted, free of charge, to any person |
|
19 |
obtaining a copy of this software and associated documentation |
|
20 |
files (the 'Software'), to deal in the Software without |
|
21 |
restriction, including without limitation the rights to use, |
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
23 |
copies of the Software, and to permit persons to whom the |
|
24 |
Software is furnished to do so, subject to the following |
|
25 |
conditions: |
|
545 | 26 |
|
2151 | 27 |
The above copyright notice and this permission notice shall be |
28 |
included in all copies or substantial portions of the Software. |
|
545 | 29 |
|
2151 | 30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
37 |
OTHER DEALINGS IN THE SOFTWARE. |
|
38 |
||
39 |
[1] Code written at SWING Research Group contain a signature |
|
40 |
of one of the above copright owners. |
|
41 |
" |
|
681 | 42 |
"{ Package: 'stx:libjava' }" |
43 |
||
233 | 44 |
JavaView subclass:#JavaEmbeddedFrameView |
282 | 45 |
instanceVariableNames:'codeURL codeBaseURL documentURL archiveURL parameterDictionary |
46 |
embeddedAppletFrame applet appletID appletThread |
|
288 | 47 |
infoDisplayReceiver autoSetupApplet autoStartApplet |
2087 | 48 |
autoDestroyApplet isNS40 attributeHashTable appletIsPreloaded' |
282 | 49 |
classVariableNames:'NextSequentialAppletID' |
233 | 50 |
poolDictionaries:'' |
2108 | 51 |
category:'Languages-Java-Views-Support' |
233 | 52 |
! |
53 |
||
545 | 54 |
!JavaEmbeddedFrameView class methodsFor:'documentation'! |
55 |
||
56 |
copyright |
|
57 |
" |
|
2151 | 58 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
59 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
|
60 |
SWING Research Group, Czech Technical University in Prague |
|
61 |
||
62 |
Parts of the code written by Claus Gittinger are under following |
|
63 |
license: |
|
545 | 64 |
|
65 |
This software is furnished under a license and may be used |
|
66 |
only in accordance with the terms of that license and with the |
|
67 |
inclusion of the above copyright notice. This software may not |
|
68 |
be provided or otherwise made available to, or used by, any |
|
69 |
other person. No title to or ownership of the software is |
|
70 |
hereby transferred. |
|
2151 | 71 |
|
72 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed: |
|
73 |
||
74 |
Permission is hereby granted, free of charge, to any person |
|
75 |
obtaining a copy of this software and associated documentation |
|
76 |
files (the 'Software'), to deal in the Software without |
|
77 |
restriction, including without limitation the rights to use, |
|
78 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
79 |
copies of the Software, and to permit persons to whom the |
|
80 |
Software is furnished to do so, subject to the following |
|
81 |
conditions: |
|
82 |
||
83 |
The above copyright notice and this permission notice shall be |
|
84 |
included in all copies or substantial portions of the Software. |
|
85 |
||
86 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
87 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
88 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
89 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
90 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
91 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
92 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
93 |
OTHER DEALINGS IN THE SOFTWARE. |
|
94 |
||
95 |
[1] Code written at SWING Research Group contain a signature |
|
96 |
of one of the above copright owners. |
|
97 |
||
2084 | 98 |
" |
545 | 99 |
! |
100 |
||
101 |
documentation |
|
102 |
" |
|
103 |
a wrapper view, which allows for Java Applets to be embedded |
|
104 |
in a smalltalk view. |
|
105 |
This requires a netscape to be installed on the system. |
|
106 |
||
107 |
[Author:] |
|
108 |
Claus Gittinger |
|
109 |
" |
|
110 |
! ! |
|
233 | 111 |
|
397 | 112 |
!JavaEmbeddedFrameView class methodsFor:'support'! |
113 |
||
114 |
newAppletContext |
|
115 |
|jMozillaAppletContextClass| |
|
116 |
||
117 |
"/ this makes it a modzilla applet context ... |
|
118 |
jMozillaAppletContextClass := Java classForName:'netscape.applet.MozillaAppletContext'. |
|
119 |
jMozillaAppletContextClass isNil ifTrue:[ |
|
120 |
self warn:'no netscape.applet.MozillaAppletContext class'. |
|
121 |
^ nil |
|
122 |
]. |
|
123 |
jMozillaAppletContextClass instVarNamed:'debug' put:1. |
|
124 |
||
125 |
^ jMozillaAppletContextClass new. |
|
126 |
||
127 |
"Created: / 20.10.1998 / 15:40:08 / cg" |
|
128 |
"Modified: / 20.10.1998 / 15:43:47 / cg" |
|
129 |
! ! |
|
130 |
||
282 | 131 |
!JavaEmbeddedFrameView methodsFor:'accessing'! |
132 |
||
545 | 133 |
applet |
134 |
^ applet |
|
135 |
||
136 |
"Created: / 26.1.1999 / 13:51:10 / cg" |
|
137 |
! |
|
138 |
||
282 | 139 |
appletID |
140 |
"return the value of the instance variable 'appletID' (automatically generated)" |
|
141 |
||
142 |
^ appletID |
|
143 |
||
144 |
"Created: / 28.1.1998 / 21:08:54 / cg" |
|
145 |
! |
|
146 |
||
147 |
appletID:something |
|
148 |
"set the value of the instance variable 'appletID' (automatically generated)" |
|
149 |
||
150 |
appletID := something. |
|
151 |
||
152 |
"Created: / 28.1.1998 / 21:08:54 / cg" |
|
153 |
! |
|
154 |
||
2087 | 155 |
appletIsPreloaded:aBoolean |
156 |
appletIsPreloaded := aBoolean. |
|
157 |
! |
|
158 |
||
282 | 159 |
appletThread |
160 |
^ appletThread |
|
161 |
||
162 |
"Created: / 28.1.1998 / 21:39:42 / cg" |
|
163 |
! |
|
164 |
||
165 |
archiveURL:anArchiveURLString |
|
166 |
archiveURL := anArchiveURLString |
|
167 |
||
168 |
"Created: / 28.1.1998 / 21:00:38 / cg" |
|
169 |
! |
|
170 |
||
171 |
codeBaseURL:aCodeBaseURLString |
|
172 |
codeBaseURL := aCodeBaseURLString |
|
173 |
||
174 |
"Created: / 28.1.1998 / 20:59:34 / cg" |
|
175 |
! |
|
176 |
||
177 |
codeURL:aCodeURLString |
|
178 |
codeURL := aCodeURLString |
|
179 |
||
180 |
"Created: / 28.1.1998 / 21:10:11 / cg" |
|
181 |
! |
|
182 |
||
183 |
documentURL:aDocumentURLString |
|
184 |
documentURL := aDocumentURLString |
|
185 |
||
186 |
"Created: / 28.1.1998 / 21:00:03 / cg" |
|
187 |
"Modified: / 28.1.1998 / 21:00:28 / cg" |
|
188 |
! |
|
189 |
||
190 |
embeddedAppletFrame |
|
191 |
^ embeddedAppletFrame |
|
192 |
||
193 |
"Created: / 28.1.1998 / 21:39:35 / cg" |
|
194 |
! |
|
195 |
||
196 |
infoDisplayReceiver |
|
197 |
"return the value of the instance variable 'infoDisplayReceiver' (automatically generated)" |
|
198 |
||
199 |
^ infoDisplayReceiver |
|
200 |
||
201 |
"Created: / 28.1.1998 / 21:43:54 / cg" |
|
202 |
! |
|
203 |
||
204 |
infoDisplayReceiver:something |
|
205 |
"set the value of the instance variable 'infoDisplayReceiver' (automatically generated)" |
|
206 |
||
207 |
infoDisplayReceiver := something. |
|
208 |
||
209 |
"Created: / 28.1.1998 / 21:43:54 / cg" |
|
210 |
! |
|
211 |
||
545 | 212 |
parameterAt:key put:valueString |
213 |
parameterDictionary isNil ifTrue:[ |
|
214 |
parameterDictionary := IdentityDictionary new. |
|
215 |
]. |
|
216 |
parameterDictionary at:key put:valueString. |
|
217 |
attributeHashTable |
|
218 |
perform:#'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;' |
|
219 |
with:(Java as_String:key) |
|
220 |
with:(Java as_String:valueString) |
|
221 |
||
222 |
"Created: / 26.1.1999 / 13:46:01 / cg" |
|
223 |
"Modified: / 28.1.1999 / 17:59:36 / cg" |
|
224 |
! |
|
225 |
||
282 | 226 |
parameterDictionary:aParameterDictionary |
227 |
parameterDictionary := aParameterDictionary |
|
228 |
||
229 |
"Created: / 28.1.1998 / 21:01:20 / cg" |
|
230 |
! ! |
|
231 |
||
232 |
!JavaEmbeddedFrameView methodsFor:'applet control'! |
|
233 |
||
234 |
appletDESTROY |
|
384 | 235 |
|ev| |
236 |
||
237 |
isNS40 ifTrue:[ |
|
451 | 238 |
"/ ev = netscape.applet.AppletEvent(APPLET_DESTROY); |
239 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
240 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_DESTROY'). |
|
384 | 241 |
embeddedAppletFrame |
242 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
243 |
with:ev. |
|
244 |
^ self |
|
245 |
]. |
|
282 | 246 |
embeddedAppletFrame |
247 |
perform:#'sendEvent(I)V' |
|
248 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_DESTROY'). |
|
249 |
||
250 |
"Created: / 28.1.1998 / 21:41:45 / cg" |
|
451 | 251 |
"Modified: / 13.11.1998 / 14:19:49 / cg" |
282 | 252 |
! |
253 |
||
254 |
appletDISPOSE |
|
384 | 255 |
|ev| |
256 |
||
257 |
isNS40 ifTrue:[ |
|
451 | 258 |
"/ ev = netscape.applet.AppletEvent(APPLET_DISPOSE); |
259 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
260 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_DISPOSE'). |
|
384 | 261 |
embeddedAppletFrame |
262 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
263 |
with:ev. |
|
264 |
^ self |
|
265 |
]. |
|
282 | 266 |
embeddedAppletFrame |
267 |
perform:#'sendEvent(I)V' |
|
268 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_DISPOSE'). |
|
269 |
||
270 |
"Created: / 28.1.1998 / 21:41:57 / cg" |
|
451 | 271 |
"Modified: / 13.11.1998 / 14:19:43 / cg" |
282 | 272 |
! |
273 |
||
274 |
appletINIT |
|
384 | 275 |
|ev| |
276 |
||
277 |
isNS40 ifTrue:[ |
|
451 | 278 |
"/ ev = netscape.applet.AppletEvent(APPLET_INIT); |
279 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
280 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_INIT'). |
|
384 | 281 |
embeddedAppletFrame |
282 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
283 |
with:ev. |
|
284 |
^ self |
|
285 |
]. |
|
282 | 286 |
embeddedAppletFrame |
287 |
perform:#'sendEvent(I)V' |
|
288 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_INIT'). |
|
289 |
||
290 |
"Created: / 28.1.1998 / 21:17:51 / cg" |
|
451 | 291 |
"Modified: / 13.11.1998 / 14:19:35 / cg" |
282 | 292 |
! |
293 |
||
294 |
appletLOAD |
|
384 | 295 |
|ev| |
296 |
||
297 |
isNS40 ifTrue:[ |
|
451 | 298 |
"/ ev = netscape.applet.AppletEvent(APPLET_LOAD); |
299 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
300 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_LOAD'). |
|
384 | 301 |
embeddedAppletFrame |
302 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
303 |
with:ev. |
|
304 |
^ self |
|
305 |
]. |
|
282 | 306 |
embeddedAppletFrame |
307 |
perform:#'sendEvent(I)V' |
|
308 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_LOAD'). |
|
309 |
||
310 |
"Created: / 28.1.1998 / 21:17:37 / cg" |
|
451 | 311 |
"Modified: / 13.11.1998 / 14:19:31 / cg" |
282 | 312 |
! |
313 |
||
314 |
appletSTART |
|
384 | 315 |
|ev| |
316 |
||
317 |
isNS40 ifTrue:[ |
|
451 | 318 |
"/ ev = netscape.applet.AppletEvent(APPLET_START); |
319 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
320 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_START'). |
|
384 | 321 |
embeddedAppletFrame |
322 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
323 |
with:ev. |
|
324 |
^ self |
|
325 |
]. |
|
282 | 326 |
embeddedAppletFrame |
327 |
perform:#'sendEvent(I)V' |
|
328 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_START'). |
|
329 |
||
330 |
"Created: / 28.1.1998 / 21:18:01 / cg" |
|
451 | 331 |
"Modified: / 13.11.1998 / 14:19:21 / cg" |
282 | 332 |
! |
333 |
||
334 |
appletSTOP |
|
384 | 335 |
|ev| |
336 |
||
337 |
isNS40 ifTrue:[ |
|
451 | 338 |
"/ ev = netscape.applet.AppletEvent(APPLET_STOP); |
339 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
340 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_STOP'). |
|
384 | 341 |
embeddedAppletFrame |
342 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
343 |
with:ev. |
|
344 |
^ self |
|
345 |
]. |
|
282 | 346 |
embeddedAppletFrame |
347 |
perform:#'sendEvent(I)V' |
|
348 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_STOP'). |
|
349 |
||
350 |
"Created: / 28.1.1998 / 21:41:33 / cg" |
|
451 | 351 |
"Modified: / 13.11.1998 / 14:19:14 / cg" |
282 | 352 |
! |
353 |
||
288 | 354 |
autoDestroyApplet:aBoolean |
355 |
"set/clear the autoDestroy flag. |
|
356 |
If set, the applet will be shutDown whenever the I get destroyed. |
|
357 |
if clear, the applet is not automatically shutDown and must be |
|
358 |
terminated by someone else. |
|
359 |
The default is false." |
|
360 |
||
361 |
autoDestroyApplet := aBoolean. |
|
362 |
||
363 |
"Created: / 29.1.1998 / 15:18:50 / cg" |
|
364 |
"Modified: / 29.1.1998 / 15:21:01 / cg" |
|
365 |
! |
|
366 |
||
367 |
autoSetupApplet:aBoolean |
|
368 |
"set/clear the autoSetup flag. |
|
369 |
If set, the appletFrame will be setup whenever the I get realized |
|
370 |
for the first time. |
|
371 |
If clear, the frame is not automatically setup and must be |
|
372 |
setup by someone else. |
|
373 |
The default is true." |
|
374 |
||
375 |
||
376 |
autoSetupApplet := aBoolean. |
|
377 |
||
378 |
"Created: / 29.1.1998 / 15:18:41 / cg" |
|
379 |
"Modified: / 29.1.1998 / 20:45:37 / cg" |
|
380 |
! |
|
381 |
||
382 |
autoStartApplet:aBoolean |
|
383 |
"set/clear the autoStart flag. |
|
384 |
If set, the applet will be loaded & started whenever the I get realized |
|
385 |
for the first time. |
|
386 |
If clear, the applet is not automatically started and must be |
|
387 |
started by someone else. |
|
388 |
The default is false." |
|
389 |
||
390 |
||
391 |
autoStartApplet := aBoolean. |
|
392 |
||
393 |
"Created: / 29.1.1998 / 15:18:41 / cg" |
|
394 |
"Modified: / 29.1.1998 / 15:20:54 / cg" |
|
395 |
! |
|
396 |
||
282 | 397 |
startApplet |
681 | 398 |
"/ ensure its initialized when the first event comes; |
399 |
"/ therefore, raise my prio above the event dispatchers prio for a while. |
|
282 | 400 |
|
681 | 401 |
Processor activeProcess withPriority:(Processor activePriority + 1) |
402 |
do:[ |
|
403 |
self startAppletThread. |
|
404 |
||
2087 | 405 |
appletIsPreloaded ifFalse:[self appletLOAD]. |
681 | 406 |
self appletINIT. |
407 |
]. |
|
408 |
||
282 | 409 |
self appletSTART |
410 |
||
411 |
"Modified: / 28.1.1998 / 21:30:24 / cg" |
|
412 |
! |
|
413 |
||
414 |
startAppletThread |
|
415 |
|appletName| |
|
416 |
||
417 |
appletThread := JavaProcess |
|
418 |
for:[ |
|
419 |
"/ passnotifications to the documentFrame ... |
|
420 |
Object informationSignal handle:[:ex | |
|
421 |
JavaVM javaConsoleStream showCR:ex errorString. |
|
422 |
ex proceed. |
|
423 |
] do:[ |
|
424 |
Object activityNotificationSignal handle:[:ex | |
|
425 |
infoDisplayReceiver notNil ifTrue:[ |
|
426 |
infoDisplayReceiver infoDisplay:ex errorString. |
|
427 |
] ifFalse:[ |
|
428 |
Transcript showCR:ex errorString |
|
429 |
]. |
|
430 |
ex proceed. |
|
431 |
] do:[ |
|
432 |
[ |
|
2116
6178a12902ca
Rename AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
2108
diff
changeset
|
433 |
"/ Transcript showCR:(Timestamp now printString , ' start embeddedAppletFrame'). |
282 | 434 |
embeddedAppletFrame perform:#'run()V'. |
2116
6178a12902ca
Rename AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
2108
diff
changeset
|
435 |
] ensure:[ |
690 | 436 |
appletThread notNil ifTrue:[ |
437 |
appletThread terminateAllSubprocesses. |
|
438 |
]. |
|
282 | 439 |
Transcript showCR:'JAVA applet startup finished'. |
440 |
] |
|
441 |
] |
|
442 |
] |
|
443 |
] |
|
681 | 444 |
priority:(Processor activePriority "- 1"). |
282 | 445 |
|
446 |
appletName := codeURL asFilename withoutSuffix baseName. |
|
417 | 447 |
appletThread name:('JAVA-' , appletName , '-applet' , ' [startup]'). |
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
448 |
appletThread restartable:true. |
282 | 449 |
appletThread resume. |
450 |
^ appletThread. |
|
451 |
||
452 |
"Created: / 28.1.1998 / 21:30:32 / cg" |
|
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
453 |
"Modified: / 24.12.1999 / 02:58:50 / cg" |
286 | 454 |
! |
455 |
||
456 |
stopApplet |
|
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
457 |
|n n2| |
286 | 458 |
|
459 |
(appletThread notNil |
|
460 |
and:[appletThread isDead not])ifTrue:[ |
|
318 | 461 |
"/ 'EmbeddedAppletFrame [info]: send APPLET_STOP ...' infoPrintCR. |
286 | 462 |
self appletSTOP. |
463 |
||
318 | 464 |
"/ 'EmbeddedAppletFrame [info]: send APPLET_DESTROY ...' infoPrintCR. |
286 | 465 |
self appletDESTROY. |
466 |
||
318 | 467 |
"/ 'EmbeddedAppletFrame [info]: send APPLET_DISPOSE ...' infoPrintCR. |
286 | 468 |
self appletDISPOSE. |
469 |
||
470 |
"/ |
|
471 |
"/ give it a chance to stop ... |
|
472 |
"/ |
|
473 |
Processor yield. |
|
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
474 |
n2 := 0. |
286 | 475 |
[appletThread isDead] whileFalse:[ |
455 | 476 |
"/ give it a second to shut down ... |
286 | 477 |
n := 0. |
478 |
[n < 10 and:[appletThread isDead not]] whileTrue:[ |
|
479 |
Delay waitForSeconds:0.1. |
|
480 |
n := n + 1. |
|
481 |
]. |
|
482 |
appletThread isDead ifFalse:[ |
|
455 | 483 |
"/ after 3 seconds, kill it. |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
484 |
Transcript showCR:'EmbeddedAppletFrame [info]: JAVA thread did not stop - soft terminate ...'. |
527 | 485 |
appletThread == JavaVM javaScreenUpdaterThread ifTrue:[self halt]. |
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
486 |
appletThread == JavaVM javaEventQueueThread ifTrue:[self halt]. |
286 | 487 |
appletThread terminate. |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
488 |
n2 := n2 + 1. |
455 | 489 |
n2 > 3 ifTrue:[ |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
490 |
Transcript showCR:'EmbeddedAppletFrame [info]: JAVA thread did not stop - shooting down ...'. |
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
491 |
appletThread terminateNoSignal |
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
492 |
] |
286 | 493 |
]. |
494 |
]. |
|
495 |
]. |
|
496 |
appletThread := nil |
|
497 |
||
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
498 |
"Modified: / 24.12.1999 / 02:35:25 / cg" |
286 | 499 |
! ! |
500 |
||
501 |
!JavaEmbeddedFrameView methodsFor:'initialize / release'! |
|
502 |
||
503 |
destroy |
|
504 |
autoDestroyApplet == true ifTrue:[ |
|
505 |
self stopApplet |
|
506 |
]. |
|
507 |
super destroy. |
|
508 |
||
509 |
"Created: / 29.1.1998 / 15:21:45 / cg" |
|
510 |
"Modified: / 29.1.1998 / 15:28:26 / cg" |
|
511 |
! |
|
512 |
||
545 | 513 |
initialize |
2087 | 514 |
appletIsPreloaded := false. |
545 | 515 |
super initialize. |
516 |
viewBackground := Color black. |
|
517 |
||
518 |
"Modified: / 28.1.1999 / 17:44:11 / cg" |
|
519 |
! |
|
520 |
||
286 | 521 |
realize |
288 | 522 |
autoSetupApplet ~~ false ifTrue:[ |
397 | 523 |
self setupAppletFrameIn:nil initializeJava:true |
288 | 524 |
]. |
286 | 525 |
autoStartApplet == true ifTrue:[ |
288 | 526 |
embeddedAppletFrame notNil ifTrue:[ |
527 |
self startApplet |
|
528 |
] |
|
681 | 529 |
]. |
530 |
super realize. |
|
286 | 531 |
|
532 |
"Created: / 29.1.1998 / 15:21:30 / cg" |
|
397 | 533 |
"Modified: / 20.10.1998 / 15:46:32 / cg" |
282 | 534 |
! ! |
535 |
||
536 |
!JavaEmbeddedFrameView methodsFor:'private'! |
|
537 |
||
397 | 538 |
setupAppletFrameIn:anAppletContextOrNil |
644 | 539 |
^ self setupAppletFrameIn:anAppletContextOrNil initializeJava:true. |
540 |
! |
|
541 |
||
542 |
setupAppletFrameIn:anAppletContextOrNil initializeJava:initializeJava |
|
397 | 543 |
|appletContext |
384 | 544 |
jEmbeddedAppletFrameClass jDerivedAppletFrameClass |
282 | 545 |
toolkit peer attribs id |
644 | 546 |
jCodeBaseURL jDocumentURL jArchiveURL u fn| |
282 | 547 |
|
288 | 548 |
embeddedAppletFrame notNil ifTrue:[ |
549 |
"/ already setup |
|
550 |
^ self |
|
551 |
]. |
|
552 |
||
553 |
codeBaseURL isNil ifTrue:[ |
|
554 |
^ self |
|
555 |
]. |
|
556 |
||
644 | 557 |
initializeJava ifTrue:[ |
558 |
Java startupJavaSystem. |
|
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
559 |
] ifFalse:[ |
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
560 |
JavaVM initializeVMIfNoEventThreadRunning |
644 | 561 |
]. |
288 | 562 |
|
644 | 563 |
"/ if its a relative file-URL, make it relative under |
564 |
"/ java... |
|
565 |
u := URL fromString:codeBaseURL. |
|
566 |
u method = 'file' ifTrue:[ |
|
567 |
fn := Smalltalk getSystemFileName:u file. |
|
568 |
fn isNil ifTrue:[ |
|
569 |
fn := Smalltalk getPackageFileName:('stx/libjava/' , u file). |
|
570 |
] |
|
571 |
]. |
|
572 |
fn notNil ifTrue:[ |
|
573 |
fn := 'file:' , fn asFilename pathName |
|
574 |
] ifFalse:[ |
|
575 |
fn := codeBaseURL |
|
576 |
]. |
|
577 |
jCodeBaseURL := Java as_URL:fn. |
|
288 | 578 |
documentURL notNil ifTrue:[ |
579 |
jDocumentURL := Java as_URL:documentURL. |
|
644 | 580 |
] ifFalse:[ |
581 |
jDocumentURL := Java as_URL:fn |
|
288 | 582 |
]. |
583 |
archiveURL notNil ifTrue:[ |
|
584 |
jArchiveURL := Java as_URL:archiveURL. |
|
585 |
]. |
|
282 | 586 |
|
587 |
id := appletID. |
|
588 |
id isNil ifTrue:[ |
|
589 |
NextSequentialAppletID isNil ifTrue:[ |
|
590 |
NextSequentialAppletID := 1. |
|
591 |
]. |
|
592 |
id := NextSequentialAppletID. |
|
593 |
NextSequentialAppletID := NextSequentialAppletID + 1 |
|
594 |
]. |
|
595 |
||
596 |
attribs := Dictionary new. |
|
597 |
width notNil ifTrue:[attribs at:'width' put:width printString]. |
|
598 |
height notNil ifTrue:[attribs at:'height' put:height printString]. |
|
599 |
||
644 | 600 |
codeURL notNil ifTrue:[ |
601 |
attribs at:'code' put:codeURL |
|
384 | 602 |
]. |
397 | 603 |
parameterDictionary notNil ifTrue:[ |
604 |
attribs declareAllFrom:parameterDictionary |
|
605 |
]. |
|
545 | 606 |
attributeHashTable := Java as_Hashtable:attribs. |
397 | 607 |
|
608 |
anAppletContextOrNil notNil ifTrue:[ |
|
609 |
appletContext := anAppletContextOrNil |
|
610 |
] ifFalse:[ |
|
420 | 611 |
appletContext := self class newAppletContext. |
397 | 612 |
appletContext isNil ifTrue:[ |
613 |
self warn:'no netscape.applet.MozillaAppletContext class'. |
|
614 |
^ false |
|
615 |
]. |
|
616 |
]. |
|
617 |
||
618 |
jEmbeddedAppletFrameClass := Java classForName:'netscape.applet.EmbeddedAppletFrame'. |
|
619 |
jEmbeddedAppletFrameClass isNil ifTrue:[ |
|
620 |
self warn:'no netscape.applet.EmbeddedAppletFrame class'. |
|
621 |
^ false |
|
622 |
]. |
|
623 |
jDerivedAppletFrameClass := Java classForName:'netscape.applet.DerivedAppletFrame'. |
|
624 |
jDerivedAppletFrameClass notNil ifTrue:[ |
|
625 |
"/ ns4.0 |
|
626 |
embeddedAppletFrame := jDerivedAppletFrameClass new. |
|
627 |
isNS40 := true. |
|
628 |
] ifFalse:[ |
|
629 |
"/ ns3.x |
|
630 |
embeddedAppletFrame := jEmbeddedAppletFrameClass new. |
|
631 |
isNS40 := false. |
|
632 |
]. |
|
633 |
embeddedAppletFrame instVarNamed:'pData' put:self. |
|
634 |
||
429 | 635 |
toolkit := (Java classForName:'java.awt.Toolkit') perform:#'getDefaultToolkit'. |
397 | 636 |
peer := toolkit |
637 |
perform:#'createFrame(Ljava/awt/Frame;)Ljava/awt/peer/FramePeer;' |
|
638 |
with:embeddedAppletFrame. |
|
639 |
||
640 |
(embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V') |
|
641 |
ifTrue:[ |
|
642 |
"/ 4.0 netscape |
|
643 |
embeddedAppletFrame |
|
644 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V' |
|
645 |
withArguments: |
|
646 |
(Array |
|
647 |
with:jDocumentURL |
|
648 |
with:jCodeBaseURL |
|
649 |
with:jArchiveURL |
|
545 | 650 |
with:attributeHashTable |
397 | 651 |
with:appletContext |
652 |
with:(Java as_Integer:id) |
|
653 |
with:0 "/ reloadClasses-boolean |
|
654 |
). |
|
655 |
] ifFalse:[ |
|
656 |
(embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V') |
|
657 |
ifTrue:[ |
|
658 |
"/ 3.01 netscape |
|
659 |
embeddedAppletFrame |
|
660 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V' |
|
661 |
with:jDocumentURL |
|
662 |
with:jCodeBaseURL |
|
663 |
with:jArchiveURL |
|
545 | 664 |
with:attributeHashTable |
397 | 665 |
with:appletContext |
666 |
with:(Java as_Integer:id). |
|
667 |
] ifFalse:[ |
|
668 |
"/ oldStyle netscape |
|
669 |
embeddedAppletFrame |
|
670 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;I)V' |
|
671 |
with:jDocumentURL |
|
672 |
with:jCodeBaseURL |
|
545 | 673 |
with:attributeHashTable |
397 | 674 |
with:appletContext |
675 |
with:id. |
|
676 |
]. |
|
677 |
]. |
|
678 |
||
679 |
embeddedAppletFrame instVarNamed:'peer' put:peer. |
|
680 |
||
681 |
self javaPeer:peer. |
|
282 | 682 |
|
683 |
^ true |
|
684 |
||
397 | 685 |
"Created: / 20.10.1998 / 15:47:04 / cg" |
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
686 |
"Modified: / 24.12.1999 / 01:38:17 / cg" |
282 | 687 |
! ! |
688 |
||
303 | 689 |
!JavaEmbeddedFrameView methodsFor:'resizing'! |
690 |
||
691 |
sizeChanged:how |
|
692 |
super sizeChanged:how. |
|
693 |
^ self. |
|
694 |
embeddedAppletFrame notNil ifTrue:[ |
|
695 |
(embeddedAppletFrame perform:#'isResizable()Z') ~~ 0 ifTrue:[ |
|
696 |
self windowGroup sensor |
|
697 |
pushDamageEvent:(WindowEvent |
|
698 |
for:self |
|
699 |
type:#configureX:y:width:height: |
|
700 |
arguments:(Array with:left with:top with:width with:height)). |
|
701 |
"/ embeddedAppletFrame |
|
702 |
"/ perform:#'appletResize(II)V' |
|
703 |
"/ with:self width |
|
704 |
"/ with:self height. |
|
705 |
] |
|
706 |
] |
|
707 |
||
708 |
"Modified: / 1.2.1998 / 19:15:07 / cg" |
|
709 |
! ! |
|
710 |
||
233 | 711 |
!JavaEmbeddedFrameView class methodsFor:'documentation'! |
712 |
||
713 |
version |
|
2151 | 714 |
^ '$Id: JavaEmbeddedFrameView.st,v 1.26 2011-08-18 18:42:48 vrany Exp $' |
715 |
! |
|
716 |
||
717 |
version_SVN |
|
718 |
^ '$Id: JavaEmbeddedFrameView.st,v 1.26 2011-08-18 18:42:48 vrany Exp $' |
|
2084 | 719 |
! ! |