230 ! ! |
230 ! ! |
231 |
231 |
232 !JavaEmbeddedFrameView methodsFor:'applet control'! |
232 !JavaEmbeddedFrameView methodsFor:'applet control'! |
233 |
233 |
234 appletDESTROY |
234 appletDESTROY |
235 |ev| |
235 | ev | |
236 |
236 |
237 isNS40 ifTrue:[ |
237 isNS40 ifTrue: [ |
238 "/ ev = netscape.applet.AppletEvent(APPLET_DESTROY); |
238 "/ ev = netscape.applet.AppletEvent(APPLET_DESTROY); |
239 ev := (Java classForName:'netscape.applet.AppletEvent') |
239 ev := (JavaVM classForName: 'netscape.applet.AppletEvent') |
240 newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_DESTROY'). |
240 newWith_int: (embeddedAppletFrame class instVarNamed: 'APPLET_DESTROY'). |
241 embeddedAppletFrame |
241 embeddedAppletFrame perform: #'sendEvent(Lnetscape/applet/NEvent;)V' |
242 perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
242 with: ev. |
243 with:ev. |
|
244 ^ self |
243 ^ self |
245 ]. |
244 ]. |
246 embeddedAppletFrame |
245 embeddedAppletFrame perform: #'sendEvent(I)V' |
247 perform:#'sendEvent(I)V' |
246 with: (embeddedAppletFrame class instVarNamed: 'APPLET_DESTROY'). |
248 with:(embeddedAppletFrame class instVarNamed:'APPLET_DESTROY'). |
|
249 |
247 |
250 "Created: / 28.1.1998 / 21:41:45 / cg" |
248 "Created: / 28.1.1998 / 21:41:45 / cg" |
251 "Modified: / 13.11.1998 / 14:19:49 / cg" |
249 "Modified: / 13.11.1998 / 14:19:49 / cg" |
252 ! |
250 ! |
253 |
251 |
254 appletDISPOSE |
252 appletDISPOSE |
255 |ev| |
253 | ev | |
256 |
254 |
257 isNS40 ifTrue:[ |
255 isNS40 ifTrue: [ |
258 "/ ev = netscape.applet.AppletEvent(APPLET_DISPOSE); |
256 "/ ev = netscape.applet.AppletEvent(APPLET_DISPOSE); |
259 ev := (Java classForName:'netscape.applet.AppletEvent') |
257 ev := (JavaVM classForName: 'netscape.applet.AppletEvent') |
260 newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_DISPOSE'). |
258 newWith_int: (embeddedAppletFrame class instVarNamed: 'APPLET_DISPOSE'). |
261 embeddedAppletFrame |
259 embeddedAppletFrame perform: #'sendEvent(Lnetscape/applet/NEvent;)V' |
262 perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
260 with: ev. |
263 with:ev. |
|
264 ^ self |
261 ^ self |
265 ]. |
262 ]. |
266 embeddedAppletFrame |
263 embeddedAppletFrame perform: #'sendEvent(I)V' |
267 perform:#'sendEvent(I)V' |
264 with: (embeddedAppletFrame class instVarNamed: 'APPLET_DISPOSE'). |
268 with:(embeddedAppletFrame class instVarNamed:'APPLET_DISPOSE'). |
|
269 |
265 |
270 "Created: / 28.1.1998 / 21:41:57 / cg" |
266 "Created: / 28.1.1998 / 21:41:57 / cg" |
271 "Modified: / 13.11.1998 / 14:19:43 / cg" |
267 "Modified: / 13.11.1998 / 14:19:43 / cg" |
272 ! |
268 ! |
273 |
269 |
274 appletINIT |
270 appletINIT |
275 |ev| |
271 | ev | |
276 |
272 |
277 isNS40 ifTrue:[ |
273 isNS40 ifTrue: [ |
278 "/ ev = netscape.applet.AppletEvent(APPLET_INIT); |
274 "/ ev = netscape.applet.AppletEvent(APPLET_INIT); |
279 ev := (Java classForName:'netscape.applet.AppletEvent') |
275 ev := (JavaVM classForName: 'netscape.applet.AppletEvent') |
280 newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_INIT'). |
276 newWith_int: (embeddedAppletFrame class instVarNamed: 'APPLET_INIT'). |
281 embeddedAppletFrame |
277 embeddedAppletFrame perform: #'sendEvent(Lnetscape/applet/NEvent;)V' |
282 perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
278 with: ev. |
283 with:ev. |
|
284 ^ self |
279 ^ self |
285 ]. |
280 ]. |
286 embeddedAppletFrame |
281 embeddedAppletFrame perform: #'sendEvent(I)V' |
287 perform:#'sendEvent(I)V' |
282 with: (embeddedAppletFrame class instVarNamed: 'APPLET_INIT'). |
288 with:(embeddedAppletFrame class instVarNamed:'APPLET_INIT'). |
|
289 |
283 |
290 "Created: / 28.1.1998 / 21:17:51 / cg" |
284 "Created: / 28.1.1998 / 21:17:51 / cg" |
291 "Modified: / 13.11.1998 / 14:19:35 / cg" |
285 "Modified: / 13.11.1998 / 14:19:35 / cg" |
292 ! |
286 ! |
293 |
287 |
294 appletLOAD |
288 appletLOAD |
295 |ev| |
289 | ev | |
296 |
290 |
297 isNS40 ifTrue:[ |
291 isNS40 ifTrue: [ |
298 "/ ev = netscape.applet.AppletEvent(APPLET_LOAD); |
292 "/ ev = netscape.applet.AppletEvent(APPLET_LOAD); |
299 ev := (Java classForName:'netscape.applet.AppletEvent') |
293 ev := (JavaVM classForName: 'netscape.applet.AppletEvent') |
300 newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_LOAD'). |
294 newWith_int: (embeddedAppletFrame class instVarNamed: 'APPLET_LOAD'). |
301 embeddedAppletFrame |
295 embeddedAppletFrame perform: #'sendEvent(Lnetscape/applet/NEvent;)V' |
302 perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
296 with: ev. |
303 with:ev. |
|
304 ^ self |
297 ^ self |
305 ]. |
298 ]. |
306 embeddedAppletFrame |
299 embeddedAppletFrame perform: #'sendEvent(I)V' |
307 perform:#'sendEvent(I)V' |
300 with: (embeddedAppletFrame class instVarNamed: 'APPLET_LOAD'). |
308 with:(embeddedAppletFrame class instVarNamed:'APPLET_LOAD'). |
|
309 |
301 |
310 "Created: / 28.1.1998 / 21:17:37 / cg" |
302 "Created: / 28.1.1998 / 21:17:37 / cg" |
311 "Modified: / 13.11.1998 / 14:19:31 / cg" |
303 "Modified: / 13.11.1998 / 14:19:31 / cg" |
312 ! |
304 ! |
313 |
305 |
314 appletSTART |
306 appletSTART |
315 |ev| |
307 | ev | |
316 |
308 |
317 isNS40 ifTrue:[ |
309 isNS40 ifTrue: [ |
318 "/ ev = netscape.applet.AppletEvent(APPLET_START); |
310 "/ ev = netscape.applet.AppletEvent(APPLET_START); |
319 ev := (Java classForName:'netscape.applet.AppletEvent') |
311 ev := (JavaVM classForName: 'netscape.applet.AppletEvent') |
320 newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_START'). |
312 newWith_int: (embeddedAppletFrame class instVarNamed: 'APPLET_START'). |
321 embeddedAppletFrame |
313 embeddedAppletFrame perform: #'sendEvent(Lnetscape/applet/NEvent;)V' |
322 perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
314 with: ev. |
323 with:ev. |
|
324 ^ self |
315 ^ self |
325 ]. |
316 ]. |
326 embeddedAppletFrame |
317 embeddedAppletFrame perform: #'sendEvent(I)V' |
327 perform:#'sendEvent(I)V' |
318 with: (embeddedAppletFrame class instVarNamed: 'APPLET_START'). |
328 with:(embeddedAppletFrame class instVarNamed:'APPLET_START'). |
|
329 |
319 |
330 "Created: / 28.1.1998 / 21:18:01 / cg" |
320 "Created: / 28.1.1998 / 21:18:01 / cg" |
331 "Modified: / 13.11.1998 / 14:19:21 / cg" |
321 "Modified: / 13.11.1998 / 14:19:21 / cg" |
332 ! |
322 ! |
333 |
323 |
334 appletSTOP |
324 appletSTOP |
335 |ev| |
325 | ev | |
336 |
326 |
337 isNS40 ifTrue:[ |
327 isNS40 ifTrue: [ |
338 "/ ev = netscape.applet.AppletEvent(APPLET_STOP); |
328 "/ ev = netscape.applet.AppletEvent(APPLET_STOP); |
339 ev := (Java classForName:'netscape.applet.AppletEvent') |
329 ev := (JavaVM classForName: 'netscape.applet.AppletEvent') |
340 newWith_int:(embeddedAppletFrame class instVarNamed:'APPLET_STOP'). |
330 newWith_int: (embeddedAppletFrame class instVarNamed: 'APPLET_STOP'). |
341 embeddedAppletFrame |
331 embeddedAppletFrame perform: #'sendEvent(Lnetscape/applet/NEvent;)V' |
342 perform:#'sendEvent(Lnetscape/applet/NEvent;)V' |
332 with: ev. |
343 with:ev. |
|
344 ^ self |
333 ^ self |
345 ]. |
334 ]. |
346 embeddedAppletFrame |
335 embeddedAppletFrame perform: #'sendEvent(I)V' |
347 perform:#'sendEvent(I)V' |
336 with: (embeddedAppletFrame class instVarNamed: 'APPLET_STOP'). |
348 with:(embeddedAppletFrame class instVarNamed:'APPLET_STOP'). |
|
349 |
337 |
350 "Created: / 28.1.1998 / 21:41:33 / cg" |
338 "Created: / 28.1.1998 / 21:41:33 / cg" |
351 "Modified: / 13.11.1998 / 14:19:14 / cg" |
339 "Modified: / 13.11.1998 / 14:19:14 / cg" |
352 ! |
340 ! |
353 |
341 |
539 |
527 |
540 setupAppletFrameIn:anAppletContextOrNil |
528 setupAppletFrameIn:anAppletContextOrNil |
541 ^ self setupAppletFrameIn:anAppletContextOrNil initializeJava:true. |
529 ^ self setupAppletFrameIn:anAppletContextOrNil initializeJava:true. |
542 ! |
530 ! |
543 |
531 |
544 setupAppletFrameIn:anAppletContextOrNil initializeJava:initializeJava |
532 setupAppletFrameIn: anAppletContextOrNil initializeJava: initializeJava |
545 |appletContext |
533 | appletContext jEmbeddedAppletFrameClass jDerivedAppletFrameClass toolkit peer attribs id jCodeBaseURL jDocumentURL jArchiveURL u fn | |
546 jEmbeddedAppletFrameClass jDerivedAppletFrameClass |
534 |
547 toolkit peer attribs id |
535 embeddedAppletFrame notNil ifTrue: [ |
548 jCodeBaseURL jDocumentURL jArchiveURL u fn| |
|
549 |
|
550 embeddedAppletFrame notNil ifTrue:[ |
|
551 "/ already setup |
536 "/ already setup |
552 ^ self |
537 ^ self |
553 ]. |
538 ]. |
554 |
539 codeBaseURL isNil ifTrue: [ ^ self ]. |
555 codeBaseURL isNil ifTrue:[ |
540 initializeJava ifTrue: [ Java startupJavaSystem. ] ifFalse: [ |
556 ^ self |
|
557 ]. |
|
558 |
|
559 initializeJava ifTrue:[ |
|
560 Java startupJavaSystem. |
|
561 ] ifFalse:[ |
|
562 JavaVM initializeVMIfNoEventThreadRunning |
541 JavaVM initializeVMIfNoEventThreadRunning |
563 ]. |
542 ]. |
564 |
543 |
565 "/ if its a relative file-URL, make it relative under |
544 "/ if its a relative file-URL, make it relative under |
566 "/ java... |
545 "/ java... |
567 u := URL fromString:codeBaseURL. |
546 |
568 u method = 'file' ifTrue:[ |
547 u := URL fromString: codeBaseURL. |
569 fn := Smalltalk getSystemFileName:u file. |
548 u method = 'file' ifTrue: [ |
570 fn isNil ifTrue:[ |
549 fn := Smalltalk getSystemFileName: u file. |
571 fn := Smalltalk getPackageFileName:('stx/libjava/' , u file). |
550 fn isNil ifTrue: [ |
|
551 fn := Smalltalk getPackageFileName: ('stx/libjava/' , u file). |
572 ] |
552 ] |
573 ]. |
553 ]. |
574 fn notNil ifTrue:[ |
554 fn notNil ifTrue: [ fn := 'file:' , fn asFilename pathName ] ifFalse: [ |
575 fn := 'file:' , fn asFilename pathName |
|
576 ] ifFalse:[ |
|
577 fn := codeBaseURL |
555 fn := codeBaseURL |
578 ]. |
556 ]. |
579 jCodeBaseURL := Java as_URL:fn. |
557 jCodeBaseURL := Java as_URL: fn. |
580 documentURL notNil ifTrue:[ |
558 documentURL notNil ifTrue: [ jDocumentURL := Java as_URL: documentURL. ] ifFalse: [ |
581 jDocumentURL := Java as_URL:documentURL. |
559 jDocumentURL := Java as_URL: fn |
582 ] ifFalse:[ |
560 ]. |
583 jDocumentURL := Java as_URL:fn |
561 archiveURL notNil ifTrue: [ jArchiveURL := Java as_URL: archiveURL. ]. |
584 ]. |
|
585 archiveURL notNil ifTrue:[ |
|
586 jArchiveURL := Java as_URL:archiveURL. |
|
587 ]. |
|
588 |
|
589 id := appletID. |
562 id := appletID. |
590 id isNil ifTrue:[ |
563 id isNil ifTrue: [ |
591 NextSequentialAppletID isNil ifTrue:[ |
564 NextSequentialAppletID isNil ifTrue: [ NextSequentialAppletID := 1. ]. |
592 NextSequentialAppletID := 1. |
|
593 ]. |
|
594 id := NextSequentialAppletID. |
565 id := NextSequentialAppletID. |
595 NextSequentialAppletID := NextSequentialAppletID + 1 |
566 NextSequentialAppletID := NextSequentialAppletID + 1 |
596 ]. |
567 ]. |
597 |
|
598 attribs := Dictionary new. |
568 attribs := Dictionary new. |
599 width notNil ifTrue:[attribs at:'width' put:width printString]. |
569 width notNil ifTrue: [ attribs at: 'width' put: width printString ]. |
600 height notNil ifTrue:[attribs at:'height' put:height printString]. |
570 height notNil ifTrue: [ attribs at: 'height' put: height printString ]. |
601 |
571 codeURL notNil ifTrue: [ attribs at: 'code' put: codeURL ]. |
602 codeURL notNil ifTrue:[ |
572 parameterDictionary notNil ifTrue: [ |
603 attribs at:'code' put:codeURL |
573 attribs declareAllFrom: parameterDictionary |
604 ]. |
574 ]. |
605 parameterDictionary notNil ifTrue:[ |
575 attributeHashTable := Java as_Hashtable: attribs. |
606 attribs declareAllFrom:parameterDictionary |
576 anAppletContextOrNil notNil ifTrue: [ appletContext := anAppletContextOrNil ] ifFalse: [ |
607 ]. |
|
608 attributeHashTable := Java as_Hashtable:attribs. |
|
609 |
|
610 anAppletContextOrNil notNil ifTrue:[ |
|
611 appletContext := anAppletContextOrNil |
|
612 ] ifFalse:[ |
|
613 appletContext := self class newAppletContext. |
577 appletContext := self class newAppletContext. |
614 appletContext isNil ifTrue:[ |
578 appletContext isNil ifTrue: [ |
615 self warn:'no netscape.applet.MozillaAppletContext class'. |
579 self warn: 'no netscape.applet.MozillaAppletContext class'. |
616 ^ false |
580 ^ false |
617 ]. |
581 ]. |
618 ]. |
582 ]. |
619 |
583 jEmbeddedAppletFrameClass := JavaVM |
620 jEmbeddedAppletFrameClass := Java classForName:'netscape.applet.EmbeddedAppletFrame'. |
584 classForName: 'netscape.applet.EmbeddedAppletFrame'. |
621 jEmbeddedAppletFrameClass isNil ifTrue:[ |
585 jEmbeddedAppletFrameClass isNil ifTrue: [ |
622 self warn:'no netscape.applet.EmbeddedAppletFrame class'. |
586 self warn: 'no netscape.applet.EmbeddedAppletFrame class'. |
623 ^ false |
587 ^ false |
624 ]. |
588 ]. |
625 jDerivedAppletFrameClass := Java classForName:'netscape.applet.DerivedAppletFrame'. |
589 jDerivedAppletFrameClass := Java |
626 jDerivedAppletFrameClass notNil ifTrue:[ |
590 classForName: 'netscape.applet.DerivedAppletFrame'. |
|
591 jDerivedAppletFrameClass notNil ifTrue: [ |
627 "/ ns4.0 |
592 "/ ns4.0 |
628 embeddedAppletFrame := jDerivedAppletFrameClass new. |
593 embeddedAppletFrame := jDerivedAppletFrameClass new. |
629 isNS40 := true. |
594 isNS40 := true. |
630 ] ifFalse:[ |
595 ] ifFalse: [ |
631 "/ ns3.x |
596 "/ ns3.x |
632 embeddedAppletFrame := jEmbeddedAppletFrameClass new. |
597 embeddedAppletFrame := jEmbeddedAppletFrameClass new. |
633 isNS40 := false. |
598 isNS40 := false. |
634 ]. |
599 ]. |
635 embeddedAppletFrame instVarNamed:'pData' put:self. |
600 embeddedAppletFrame instVarNamed: 'pData' put: self. |
636 |
601 toolkit := (Java classForName: 'java.awt.Toolkit') |
637 toolkit := (Java classForName:'java.awt.Toolkit') perform:#'getDefaultToolkit'. |
602 perform: #getDefaultToolkit. |
638 peer := toolkit |
603 peer := toolkit |
639 perform:#'createFrame(Ljava/awt/Frame;)Ljava/awt/peer/FramePeer;' |
604 perform: #'createFrame(Ljava/awt/Frame;)Ljava/awt/peer/FramePeer;' |
640 with:embeddedAppletFrame. |
605 with: embeddedAppletFrame. |
641 |
606 (embeddedAppletFrame |
642 (embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V') |
607 respondsTo: #'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V') |
643 ifTrue:[ |
608 ifTrue: [ |
644 "/ 4.0 netscape |
609 "/ 4.0 netscape |
645 embeddedAppletFrame |
610 embeddedAppletFrame |
646 perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V' |
611 perform: #'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;Z)V' |
647 withArguments: |
612 withArguments: (Array |
648 (Array |
613 with: jDocumentURL |
649 with:jDocumentURL |
614 with: jCodeBaseURL |
650 with:jCodeBaseURL |
615 with: jArchiveURL |
651 with:jArchiveURL |
616 with: attributeHashTable |
652 with:attributeHashTable |
617 with: appletContext |
653 with:appletContext |
618 with: (Java as_Integer: id) |
654 with:(Java as_Integer:id) |
619 with: 0). |
655 with:0 "/ reloadClasses-boolean |
620 |
656 ). |
621 "/ reloadClasses-boolean |
657 ] ifFalse:[ |
622 ] |
658 (embeddedAppletFrame respondsTo:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V') |
623 ifFalse: [ |
659 ifTrue:[ |
624 (embeddedAppletFrame |
660 "/ 3.01 netscape |
625 respondsTo: #'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V') |
661 embeddedAppletFrame |
626 ifTrue: [ |
662 perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V' |
627 "/ 3.01 netscape |
663 with:jDocumentURL |
628 embeddedAppletFrame |
664 with:jCodeBaseURL |
629 perform: #'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;Ljava/lang/Integer;)V' |
665 with:jArchiveURL |
630 with: jDocumentURL |
666 with:attributeHashTable |
631 with: jCodeBaseURL |
667 with:appletContext |
632 with: jArchiveURL |
668 with:(Java as_Integer:id). |
633 with: attributeHashTable |
669 ] ifFalse:[ |
634 with: appletContext |
670 "/ oldStyle netscape |
635 with: (Java as_Integer: id). |
671 embeddedAppletFrame |
636 ] |
672 perform:#'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;I)V' |
637 ifFalse: [ |
673 with:jDocumentURL |
638 "/ oldStyle netscape |
674 with:jCodeBaseURL |
639 embeddedAppletFrame |
675 with:attributeHashTable |
640 perform: #'<init>(Ljava/net/URL;Ljava/net/URL;Ljava/util/Hashtable;Lnetscape/applet/MozillaAppletContext;I)V' |
676 with:appletContext |
641 with: jDocumentURL |
677 with:id. |
642 with: jCodeBaseURL |
678 ]. |
643 with: attributeHashTable |
679 ]. |
644 with: appletContext |
680 |
645 with: id. |
681 embeddedAppletFrame instVarNamed:'peer' put:peer. |
646 ]. |
682 |
647 ]. |
683 self javaPeer:peer. |
648 embeddedAppletFrame instVarNamed: 'peer' put: peer. |
684 |
649 self javaPeer: peer. |
685 ^ true |
650 ^ true |
686 |
651 |
687 "Created: / 20.10.1998 / 15:47:04 / cg" |
652 "Created: / 20.10.1998 / 15:47:04 / cg" |
688 "Modified: / 24.12.1999 / 01:38:17 / cg" |
653 "Modified: / 24.12.1999 / 01:38:17 / cg" |
689 ! ! |
654 ! ! |