X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FXWT.java;h=2eeaadf3740559358b1709098804d1491c696889;hb=3a003a2e72e4762366a00aeb8ffbd9c6fb4b11f5;hp=7c37978aa2a2b30643ebe079eaaa055ea75acf40;hpb=027607da259f292060d80e0ed90d2b0e896acd86;p=org.ibex.core.git diff --git a/src/org/xwt/XWT.java b/src/org/xwt/XWT.java index 7c37978..2eeaadf 100644 --- a/src/org/xwt/XWT.java +++ b/src/org/xwt/XWT.java @@ -38,6 +38,7 @@ public final class XWT extends JSObject { else if (name.equals("newBox")) return newBox; else if (name.equals("soap")) return soap; else if (name.equals("xmlrpc")) return xmlrpc; + else if (name.equals("origin")) return Main.origin; else if (name.equals("clipboard")) return Platform.getClipBoard(); else if (name.equals("altKeyName")) return Platform.altKeyName(); else if (name.equals("screenWidth")) return new Integer(Platform.getScreenWidth()); @@ -48,6 +49,10 @@ public final class XWT extends JSObject { else if (name.equals("saveFile")) return saveFile; else if (name.equals("saveFileAs")) return saveFileAs; else if (name.equals("utfEncode")) return utfEncode; + else if (name.equals("fileSeparator")) return File.separator; + else if (name.equals("homeDir")) return System.getProperty("user.home"); + else if (name.equals("tempDir")) return System.getProperty("java.io.tempdir"); + else if (name.equals("recursivePrintObject")) return recursivePrintObject; else if (name.equals("button")) { if (Surface.button1 && !Surface.button2 && !Surface.button3) return new Integer(1); else if (!Surface.button1 && Surface.button2 && !Surface.button3) return new Integer(1); @@ -219,7 +224,7 @@ public final class XWT extends JSObject { private static final JSFunction openFile = new JSFunction() { public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) throws JavaScriptException { - if (args == null || args.length != 1) return null; + if (args.length != 1) return null; String file = Platform.fileDialog(args[0].toString(), false); return file == null ? null : new ByteStream(file); } @@ -227,17 +232,15 @@ public final class XWT extends JSObject { private static final JSFunction saveFile = new JSFunction() { public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) throws JavaScriptException { - if (args == null || args.length != 2) return null; + if (args.length != 2) return null; if (!(args[1] instanceof ByteStream)) return null; String file = args[0].toString(); if (safeFiles.get(Platform.isCaseSensitive() ? file : file.toLowerCase()) == null) { file = Platform.fileDialog(file, true); if (file == null) return null; - System.out.println(">>" + file + "<<"); safeFiles.put(Platform.isCaseSensitive() ? file : file.toLowerCase(), new Object()); } try { - System.out.println("WRITING TO " + file); ((ByteStream)args[1]).writeTo(new FileOutputStream(file)); return null; } catch (IOException e) { @@ -250,7 +253,7 @@ public final class XWT extends JSObject { private static final JSFunction saveFileAs = new JSFunction() { public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) throws JavaScriptException { - if (args == null || args.length != 2) return null; + if (args.length != 2) return null; if (!(args[1] instanceof ByteStream)) return null; String file = args[0].toString(); file = Platform.fileDialog(file, true); @@ -274,6 +277,41 @@ public final class XWT extends JSObject { } }; + + private static void recurse(String indent, String name, Object o, Context cx) { + if (!name.equals("")) name += " : "; + + if (o == null) { + Log.log(cx.interpreterSourceFile, indent + name + ""); + + } else if (o instanceof NativeArray) { + Log.log(cx.interpreterSourceFile, indent + name + ""); + NativeArray na = (NativeArray)o; + for(int i=0; i"); + Scriptable s = (Scriptable)o; + Object[] keys = s.getIds(); + for(int i=0; i