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