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