home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / filesbbs / os2 / fp1os2.arj / OS2 / DATA / 49 / C / 0 / F_26836 / JScriptWindowObject.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-05-15  |  6.3 KB  |  311 lines

  1. import stardiv.tools.HoldJavaEnvironment;
  2.  
  3. public class JScriptWindowObject extends JScriptFrameObject {
  4.    private static final int WINDOW_ID_DEFAULTSTATUS = 273;
  5.    private static final int WINDOW_ID_STATUS = 274;
  6.    private static final int WINDOW_ID_BLUR = 275;
  7.    private static final int WINDOW_ID_FOCUS = 276;
  8.    private static final int WINDOW_ID_SCROLL = 277;
  9.    private static final int WINDOW_ID_LOCATION = 278;
  10.    private static final int WINDOW_ID_OPENER = 279;
  11.    private static final int WINDOW_ID_NAVIGATOR = 280;
  12.    private static final int WINDOW_ID_ONLOAD = 281;
  13.    private static final int WINDOW_ID_ONUNLOAD = 282;
  14.    private static final int WINDOW_ID_ONERROR = 283;
  15.    private static final int WINDOW_ID_HISTORY = 284;
  16.    private static final int WINDOW_ID_PROTOCOL = 301;
  17.    private JScriptFrameObject aOpener;
  18.  
  19.    public final void SetOpener(JScriptFrameObject var1) {
  20.       this.aOpener = var1;
  21.    }
  22.  
  23.    public final JScriptFrameObject GetOpener() {
  24.       return this.aOpener;
  25.    }
  26.  
  27.    public void ClearGlobalVariables() {
  28.       super.aNameArray = null;
  29.       super.aHistoryArray = null;
  30.       super.aIndexArray = null;
  31.       this.InitAllProps();
  32.  
  33.       try {
  34.          ((JScriptFrameObject)this).StopAllJavaScripts();
  35.       } catch (UnsatisfiedLinkError var1) {
  36.       }
  37.    }
  38.  
  39.    public String GetName() {
  40.       return "window";
  41.    }
  42.  
  43.    public JScriptWindowObject(long var1) {
  44.       super(var1);
  45.       this.SetOpener((JScriptFrameObject)null);
  46.       this.InitWinProps();
  47.    }
  48.  
  49.    protected void InitAllProps() {
  50.       if (super.aConstructorHandle != null) {
  51.          super.aConstructorHandle.CreateObjectProperties(this);
  52.       }
  53.  
  54.       ((JScriptFrameObject)this).InitFrameProps();
  55.       this.InitWinProps();
  56.    }
  57.  
  58.    private void InitWinProps() {
  59.       try {
  60.          ((JSbxObject)this).Put(new JSbxObjectProperty("defaultStatus", this, this, 273, true));
  61.          ((JSbxObject)this).Put(new JSbxObjectProperty("status", this, this, 274, true));
  62.          ((JSbxObject)this).Put(new JSbxObjectProperty("opener", this, this, 279, true));
  63.          ((JSbxObject)this).Put(new JSbxObjectProperty("location", this, this, 278, true));
  64.          ((JSbxObject)this).Put(new JSbxObjectProperty("navigator", this, this, 280, true));
  65.          ((JSbxObject)this).Put(new JSbxObjectProperty("history", this, this, 284, true));
  66.          ((JSbxObject)this).Put(new JSbxObjectProperty("onload", this, this, 281, true, true));
  67.          ((JSbxObject)this).Put(new JSbxObjectProperty("onunload", this, this, 282, true, true));
  68.          ((JSbxObject)this).Put(new JSbxObjectProperty("onerror", this, this, 283, true, true));
  69.          ((JSbxObject)this).Put(new JSbxObjectProperty("blur", this, this, 275, true, true));
  70.          ((JSbxObject)this).Put(new JSbxObjectProperty("focus", this, this, 276, true, true));
  71.          ((JSbxObject)this).Put(new JSbxObjectProperty("scroll", this, this, 277, true, true));
  72.          ((JSbxObject)this).Put(new JSbxObjectProperty("_protocol", this, this, 301, true, true));
  73.       } catch (JSbxException var2) {
  74.          HoldJavaEnvironment.AddToProtocol("Exception in JScriptWindowObject()-Ctor " + var2 + " ");
  75.       }
  76.  
  77.       JavaScriptWrapperObject.InitStdObjects(this);
  78.    }
  79.  
  80.    public JSbxValue PropertyCallFunction(JSbxObjectProperty var1, JScriptCallParam var2) throws JSbxExceptionBase {
  81.       JSbxVector var3 = var2.GetParamVector();
  82.       int var4 = var3 != null ? var3.GetSize() : 0;
  83.       int var5 = var1.GetID();
  84.       String var6 = "";
  85.       double var7 = (double)0.0F;
  86.       boolean var9 = false;
  87.       boolean var10 = true;
  88.  
  89.       try {
  90.          switch (var5) {
  91.             case 275:
  92.                this.blur();
  93.                break;
  94.             case 276:
  95.                this.focus();
  96.                break;
  97.             case 277:
  98.                if (var4 > 1) {
  99.                   this.scroll((int)GetDoubleParam(var3, 0), (int)GetDoubleParam(var3, 1));
  100.                }
  101.                break;
  102.             case 301:
  103.                if (var4 > 0) {
  104.                   HoldJavaEnvironment.AddToProtocol("_protocol()=" + GetStringParam(var3, 0));
  105.                }
  106.                break;
  107.             default:
  108.                return super.PropertyCallFunction(var1, var2);
  109.          }
  110.       } catch (UnsatisfiedLinkError var12) {
  111.       }
  112.  
  113.       Object var11 = null;
  114.       JSbxValue var13;
  115.       if (var10) {
  116.          var13 = new JSbxValue();
  117.       } else if (var9) {
  118.          var13 = new JSbxValue(var7);
  119.       } else {
  120.          var13 = new JSbxValue(var6);
  121.       }
  122.  
  123.       var2.GetRuntimeParam().SetReturnValue(var13);
  124.       return var13;
  125.    }
  126.  
  127.    public void PropertyGet(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
  128.       int var3 = var1.GetID();
  129.       JSbxValue var4 = null;
  130.  
  131.       try {
  132.          switch (var3) {
  133.             case 273:
  134.                var4 = new JSbxValue(this.getDefaultStatus());
  135.                break;
  136.             case 274:
  137.                var4 = new JSbxValue(this.getStatus());
  138.                break;
  139.             case 275:
  140.             case 276:
  141.             case 277:
  142.             default:
  143.                super.PropertyGet(var1, var2);
  144.                return;
  145.             case 278:
  146.                var4 = new JSbxValue(this.getLocation());
  147.                break;
  148.             case 279:
  149.                var4 = new JSbxValue(this.GetOpener());
  150.                break;
  151.             case 280:
  152.                var4 = new JSbxValue(this.getNavigator());
  153.                break;
  154.             case 281:
  155.                var4 = new JSbxValue(this.getOnLoad());
  156.                break;
  157.             case 282:
  158.                var4 = new JSbxValue(this.getOnUnLoad());
  159.                break;
  160.             case 283:
  161.                var4 = new JSbxValue(this.getOnError());
  162.                break;
  163.             case 284:
  164.                var4 = new JSbxValue(this.getHistory());
  165.          }
  166.       } catch (UnsatisfiedLinkError var5) {
  167.       }
  168.  
  169.       if (var4 == null) {
  170.          var4 = new JSbxValue("*** not safe to inspect ***");
  171.       }
  172.  
  173.       var2.Put(var4);
  174.    }
  175.  
  176.    public void PropertyPut(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
  177.       int var3 = var1.GetID();
  178.  
  179.       try {
  180.          switch (var3) {
  181.             case 273:
  182.                this.setDefaultStatus(var2.GetString());
  183.                return;
  184.             case 274:
  185.                this.setStatus(var2.GetString());
  186.                return;
  187.             case 278:
  188.                JScriptLocationObject var4 = this.getLocation();
  189.                if (var4 != null) {
  190.                   var4.SetHref(var2.GetString());
  191.                   return;
  192.                }
  193.                break;
  194.             case 279:
  195.                this.SetOpener((JScriptFrameObject)var2.GetObject());
  196.                return;
  197.             case 281:
  198.                this.setOnLoad(var2.GetString());
  199.                return;
  200.             case 282:
  201.                this.setOnUnLoad(var2.GetString());
  202.                return;
  203.             case 283:
  204.                this.setOnError(var2.GetString());
  205.                return;
  206.             default:
  207.                super.PropertyPut(var1, var2);
  208.          }
  209.  
  210.       } catch (UnsatisfiedLinkError var5) {
  211.       }
  212.    }
  213.  
  214.    public String Property_GetJScript_typeofString(JSbxObjectProperty var1) {
  215.       return "Window";
  216.    }
  217.  
  218.    public String GetJScriptString(boolean var1) {
  219.       return "[object Window]";
  220.    }
  221.  
  222.    protected native String getDefaultStatus();
  223.  
  224.    protected native void setDefaultStatus(String var1);
  225.  
  226.    protected native String getStatus();
  227.  
  228.    protected native void setStatus(String var1);
  229.  
  230.    protected native JScriptLocationObject getLocation();
  231.  
  232.    protected native JScriptNavigatorObject getNavigator();
  233.  
  234.    protected native JScriptHistoryObject getHistory();
  235.  
  236.    protected native void blur();
  237.  
  238.    protected native void focus();
  239.  
  240.    protected native void scroll(int var1, int var2);
  241.  
  242.    protected native String getOnLoad();
  243.  
  244.    protected native void setOnLoad(String var1);
  245.  
  246.    protected native String getOnUnLoad();
  247.  
  248.    protected native void setOnUnLoad(String var1);
  249.  
  250.    protected native String getOnError();
  251.  
  252.    protected native void setOnError(String var1);
  253.  
  254.    public static double GetDoubleParam(JSbxVector var0, int var1) throws JScriptException {
  255.       JSbxValue var2 = (JSbxValue)var0.Get(var1);
  256.       if (var2 == null) {
  257.          var2 = new JSbxValue();
  258.       }
  259.  
  260.       double var3 = (double)0.0F;
  261.  
  262.       try {
  263.          var3 = var2.GetDouble();
  264.       } catch (JSbxException var5) {
  265.       }
  266.  
  267.       return var3;
  268.    }
  269.  
  270.    public static String GetStringParam(JSbxVector var0, int var1) throws JScriptException {
  271.       JSbxValue var2 = (JSbxValue)var0.Get(var1);
  272.       if (var2 == null) {
  273.          var2 = new JSbxValue();
  274.       }
  275.  
  276.       String var3 = "";
  277.  
  278.       try {
  279.          var3 = var2.GetString();
  280.       } catch (JSbxException var4) {
  281.       }
  282.  
  283.       return var3;
  284.    }
  285.  
  286.    public static boolean GetBooleanParam(JSbxVector var0, int var1) throws JScriptException {
  287.       JSbxValue var2 = (JSbxValue)var0.Get(var1);
  288.       if (var2 == null) {
  289.          var2 = new JSbxValue();
  290.       }
  291.  
  292.       boolean var3 = false;
  293.  
  294.       try {
  295.          var3 = var2.GetBool();
  296.       } catch (JSbxException var4) {
  297.       }
  298.  
  299.       return var3;
  300.    }
  301.  
  302.    public static boolean IsParamANumber(JSbxVector var0, int var1) throws JScriptException {
  303.       JSbxValue var2 = (JSbxValue)var0.Get(var1);
  304.       if (var2 != null) {
  305.          return var2.GetType() == 16;
  306.       } else {
  307.          return false;
  308.       }
  309.    }
  310. }
  311.