author | Claus Gittinger <cg@exept.de> |
Thu, 24 Nov 2011 13:02:05 +0100 | |
changeset 2330 | b189800c0d92 |
parent 2259 | 25d241dbe673 |
child 2353 | fa7400d022a0 |
permissions | -rw-r--r-- |
545 | 1 |
" |
2151 | 2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
545 | 3 |
|
4 |
This software is furnished under a license and may be used |
|
5 |
only in accordance with the terms of that license and with the |
|
6 |
inclusion of the above copyright notice. This software may not |
|
7 |
be provided or otherwise made available to, or used by, any |
|
8 |
other person. No title to or ownership of the software is |
|
9 |
hereby transferred. |
|
2151 | 10 |
" |
681 | 11 |
"{ Package: 'stx:libjava' }" |
12 |
||
233 | 13 |
JavaView subclass:#JavaEmbeddedFrameView |
282 | 14 |
instanceVariableNames:'codeURL codeBaseURL documentURL archiveURL parameterDictionary |
15 |
embeddedAppletFrame applet appletID appletThread |
|
288 | 16 |
infoDisplayReceiver autoSetupApplet autoStartApplet |
2087 | 17 |
autoDestroyApplet isNS40 attributeHashTable appletIsPreloaded' |
282 | 18 |
classVariableNames:'NextSequentialAppletID' |
233 | 19 |
poolDictionaries:'' |
2108 | 20 |
category:'Languages-Java-Views-Support' |
233 | 21 |
! |
22 |
||
545 | 23 |
!JavaEmbeddedFrameView class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
2151 | 27 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
545 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
2084 | 35 |
" |
545 | 36 |
! |
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
a wrapper view, which allows for Java Applets to be embedded |
|
41 |
in a smalltalk view. |
|
42 |
This requires a netscape to be installed on the system. |
|
43 |
||
44 |
[Author:] |
|
45 |
Claus Gittinger |
|
46 |
" |
|
47 |
! ! |
|
233 | 48 |
|
397 | 49 |
!JavaEmbeddedFrameView class methodsFor:'support'! |
50 |
||
51 |
newAppletContext |
|
52 |
|jMozillaAppletContextClass| |
|
53 |
||
54 |
"/ this makes it a modzilla applet context ... |
|
55 |
jMozillaAppletContextClass := Java classForName:'netscape.applet.MozillaAppletContext'. |
|
56 |
jMozillaAppletContextClass isNil ifTrue:[ |
|
57 |
self warn:'no netscape.applet.MozillaAppletContext class'. |
|
58 |
^ nil |
|
59 |
]. |
|
60 |
jMozillaAppletContextClass instVarNamed:'debug' put:1. |
|
61 |
||
62 |
^ jMozillaAppletContextClass new. |
|
63 |
||
64 |
"Created: / 20.10.1998 / 15:40:08 / cg" |
|
65 |
"Modified: / 20.10.1998 / 15:43:47 / cg" |
|
66 |
! ! |
|
67 |
||
282 | 68 |
!JavaEmbeddedFrameView methodsFor:'accessing'! |
69 |
||
545 | 70 |
applet |
71 |
^ applet |
|
72 |
||
73 |
"Created: / 26.1.1999 / 13:51:10 / cg" |
|
74 |
! |
|
75 |
||
282 | 76 |
appletID |
77 |
"return the value of the instance variable 'appletID' (automatically generated)" |
|
78 |
||
79 |
^ appletID |
|
80 |
||
81 |
"Created: / 28.1.1998 / 21:08:54 / cg" |
|
82 |
! |
|
83 |
||
84 |
appletID:something |
|
85 |
"set the value of the instance variable 'appletID' (automatically generated)" |
|
86 |
||
87 |
appletID := something. |
|
88 |
||
89 |
"Created: / 28.1.1998 / 21:08:54 / cg" |
|
90 |
! |
|
91 |
||
2087 | 92 |
appletIsPreloaded:aBoolean |
93 |
appletIsPreloaded := aBoolean. |
|
94 |
! |
|
95 |
||
282 | 96 |
appletThread |
97 |
^ appletThread |
|
98 |
||
99 |
"Created: / 28.1.1998 / 21:39:42 / cg" |
|
100 |
! |
|
101 |
||
102 |
archiveURL:anArchiveURLString |
|
103 |
archiveURL := anArchiveURLString |
|
104 |
||
105 |
"Created: / 28.1.1998 / 21:00:38 / cg" |
|
106 |
! |
|
107 |
||
108 |
codeBaseURL:aCodeBaseURLString |
|
109 |
codeBaseURL := aCodeBaseURLString |
|
110 |
||
111 |
"Created: / 28.1.1998 / 20:59:34 / cg" |
|
112 |
! |
|
113 |
||
114 |
codeURL:aCodeURLString |
|
115 |
codeURL := aCodeURLString |
|
116 |
||
117 |
"Created: / 28.1.1998 / 21:10:11 / cg" |
|
118 |
! |
|
119 |
||
120 |
documentURL:aDocumentURLString |
|
121 |
documentURL := aDocumentURLString |
|
122 |
||
123 |
"Created: / 28.1.1998 / 21:00:03 / cg" |
|
124 |
"Modified: / 28.1.1998 / 21:00:28 / cg" |
|
125 |
! |
|
126 |
||
127 |
embeddedAppletFrame |
|
128 |
^ embeddedAppletFrame |
|
129 |
||
130 |
"Created: / 28.1.1998 / 21:39:35 / cg" |
|
131 |
! |
|
132 |
||
133 |
infoDisplayReceiver |
|
134 |
"return the value of the instance variable 'infoDisplayReceiver' (automatically generated)" |
|
135 |
||
136 |
^ infoDisplayReceiver |
|
137 |
||
138 |
"Created: / 28.1.1998 / 21:43:54 / cg" |
|
139 |
! |
|
140 |
||
141 |
infoDisplayReceiver:something |
|
142 |
"set the value of the instance variable 'infoDisplayReceiver' (automatically generated)" |
|
143 |
||
144 |
infoDisplayReceiver := something. |
|
145 |
||
146 |
"Created: / 28.1.1998 / 21:43:54 / cg" |
|
147 |
! |
|
148 |
||
545 | 149 |
parameterAt:key put:valueString |
150 |
parameterDictionary isNil ifTrue:[ |
|
151 |
parameterDictionary := IdentityDictionary new. |
|
152 |
]. |
|
153 |
parameterDictionary at:key put:valueString. |
|
154 |
attributeHashTable |
|
155 |
perform:#'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;' |
|
156 |
with:(Java as_String:key) |
|
157 |
with:(Java as_String:valueString) |
|
158 |
||
159 |
"Created: / 26.1.1999 / 13:46:01 / cg" |
|
160 |
"Modified: / 28.1.1999 / 17:59:36 / cg" |
|
161 |
! |
|
162 |
||
282 | 163 |
parameterDictionary:aParameterDictionary |
164 |
parameterDictionary := aParameterDictionary |
|
165 |
||
166 |
"Created: / 28.1.1998 / 21:01:20 / cg" |
|
167 |
! ! |
|
168 |
||
169 |
!JavaEmbeddedFrameView methodsFor:'applet control'! |
|
170 |
||
171 |
appletDESTROY |
|
384 | 172 |
|ev| |
173 |
||
174 |
isNS40 ifTrue:[ |
|
451 | 175 |
"/ ev = netscape.applet.AppletEvent(APPLET_DESTROY); |
176 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
177 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_DESTROY'). |
|
384 | 178 |
embeddedAppletFrame |
179 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
180 |
with:ev. |
|
181 |
^ self |
|
182 |
]. |
|
282 | 183 |
embeddedAppletFrame |
184 |
perform:#'sendEvent(I)V' |
|
185 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_DESTROY'). |
|
186 |
||
187 |
"Created: / 28.1.1998 / 21:41:45 / cg" |
|
451 | 188 |
"Modified: / 13.11.1998 / 14:19:49 / cg" |
282 | 189 |
! |
190 |
||
191 |
appletDISPOSE |
|
384 | 192 |
|ev| |
193 |
||
194 |
isNS40 ifTrue:[ |
|
451 | 195 |
"/ ev = netscape.applet.AppletEvent(APPLET_DISPOSE); |
196 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
197 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_DISPOSE'). |
|
384 | 198 |
embeddedAppletFrame |
199 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
200 |
with:ev. |
|
201 |
^ self |
|
202 |
]. |
|
282 | 203 |
embeddedAppletFrame |
204 |
perform:#'sendEvent(I)V' |
|
205 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_DISPOSE'). |
|
206 |
||
207 |
"Created: / 28.1.1998 / 21:41:57 / cg" |
|
451 | 208 |
"Modified: / 13.11.1998 / 14:19:43 / cg" |
282 | 209 |
! |
210 |
||
211 |
appletINIT |
|
384 | 212 |
|ev| |
213 |
||
214 |
isNS40 ifTrue:[ |
|
451 | 215 |
"/ ev = netscape.applet.AppletEvent(APPLET_INIT); |
216 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
217 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_INIT'). |
|
384 | 218 |
embeddedAppletFrame |
219 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
220 |
with:ev. |
|
221 |
^ self |
|
222 |
]. |
|
282 | 223 |
embeddedAppletFrame |
224 |
perform:#'sendEvent(I)V' |
|
225 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_INIT'). |
|
226 |
||
227 |
"Created: / 28.1.1998 / 21:17:51 / cg" |
|
451 | 228 |
"Modified: / 13.11.1998 / 14:19:35 / cg" |
282 | 229 |
! |
230 |
||
231 |
appletLOAD |
|
384 | 232 |
|ev| |
233 |
||
234 |
isNS40 ifTrue:[ |
|
451 | 235 |
"/ ev = netscape.applet.AppletEvent(APPLET_LOAD); |
236 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
237 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_LOAD'). |
|
384 | 238 |
embeddedAppletFrame |
239 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
240 |
with:ev. |
|
241 |
^ self |
|
242 |
]. |
|
282 | 243 |
embeddedAppletFrame |
244 |
perform:#'sendEvent(I)V' |
|
245 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_LOAD'). |
|
246 |
||
247 |
"Created: / 28.1.1998 / 21:17:37 / cg" |
|
451 | 248 |
"Modified: / 13.11.1998 / 14:19:31 / cg" |
282 | 249 |
! |
250 |
||
251 |
appletSTART |
|
384 | 252 |
|ev| |
253 |
||
254 |
isNS40 ifTrue:[ |
|
451 | 255 |
"/ ev = netscape.applet.AppletEvent(APPLET_START); |
256 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
257 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_START'). |
|
384 | 258 |
embeddedAppletFrame |
259 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
260 |
with:ev. |
|
261 |
^ self |
|
262 |
]. |
|
282 | 263 |
embeddedAppletFrame |
264 |
perform:#'sendEvent(I)V' |
|
265 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_START'). |
|
266 |
||
267 |
"Created: / 28.1.1998 / 21:18:01 / cg" |
|
451 | 268 |
"Modified: / 13.11.1998 / 14:19:21 / cg" |
282 | 269 |
! |
270 |
||
271 |
appletSTOP |
|
384 | 272 |
|ev| |
273 |
||
274 |
isNS40 ifTrue:[ |
|
451 | 275 |
"/ ev = netscape.applet.AppletEvent(APPLET_STOP); |
276 |
ev := (Java classForName:'netscape.applet.AppletEvent') |
|
277 |
newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_STOP'). |
|
384 | 278 |
embeddedAppletFrame |
279 |
perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
|
280 |
with:ev. |
|
281 |
^ self |
|
282 |
]. |
|
282 | 283 |
embeddedAppletFrame |
284 |
perform:#'sendEvent(I)V' |
|
285 |
with:(embeddedAppletFrame class instVarNamed:'APPLET_STOP'). |
|
286 |
||
287 |
"Created: / 28.1.1998 / 21:41:33 / cg" |
|
451 | 288 |
"Modified: / 13.11.1998 / 14:19:14 / cg" |
282 | 289 |
! |
290 |
||
288 | 291 |
autoDestroyApplet:aBoolean |
292 |
"set/clear the autoDestroy flag. |
|
293 |
If set, the applet will be shutDown whenever the I get destroyed. |
|
294 |
if clear, the applet is not automatically shutDown and must be |
|
295 |
terminated by someone else. |
|
296 |
The default is false." |
|
297 |
||
298 |
autoDestroyApplet := aBoolean. |
|
299 |
||
300 |
"Created: / 29.1.1998 / 15:18:50 / cg" |
|
301 |
"Modified: / 29.1.1998 / 15:21:01 / cg" |
|
302 |
! |
|
303 |
||
304 |
autoSetupApplet:aBoolean |
|
305 |
"set/clear the autoSetup flag. |
|
306 |
If set, the appletFrame will be setup whenever the I get realized |
|
307 |
for the first time. |
|
308 |
If clear, the frame is not automatically setup and must be |
|
309 |
setup by someone else. |
|
310 |
The default is true." |
|
311 |
||
312 |
||
313 |
autoSetupApplet := aBoolean. |
|
314 |
||
315 |
"Created: / 29.1.1998 / 15:18:41 / cg" |
|
316 |
"Modified: / 29.1.1998 / 20:45:37 / cg" |
|
317 |
! |
|
318 |
||
319 |
autoStartApplet:aBoolean |
|
320 |
"set/clear the autoStart flag. |
|
321 |
If set, the applet will be loaded & started whenever the I get realized |
|
322 |
for the first time. |
|
323 |
If clear, the applet is not automatically started and must be |
|
324 |
started by someone else. |
|
325 |
The default is false." |
|
326 |
||
327 |
||
328 |
autoStartApplet := aBoolean. |
|
329 |
||
330 |
"Created: / 29.1.1998 / 15:18:41 / cg" |
|
331 |
"Modified: / 29.1.1998 / 15:20:54 / cg" |
|
332 |
! |
|
333 |
||
282 | 334 |
startApplet |
681 | 335 |
"/ ensure its initialized when the first event comes; |
336 |
"/ therefore, raise my prio above the event dispatchers prio for a while. |
|
282 | 337 |
|
681 | 338 |
Processor activeProcess withPriority:(Processor activePriority + 1) |
339 |
do:[ |
|
340 |
self startAppletThread. |
|
341 |
||
2087 | 342 |
appletIsPreloaded ifFalse:[self appletLOAD]. |
681 | 343 |
self appletINIT. |
344 |
]. |
|
345 |
||
282 | 346 |
self appletSTART |
347 |
||
348 |
"Modified: / 28.1.1998 / 21:30:24 / cg" |
|
349 |
! |
|
350 |
||
351 |
startAppletThread |
|
352 |
|appletName| |
|
353 |
||
354 |
appletThread := JavaProcess |
|
355 |
for:[ |
|
356 |
"/ passnotifications to the documentFrame ... |
|
357 |
Object informationSignal handle:[:ex | |
|
358 |
JavaVM javaConsoleStream showCR:ex errorString. |
|
359 |
ex proceed. |
|
360 |
] do:[ |
|
361 |
Object activityNotificationSignal handle:[:ex | |
|
362 |
infoDisplayReceiver notNil ifTrue:[ |
|
363 |
infoDisplayReceiver infoDisplay:ex errorString. |
|
364 |
] ifFalse:[ |
|
365 |
Transcript showCR:ex errorString |
|
366 |
]. |
|
367 |
ex proceed. |
|
368 |
] do:[ |
|
369 |
[ |
|
2116
6178a12902ca
Rename AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
2108
diff
changeset
|
370 |
"/ Transcript showCR:(Timestamp now printString , ' start embeddedAppletFrame'). |
282 | 371 |
embeddedAppletFrame perform:#'run()V'. |
2116
6178a12902ca
Rename AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
2108
diff
changeset
|
372 |
] ensure:[ |
690 | 373 |
appletThread notNil ifTrue:[ |
374 |
appletThread terminateAllSubprocesses. |
|
375 |
]. |
|
282 | 376 |
Transcript showCR:'JAVA applet startup finished'. |
377 |
] |
|
378 |
] |
|
379 |
] |
|
380 |
] |
|
681 | 381 |
priority:(Processor activePriority "- 1"). |
282 | 382 |
|
383 |
appletName := codeURL asFilename withoutSuffix baseName. |
|
417 | 384 |
appletThread name:('JAVA-' , appletName , '-applet' , ' [startup]'). |
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
385 |
appletThread restartable:true. |
282 | 386 |
appletThread resume. |
387 |
^ appletThread. |
|
388 |
||
389 |
"Created: / 28.1.1998 / 21:30:32 / cg" |
|
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
390 |
"Modified: / 24.12.1999 / 02:58:50 / cg" |
286 | 391 |
! |
392 |
||
393 |
stopApplet |
|
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
394 |
|n n2| |
286 | 395 |
|
396 |
(appletThread notNil |
|
397 |
and:[appletThread isDead not])ifTrue:[ |
|
318 | 398 |
"/ 'EmbeddedAppletFrame [info]: send APPLET_STOP ...' infoPrintCR. |
286 | 399 |
self appletSTOP. |
400 |
||
318 | 401 |
"/ 'EmbeddedAppletFrame [info]: send APPLET_DESTROY ...' infoPrintCR. |
286 | 402 |
self appletDESTROY. |
403 |
||
318 | 404 |
"/ 'EmbeddedAppletFrame [info]: send APPLET_DISPOSE ...' infoPrintCR. |
286 | 405 |
self appletDISPOSE. |
406 |
||
407 |
"/ |
|
408 |
"/ give it a chance to stop ... |
|
409 |
"/ |
|
410 |
Processor yield. |
|
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
411 |
n2 := 0. |
286 | 412 |
[appletThread isDead] whileFalse:[ |
455 | 413 |
"/ give it a second to shut down ... |
286 | 414 |
n := 0. |
415 |
[n < 10 and:[appletThread isDead not]] whileTrue:[ |
|
416 |
Delay waitForSeconds:0.1. |
|
417 |
n := n + 1. |
|
418 |
]. |
|
419 |
appletThread isDead ifFalse:[ |
|
455 | 420 |
"/ after 3 seconds, kill it. |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
421 |
Transcript showCR:'EmbeddedAppletFrame [info]: JAVA thread did not stop - soft terminate ...'. |
527 | 422 |
appletThread == JavaVM javaScreenUpdaterThread ifTrue:[self halt]. |
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
423 |
appletThread == JavaVM javaEventQueueThread ifTrue:[self halt]. |
286 | 424 |
appletThread terminate. |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
425 |
n2 := n2 + 1. |
455 | 426 |
n2 > 3 ifTrue:[ |
311
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
427 |
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
|
428 |
appletThread terminateNoSignal |
b23c5e132b8c
hardterminate javaThread, if it did not terminate after 10 tries.
cg
parents:
303
diff
changeset
|
429 |
] |
286 | 430 |
]. |
431 |
]. |
|
432 |
]. |
|
433 |
appletThread := nil |
|
434 |
||
653
a98a3634389a
make processes restartable (for snapshot restart of java threads)
cg
parents:
644
diff
changeset
|
435 |
"Modified: / 24.12.1999 / 02:35:25 / cg" |
286 | 436 |
! ! |
437 |
||
438 |
!JavaEmbeddedFrameView methodsFor:'initialize / release'! |
|
439 |
||
440 |
destroy |
|
441 |
autoDestroyApplet == true ifTrue:[ |
|
442 |
self stopApplet |
|
443 |
]. |
|
444 |
super destroy. |
|
445 |
||
446 |
"Created: / 29.1.1998 / 15:21:45 / cg" |
|
447 |
"Modified: / 29.1.1998 / 15:28:26 / cg" |
|
448 |
! |
|
449 |
||
545 | 450 |
initialize |
2087 | 451 |
appletIsPreloaded := false. |
545 | 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 |
|
2259
25d241dbe673
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
651 |
^ '$Header: /cvs/stx/stx/libjava/JavaEmbeddedFrameView.st,v 1.28 2011-11-24 11:52:46 cg Exp $' |
25d241dbe673
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
652 |
! |
25d241dbe673
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
653 |
|
25d241dbe673
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
654 |
version_CVS |
25d241dbe673
fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
655 |
^ '$Header: /cvs/stx/stx/libjava/JavaEmbeddedFrameView.st,v 1.28 2011-11-24 11:52:46 cg Exp $' |
2151 | 656 |
! |
657 |
||
658 |
version_SVN |
|
2162 | 659 |
^ '§Id: JavaEmbeddedFrameView.st,v 1.26 2011/08/18 18:42:48 vrany Exp §' |
2084 | 660 |
! ! |