home *** CD-ROM | disk | FTP | other *** search
- package netscape.applet;
-
- import java.applet.Applet;
- import java.applet.AppletContext;
- import java.applet.AppletStub;
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Frame;
- import java.awt.Window;
- import java.io.PrintStream;
- import java.net.URL;
- import java.util.Hashtable;
- import java.util.Vector;
-
- class DerivedAppletFrame extends EmbeddedAppletFrame implements AppletStub, Runnable, AppletPeer {
- Integer appletID;
- // $FF: renamed from: eq netscape.applet.EventQueue
- EventQueue field_0;
- boolean isAlive;
- boolean isModal;
- Vector topLevelWindows;
- long timestamp;
- boolean inHistory = false;
- URL documentURL;
- URL codebaseURL;
- URL archiveURL;
- Hashtable atts;
- Applet applet;
- int status;
- Thread handler;
- AppletHook hook;
- static final int NULL_EVENT = -1;
- static final int APPLET_DISPOSE = 0;
- static final int APPLET_LOAD = 1;
- static final int APPLET_INIT = 2;
- static final int APPLET_START = 3;
- static final int APPLET_STOP = 4;
- static final int APPLET_DESTROY = 5;
- static final int APPLET_RESIZE = 51234;
- Dimension appletSize = new Dimension(100, 100);
- AppletClassLoader classLoader;
- boolean reloadClasses = false;
- String appletName;
- String currentStatus = "";
- boolean noisy = true;
- String errorReason;
-
- DerivedAppletFrame(URL var1, URL var2, URL var3, Hashtable var4, MozillaAppletContext var5, Integer var6, boolean var7) {
- this.appletID = var6;
- super.pData = var6;
- super.context = var5;
- this.documentURL = var1;
- this.codebaseURL = var2;
- this.archiveURL = var3;
- this.atts = var4;
- ((Container)this).setLayout(new BorderLayout());
- String var8 = this.getParameter("width");
- if (var8 != null) {
- this.appletSize.width = Integer.valueOf(var8);
- }
-
- var8 = this.getParameter("height");
- if (var8 != null) {
- this.appletSize.height = Integer.valueOf(var8);
- }
-
- this.field_0 = new EventQueue();
- this.topLevelWindows = new Vector();
- this.isAlive = true;
- this.isModal = true;
- this.reloadClasses = var7;
- }
-
- void destroy() {
- if (this.status != 0) {
- if (MozillaAppletContext.debug >= 7) {
- System.out.println("# Destroying AppletFrame without disposing: " + this);
- }
-
- ((Frame)this).dispose();
- }
-
- super.destroy();
- this.appletID = null;
- if (this.field_0 != null) {
- this.field_0.destroy();
- }
-
- this.field_0 = null;
- this.topLevelWindows = null;
- this.documentURL = null;
- this.codebaseURL = null;
- this.archiveURL = null;
- this.atts = null;
- this.applet = null;
- this.handler = null;
- this.hook = null;
- this.appletSize = null;
- this.classLoader = null;
- this.appletName = null;
- this.currentStatus = null;
- this.errorReason = null;
- }
-
- protected void finalize() {
- this.destroy();
- }
-
- void dumpState(PrintStream var1, int var2) {
- MozillaAppletContext.indent(var1, var2);
- var1.println("EmbeddedAppletFrame id=" + super.pData + " applet=" + this.applet);
- }
-
- String statusToString(int var1) {
- switch (var1) {
- case 0:
- return "dispose";
- case 1:
- return "load";
- case 2:
- return "init";
- case 3:
- return "start";
- case 4:
- return "stop";
- case 5:
- return "destroy";
- default:
- return Integer.toString(var1, 10);
- }
- }
-
- public Dimension minimumSize() {
- return new Dimension(this.appletSize.width, this.appletSize.height);
- }
-
- public Dimension preferredSize() {
- return this.minimumSize();
- }
-
- public void requestShutdown() {
- this.field_0.sendEvent(new AppletEvent(4));
- this.field_0.sendEvent(new AppletEvent(5));
- this.field_0.sendEvent(new AppletEvent(0));
- }
-
- public void start() {
- SecurityManager.enablePrivilege("UniversalThreadAccess");
- SecurityManager.enablePrivilege("UniversalThreadGroupAccess");
- this.handler = new Thread(new AppletThreadGroup("applet-" + this.atts.get("code"), this), this);
- SecurityManager.revertPrivilege();
- this.handler.start();
- }
-
- public void run() {
- String var1 = null;
- if (this.getParameter("mayscript") != null) {
- var1 = this.documentURL.toString();
- }
-
- this.classLoader = AppletClassLoader.getClassLoader(super.context, this.codebaseURL, this.archiveURL, var1, this.reloadClasses);
-
- while(this.isAlive && this.isModal) {
- NEvent var2;
- try {
- var2 = this.field_0.getNextEvent();
- } catch (Exception var21) {
- this.showAppletException(var21, "interrupted, bailing out...");
- return;
- }
-
- try {
- switch (var2.eventId) {
- case 0:
- if (this.status == 1) {
- this.status = 0;
- ((Container)this).remove(this.applet);
- this.applet = null;
- this.rightState("disposed");
- ((Frame)this).dispose();
- Vector var35 = this.topLevelWindows;
- synchronized(var35){}
-
- try {
- for(int var6 = this.topLevelWindows.size(); var6 > 0; --var6) {
- ((Window)this.topLevelWindows.elementAt(var6 - 1)).dispose();
- }
- } catch (Throwable var30) {
- throw var30;
- }
-
- this.isAlive = false;
- return;
- }
-
- this.wrongState("can't dispose", "applet not destroyed");
- break;
- case 1:
- if (this.status != 0) {
- this.wrongState("can't load", "not disposed");
- } else {
- String var3 = this.getParameter("code");
- if (var3.endsWith(".class")) {
- var3 = var3.substring(0, var3.length() - 6).replace('/', '.');
- }
-
- if (var3.endsWith(".java")) {
- var3 = var3.substring(0, var3.length() - 5).replace('/', '.');
- }
-
- try {
- Class var4 = Class.forName("java.applet.Applet");
- Class var5 = this.classLoader.loadClass(var3);
- if (!var4.isAssignableFrom(var5)) {
- throw new ClassCastException(var3 + " is not an applet");
- }
-
- this.applet = (Applet)var5.newInstance();
- } catch (VerifyError var22) {
- this.showAppletException(var22, "class " + ((Throwable)var22).getMessage() + " got a security violation: method verification error");
- continue;
- } catch (SecurityException var23) {
- this.showAppletException(var23, "class " + var3 + " got a security violation: " + ((Throwable)var23).getMessage());
- continue;
- } catch (ClassNotFoundException var24) {
- this.showAppletException(var24, "class " + var3 + " not found");
- continue;
- } catch (InstantiationException var25) {
- this.showAppletException(var25, "class " + var3 + " can't be instantiated");
- continue;
- } catch (IllegalAccessException var26) {
- this.showAppletException(var26, "class " + var3 + " is not public or has no public constructor");
- continue;
- } catch (Exception var27) {
- this.showAppletException(var27, "exception: " + ((Throwable)var27).toString());
- continue;
- } catch (ThreadDeath var28) {
- this.showAppletStatus("killed");
- return;
- } catch (Error var29) {
- this.showAppletException(var29, "error: " + ((Throwable)var29).toString());
- continue;
- }
-
- this.applet.setStub(this);
- this.applet.hide();
- ((Container)this).add("Center", this.applet);
- this.status = 1;
- this.rightState("loaded");
- ((Container)this).validate();
- }
- break;
- case 2:
- if (this.status != 1) {
- this.wrongState("can't init", "applet not loaded");
- } else {
- ((Window)this).pack();
- ((Window)this).show();
- this.applet.resize(this.appletSize);
- AppletDebugger.aboutToInit(this.applet);
- this.applet.init();
- ((Container)this).validate();
- this.status = 2;
- this.rightState("initialized");
- }
- break;
- case 3:
- if (this.status != 2) {
- this.wrongState("can't start", "applet not initialized");
- } else {
- this.status = 3;
- this.timestamp = System.currentTimeMillis();
- this.applet.resize(this.appletSize.width, this.appletSize.height);
- this.applet.start();
- this.applet.show();
- ((Container)this).validate();
- super.context.mochaOnLoad(0);
- this.rightState("running");
- }
- break;
- case 4:
- if (this.status != 3) {
- this.wrongState("can't stop", "applet not started");
- } else {
- this.status = 2;
- this.timestamp = System.currentTimeMillis();
- this.applet.hide();
- SecurityManager.enablePrivilege("UniversalThreadAccess");
- this.applet.stop();
- SecurityManager.revertPrivilege();
- this.rightState("stopped");
- }
- break;
- case 5:
- if (this.status != 2) {
- this.wrongState("can't destroy", "applet not stopped");
- } else {
- this.status = 1;
- SecurityManager.enablePrivilege("UniversalThreadAccess");
- this.applet.destroy();
- SecurityManager.revertPrivilege();
- ((Component)this).hide();
- this.rightState("destroyed");
- }
- break;
- case 20:
- var2.processEvent();
- case 51234:
- }
- } catch (SecurityException var31) {
- this.showAppletException(var31, "security violation: " + ((Throwable)var31).getMessage());
- } catch (Exception var32) {
- this.showAppletException(var32, "exception: " + ((Throwable)var32).toString());
- } catch (ThreadDeath var33) {
- this.showAppletStatus("killed");
- return;
- } catch (Error var34) {
- this.showAppletException(var34, "error: " + ((Throwable)var34).toString());
- }
- }
-
- }
-
- public boolean isActive() {
- return this.status == 3;
- }
-
- public String getParameter(String var1) {
- return this.atts != null ? (String)this.atts.get(var1.toLowerCase()) : null;
- }
-
- public URL getDocumentBase() {
- return this.documentURL;
- }
-
- public URL getCodeBase() {
- return this.codebaseURL;
- }
-
- public AppletContext getAppletContext() {
- return super.context;
- }
-
- public void appletResize(int var1, int var2) {
- this.appletSize.width = var1;
- this.appletSize.height = var2;
- ((Component)this).postEvent(new Event(this, 51234, this.preferredSize()));
- }
-
- public void setAppletSize(int var1, int var2, int var3, int var4) {
- }
-
- public String getAppletName() {
- if (this.appletName == null) {
- try {
- if (this.applet != null) {
- this.appletName = this.applet.getParameter("name");
- if (this.appletName == null) {
- this.appletName = this.applet.getClass().getName().toString();
- }
- } else {
- this.appletName = this.getParameter("code");
- int var1 = this.appletName.lastIndexOf(".class");
- if (var1 != -1) {
- this.appletName = this.appletName.substring(0, var1);
- }
- }
- } catch (Exception var2) {
- this.appletName = "?";
- }
- }
-
- return this.appletName;
- }
-
- protected void showAppletStatus(String var1) {
- String var2 = this.getAppletName();
- this.currentStatus = "Applet " + var2 + " " + var1;
- this.getAppletContext().showStatus(this.currentStatus);
- if (MozillaAppletContext.debug >= 1) {
- System.err.println("# " + this.currentStatus);
- }
-
- }
-
- protected void showAppletLog(String var1) {
- if (this.noisy) {
- String var2;
- if (this.applet == null) {
- var2 = "# Applet log: " + var1;
- } else {
- String var3 = this.getAppletName();
- var2 = "# Applet " + var3 + " " + " log: " + var1;
- }
-
- System.err.println(var2);
- }
-
- }
-
- protected void rightState(String var1) {
- this.errorReason = null;
- this.showAppletStatus(var1);
- }
-
- protected void wrongState(String var1, String var2) {
- this.showAppletStatus(var1 + ": " + (this.errorReason != null ? this.errorReason : var2));
- if (MozillaAppletContext.debug >= 7) {
- System.err.println("# status=" + this.status);
- }
-
- }
-
- protected void showAppletException(Throwable var1, String var2) {
- if (this.noisy) {
- super.context.mochaOnLoad(-1);
- if (var2 == null) {
- var2 = var1.toString();
- }
-
- this.errorReason = var2;
- System.err.println("# Applet exception: " + var2);
- var1.printStackTrace();
- this.showAppletStatus(var2);
- }
-
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- this.getAppletContext().showStatus(this.currentStatus);
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- this.getAppletContext().showStatus("");
- return true;
- }
-
- EventQueue getEventQueue() {
- return this.field_0;
- }
-
- public Thread getAppletThread() {
- return this.handler;
- }
-
- public void sendEvent(NEvent var1) {
- this.field_0.sendEvent(var1);
- }
-
- public void enterModal() {
- this.run();
- this.isModal = true;
- }
-
- public void exitModal() {
- this.isModal = false;
- }
-
- public void addTopLevelWindow(Window var1) {
- Vector var2 = this.topLevelWindows;
- synchronized(var2){}
-
- try {
- if (var1 != this) {
- this.topLevelWindows.addElement(var1);
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public void removeTopLevelWindow(Window var1) {
- Vector var2 = this.topLevelWindows;
- synchronized(var2){}
-
- try {
- if (var1 != this) {
- this.topLevelWindows.removeElement(var1);
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public void removeEvents(Object var1) {
- this.field_0.removeEvents(var1);
- }
-
- public void coalesceEvent(NEvent var1) {
- this.field_0.coalesceEvent(var1);
- }
- }
-