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