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