author | cg |
Sat, 14 Nov 1998 19:51:35 +0000 | |
changeset 451 | 50d24dc93f8b |
parent 429 | 99990a8a3509 |
child 455 | 36fffdce84f7 |
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:[ |
343 |
n := 0. |
|
344 |
[n < 10 and:[appletThread isDead not]] whileTrue:[ |
|
345 |
Delay waitForSeconds:0.1. |
|
346 |
n := n + 1. |
|
347 |
]. |
|
348 |
appletThread isDead ifFalse:[ |
|
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
349 |
Transcript showCR:'EmbeddedAppletFrame [info]: JAVA thread did not stop - soft terminate ...'. |
286 | 350 |
appletThread terminate. |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
351 |
n2 := n2 + 1. |
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
352 |
n2 > 10 ifTrue:[ |
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
353 |
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
|
354 |
appletThread terminateNoSignal |
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
355 |
] |
286 | 356 |
]. |
357 |
]. |
|
358 |
]. |
|
359 |
appletThread := nil |
|
360 |
||
318 | 361 |
"Modified: / 6.2.1998 / 02:19:18 / cg" |
286 | 362 |
! ! |
363 |
||
364 |
!JavaEmbeddedFrameView methodsFor:'initialize / release'! |
|
365 |
||
366 |
destroy |
|
367 |
autoDestroyApplet == true ifTrue:[ |
|
368 |
self stopApplet |
|
369 |
]. |
|
370 |
super destroy. |
|
371 |
||
372 |
"Created: / 29.1.1998 / 15:21:45 / cg" |
|
373 |
"Modified: / 29.1.1998 / 15:28:26 / cg" |
|
374 |
! |
|
375 |
||
376 |
realize |
|
377 |
super realize. |
|
288 | 378 |
|
379 |
autoSetupApplet ~~ false ifTrue:[ |
|
397 | 380 |
self setupAppletFrameIn:nil initializeJava:true |
288 | 381 |
]. |
286 | 382 |
autoStartApplet == true ifTrue:[ |
288 | 383 |
embeddedAppletFrame notNil ifTrue:[ |
384 |
self startApplet |
|
385 |
] |
|
286 | 386 |
] |
387 |
||
388 |
"Created: / 29.1.1998 / 15:21:30 / cg" |
|
397 | 389 |
"Modified: / 20.10.1998 / 15:46:32 / cg" |
282 | 390 |
! ! |
391 |
||
392 |
!JavaEmbeddedFrameView methodsFor:'private'! |
|
393 |
||
397 | 394 |
setupAppletFrameIn:anAppletContextOrNil |
395 |
|appletContext |
|
384 | 396 |
jEmbeddedAppletFrameClass jDerivedAppletFrameClass |
282 | 397 |
toolkit peer attribs id |
398 |
jCodeBaseURL jDocumentURL jArchiveURL| |
|
399 |
||
288 | 400 |
embeddedAppletFrame notNil ifTrue:[ |
401 |
"/ already setup |
|
402 |
^ self |
|
403 |
]. |
|
404 |
||
405 |
codeBaseURL isNil ifTrue:[ |
|
406 |
^ self |
|
407 |
]. |
|
408 |
||
409 |
Java startupJavaSystem. |
|
410 |
||
282 | 411 |
jCodeBaseURL := Java as_URL:codeBaseURL. |
288 | 412 |
documentURL notNil ifTrue:[ |
413 |
jDocumentURL := Java as_URL:documentURL. |
|
414 |
]. |
|
415 |
archiveURL notNil ifTrue:[ |
|
416 |
jArchiveURL := Java as_URL:archiveURL. |
|
417 |
]. |
|
282 | 418 |
|
419 |
id := appletID. |
|
420 |
id isNil ifTrue:[ |
|
421 |
NextSequentialAppletID isNil ifTrue:[ |
|
422 |
NextSequentialAppletID := 1. |
|
423 |
]. |
|
424 |
id := NextSequentialAppletID. |
|
425 |
NextSequentialAppletID := NextSequentialAppletID + 1 |
|
426 |
]. |
|
427 |
||
428 |
attribs := Dictionary new. |
|
429 |
width notNil ifTrue:[attribs at:'width' put:width printString]. |
|
430 |
height notNil ifTrue:[attribs at:'height' put:height printString]. |
|
431 |
codeURL notNil ifTrue:[attribs at:'code' put:codeURL]. |
|
432 |
parameterDictionary notNil ifTrue:[ |
|
433 |
attribs declareAllFrom:parameterDictionary |
|
434 |
]. |
|
435 |
attribs := Java as_Hashtable:attribs. |
|
436 |
||
397 | 437 |
anAppletContextOrNil notNil ifTrue:[ |
438 |
appletContext := anAppletContextOrNil |
|
439 |
] ifFalse:[ |
|
440 |
appletContext := self newAppletContext. |
|
441 |
appletContext isNil ifTrue:[ |
|
442 |
self warn:'no netscape.applet.MozillaAppletContext class'. |
|
443 |
^ false |
|
444 |
]. |
|
282 | 445 |
]. |
446 |
||
447 |
jEmbeddedAppletFrameClass := Java classForName:'netscape.applet.EmbeddedAppletFrame'. |
|
448 |
jEmbeddedAppletFrameClass isNil ifTrue:[ |
|
449 |
self warn:'no netscape.applet.EmbeddedAppletFrame class'. |
|
450 |
^ false |
|
451 |
]. |
|
384 | 452 |
jDerivedAppletFrameClass := Java classForName:'netscape.applet.DerivedAppletFrame'. |
453 |
jDerivedAppletFrameClass notNil ifTrue:[ |
|
454 |
"/ ns4.0 |
|
455 |
embeddedAppletFrame := jDerivedAppletFrameClass new. |
|
456 |
isNS40 := true. |
|
457 |
] ifFalse:[ |
|
458 |
"/ ns3.x |
|
459 |
embeddedAppletFrame := jEmbeddedAppletFrameClass new. |
|
460 |
isNS40 := false. |
|
461 |
]. |
|
282 | 462 |
embeddedAppletFrame instVarNamed:'pData' put:self. |
463 |
||
464 |
toolkit := Java classForName:'java.awt.Toolkit'. |
|
419 | 465 |
toolkit := toolkit perform:#getDefaultToolkit. |
282 | 466 |
peer := toolkit |
467 |
perform:#'createFrame(Ljava/awt/Frame;)Ljava/awt/peer/FramePeer;' |
|
468 |
with:embeddedAppletFrame. |
|
469 |
||
384 | 470 |
(embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V') |
282 | 471 |
ifTrue:[ |
384 | 472 |
"/ 4.0 netscape |
282 | 473 |
embeddedAppletFrame |
384 | 474 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V' |
475 |
withArguments: |
|
476 |
(Array |
|
477 |
with:jDocumentURL |
|
478 |
with:jCodeBaseURL |
|
479 |
with:jArchiveURL |
|
480 |
with:attribs |
|
481 |
with:appletContext |
|
482 |
with:(Java as_Integer:id) |
|
483 |
with:0 "/ reloadClasses-boolean |
|
484 |
). |
|
282 | 485 |
] ifFalse:[ |
384 | 486 |
(embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V') |
487 |
ifTrue:[ |
|
488 |
"/ 3.01 netscape |
|
489 |
embeddedAppletFrame |
|
490 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V' |
|
491 |
with:jDocumentURL |
|
492 |
with:jCodeBaseURL |
|
493 |
with:jArchiveURL |
|
494 |
with:attribs |
|
495 |
with:appletContext |
|
496 |
with:(Java as_Integer:id). |
|
497 |
] ifFalse:[ |
|
498 |
"/ oldStyle netscape |
|
499 |
embeddedAppletFrame |
|
500 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;I)V' |
|
501 |
with:jDocumentURL |
|
502 |
with:jCodeBaseURL |
|
503 |
with:attribs |
|
504 |
with:appletContext |
|
505 |
with:id. |
|
506 |
]. |
|
282 | 507 |
]. |
508 |
||
509 |
embeddedAppletFrame instVarNamed:'peer' put:peer. |
|
510 |
||
511 |
self javaPeer:peer. |
|
512 |
||
397 | 513 |
^ true |
514 |
||
515 |
"Created: / 20.10.1998 / 15:38:24 / cg" |
|
419 | 516 |
"Modified: / 4.11.1998 / 21:07:03 / cg" |
397 | 517 |
! |
518 |
||
519 |
setupAppletFrameIn:anAppletContextOrNil initializeJava:initializeJava |
|
520 |
|appletContext |
|
521 |
jEmbeddedAppletFrameClass jDerivedAppletFrameClass |
|
522 |
toolkit peer attribs id |
|
523 |
jCodeBaseURL jDocumentURL jArchiveURL| |
|
524 |
||
525 |
embeddedAppletFrame notNil ifTrue:[ |
|
526 |
"/ already setup |
|
527 |
^ self |
|
528 |
]. |
|
529 |
||
530 |
codeBaseURL isNil ifTrue:[ |
|
531 |
^ self |
|
532 |
]. |
|
533 |
||
534 |
initializeJava ifTrue:[ |
|
535 |
Java startupJavaSystem. |
|
536 |
]. |
|
537 |
||
538 |
jCodeBaseURL := Java as_URL:codeBaseURL. |
|
539 |
documentURL notNil ifTrue:[ |
|
540 |
jDocumentURL := Java as_URL:documentURL. |
|
541 |
]. |
|
542 |
archiveURL notNil ifTrue:[ |
|
543 |
jArchiveURL := Java as_URL:archiveURL. |
|
544 |
]. |
|
545 |
||
546 |
id := appletID. |
|
547 |
id isNil ifTrue:[ |
|
548 |
NextSequentialAppletID isNil ifTrue:[ |
|
549 |
NextSequentialAppletID := 1. |
|
550 |
]. |
|
551 |
id := NextSequentialAppletID. |
|
552 |
NextSequentialAppletID := NextSequentialAppletID + 1 |
|
553 |
]. |
|
554 |
||
555 |
attribs := Dictionary new. |
|
556 |
width notNil ifTrue:[attribs at:'width' put:width printString]. |
|
557 |
height notNil ifTrue:[attribs at:'height' put:height printString]. |
|
558 |
codeURL notNil ifTrue:[attribs at:'code' put:codeURL]. |
|
559 |
parameterDictionary notNil ifTrue:[ |
|
560 |
attribs declareAllFrom:parameterDictionary |
|
561 |
]. |
|
562 |
attribs := Java as_Hashtable:attribs. |
|
563 |
||
564 |
anAppletContextOrNil notNil ifTrue:[ |
|
565 |
appletContext := anAppletContextOrNil |
|
566 |
] ifFalse:[ |
|
420 | 567 |
appletContext := self class newAppletContext. |
397 | 568 |
appletContext isNil ifTrue:[ |
569 |
self warn:'no netscape.applet.MozillaAppletContext class'. |
|
570 |
^ false |
|
571 |
]. |
|
572 |
]. |
|
573 |
||
574 |
jEmbeddedAppletFrameClass := Java classForName:'netscape.applet.EmbeddedAppletFrame'. |
|
575 |
jEmbeddedAppletFrameClass isNil ifTrue:[ |
|
576 |
self warn:'no netscape.applet.EmbeddedAppletFrame class'. |
|
577 |
^ false |
|
578 |
]. |
|
579 |
jDerivedAppletFrameClass := Java classForName:'netscape.applet.DerivedAppletFrame'. |
|
580 |
jDerivedAppletFrameClass notNil ifTrue:[ |
|
581 |
"/ ns4.0 |
|
582 |
embeddedAppletFrame := jDerivedAppletFrameClass new. |
|
583 |
isNS40 := true. |
|
584 |
] ifFalse:[ |
|
585 |
"/ ns3.x |
|
586 |
embeddedAppletFrame := jEmbeddedAppletFrameClass new. |
|
587 |
isNS40 := false. |
|
588 |
]. |
|
589 |
embeddedAppletFrame instVarNamed:'pData' put:self. |
|
590 |
||
429 | 591 |
toolkit := (Java classForName:'java.awt.Toolkit') perform:#'getDefaultToolkit'. |
397 | 592 |
peer := toolkit |
593 |
perform:#'createFrame(Ljava/awt/Frame;)Ljava/awt/peer/FramePeer;' |
|
594 |
with:embeddedAppletFrame. |
|
595 |
||
596 |
(embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V') |
|
597 |
ifTrue:[ |
|
598 |
"/ 4.0 netscape |
|
599 |
embeddedAppletFrame |
|
600 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V' |
|
601 |
withArguments: |
|
602 |
(Array |
|
603 |
with:jDocumentURL |
|
604 |
with:jCodeBaseURL |
|
605 |
with:jArchiveURL |
|
606 |
with:attribs |
|
607 |
with:appletContext |
|
608 |
with:(Java as_Integer:id) |
|
609 |
with:0 "/ reloadClasses-boolean |
|
610 |
). |
|
611 |
] ifFalse:[ |
|
612 |
(embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V') |
|
613 |
ifTrue:[ |
|
614 |
"/ 3.01 netscape |
|
615 |
embeddedAppletFrame |
|
616 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V' |
|
617 |
with:jDocumentURL |
|
618 |
with:jCodeBaseURL |
|
619 |
with:jArchiveURL |
|
620 |
with:attribs |
|
621 |
with:appletContext |
|
622 |
with:(Java as_Integer:id). |
|
623 |
] ifFalse:[ |
|
624 |
"/ oldStyle netscape |
|
625 |
embeddedAppletFrame |
|
626 |
perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;I)V' |
|
627 |
with:jDocumentURL |
|
628 |
with:jCodeBaseURL |
|
629 |
with:attribs |
|
630 |
with:appletContext |
|
631 |
with:id. |
|
632 |
]. |
|
633 |
]. |
|
634 |
||
635 |
embeddedAppletFrame instVarNamed:'peer' put:peer. |
|
636 |
||
637 |
self javaPeer:peer. |
|
282 | 638 |
|
639 |
^ true |
|
640 |
||
397 | 641 |
"Created: / 20.10.1998 / 15:47:04 / cg" |
429 | 642 |
"Modified: / 10.11.1998 / 12:36:09 / cg" |
282 | 643 |
! ! |
644 |
||
303 | 645 |
!JavaEmbeddedFrameView methodsFor:'resizing'! |
646 |
||
647 |
sizeChanged:how |
|
648 |
super sizeChanged:how. |
|
649 |
^ self. |
|
650 |
embeddedAppletFrame notNil ifTrue:[ |
|
651 |
(embeddedAppletFrame perform:#'isResizable()Z') ~~ 0 ifTrue:[ |
|
652 |
self windowGroup sensor |
|
653 |
pushDamageEvent:(WindowEvent |
|
654 |
for:self |
|
655 |
type:#configureX:y:width:height: |
|
656 |
arguments:(Array with:left with:top with:width with:height)). |
|
657 |
"/ embeddedAppletFrame |
|
658 |
"/ perform:#'appletResize(II)V' |
|
659 |
"/ with:self width |
|
660 |
"/ with:self height. |
|
661 |
] |
|
662 |
] |
|
663 |
||
664 |
"Modified: / 1.2.1998 / 19:15:07 / cg" |
|
665 |
! ! |
|
666 |
||
233 | 667 |
!JavaEmbeddedFrameView class methodsFor:'documentation'! |
668 |
||
669 |
version |
|
451 | 670 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaEmbeddedFrameView.st,v 1.14 1998/11/14 19:50:37 cg Exp $' |
233 | 671 |
! ! |