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