Package org.apache.batik.script

Examples of org.apache.batik.script.Window


                                  Scriptable thisObj,
                                  final Object[] args,
                                  Function funObj) {
        int len = args.length;
        WindowWrapper ww = (WindowWrapper)thisObj;
        final Window window = ww.window;
        if (len < 2) {
            throw Context.reportRuntimeError("invalid argument count");
        }

        AccessControlContext acc =
            ((RhinoInterpreter)window.getInterpreter()).getAccessControlContext();

        Object ret = AccessController.doPrivileged( new PrivilegedAction() {
                public Object run() {
                    return window.parseXML
                        ((String)Context.jsToJava(args[0], String.class),
                         (Document)Context.jsToJava(args[1], Document.class));
                }
            }, acc);
        return Context.toObject(ret, thisObj);
View Full Code Here


                              Scriptable thisObj,
                              final Object[] args,
                              Function funObj) {
        int len = args.length;
        WindowWrapper ww = (WindowWrapper)thisObj;
        final Window window = ww.window;
        if (len < 2) {
            throw Context.reportRuntimeError("invalid argument count");
        }
        RhinoInterpreter interp =
            (RhinoInterpreter)window.getInterpreter();
        final String uri = (String)Context.jsToJava(args[0], String.class);
        Window.URLResponseHandler urlHandler = null;
        if (args[1] instanceof Function) {
            urlHandler = new GetURLFunctionWrapper
                (interp, (Function)args[1], ww);
        } else {
            urlHandler = new GetURLObjectWrapper
                (interp, (NativeObject)args[1], ww);
        }
        final Window.URLResponseHandler fw = urlHandler;

        AccessControlContext acc =
            ((RhinoInterpreter)window.getInterpreter()).getAccessControlContext();

        if (len == 2) {
            AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run(){
                        window.getURL(uri, fw);
                        return null;
                    }
                }, acc);
        } else {
            AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        window.getURL
                            (uri, fw,
                             (String)Context.jsToJava(args[2], String.class));
                        return null;
                    }
                }, acc);
View Full Code Here

                               Scriptable thisObj,
                               final Object[] args,
                               Function funObj) {
        int len = args.length;
        WindowWrapper ww = (WindowWrapper)thisObj;
        final Window window = ww.window;
        if (len < 3) {
            throw Context.reportRuntimeError("invalid argument count");
        }
        RhinoInterpreter interp =
            (RhinoInterpreter)window.getInterpreter();
        final String uri     = (String)Context.jsToJava(args[0], String.class);
        final String content = (String)Context.jsToJava(args[1], String.class);
        Window.URLResponseHandler urlHandler = null;
        if (args[2] instanceof Function) {
            urlHandler = new GetURLFunctionWrapper
                (interp, (Function)args[2], ww);
        } else {
            urlHandler = new GetURLObjectWrapper
                (interp, (NativeObject)args[2], ww);
        }
        final Window.URLResponseHandler fw = urlHandler;

        AccessControlContext acc;
        acc = interp.getAccessControlContext();

        switch (len) {
        case 3:
            AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run(){
                        window.postURL(uri, content, fw);
                        return null;
                    }
                }, acc);
            break;
        case 4:
            AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        window.postURL
                            (uri, content, fw,
                             (String)Context.jsToJava(args[3], String.class));
                        return null;
                    }
                }, acc);
            break;
        default:
            AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        window.postURL
                            (uri, content, fw,
                             (String)Context.jsToJava(args[3], String.class),
                             (String)Context.jsToJava(args[4], String.class));
                        return null;
                    }
View Full Code Here

                             Scriptable thisObj,
                             Object[] args,
                             Function funObj) {
        int len = args.length;
        WindowWrapper ww = (WindowWrapper)thisObj;
        Window window = ww.window;
        if (len >= 1) {
            String message =
                (String)Context.jsToJava(args[0], String.class);
            window.alert(message);
        }
    }
View Full Code Here

                                  Scriptable thisObj,
                                  Object[] args,
                                  Function funObj) {
        int len = args.length;
        WindowWrapper ww = (WindowWrapper)thisObj;
        Window window = ww.window;
        if (len >= 1) {
            String message =
                (String)Context.jsToJava(args[0], String.class);
            if (window.confirm(message))
                return Context.toObject(Boolean.TRUE, thisObj);
            else
                return Context.toObject(Boolean.FALSE, thisObj);
        }
        return Context.toObject(Boolean.FALSE, thisObj);
View Full Code Here

                                Scriptable thisObj,
                                Object[] args,
                                Function funObj) {

        WindowWrapper ww = (WindowWrapper)thisObj;
        Window window = ww.window;
        Object result;
        switch (args.length) {
            case 0:
                result = "";
                break;
            case 1:
                String message =
                    (String)Context.jsToJava(args[0], String.class);
                result = window.prompt(message);
                break;
            default:
                message =
                    (String)Context.jsToJava(args[0], String.class);
                String defVal =
                    (String)Context.jsToJava(args[1], String.class);
                result = window.prompt(message, defVal);
                break;
        }

        if (result == null) {
            return null;
View Full Code Here

        // Nota: si se quiere capturar posibles excepciones Java desde JavaScript, hacer
        // un try{ }catch(e) { if (e.javaException) ... } en donde javaException es el objeto Exception Java
        // si se hace e.javaException.printStackTrace(); saldrá por la consola.

        Window window = WindowWrapperUtil.getWindow(winWrapper);

        URL url = null;
        try { url = new URL(doc.getDocumentURI()); } // La inspección del código fuente de Batik muestra que el RhinoInterpreter es creado usando este URL
        catch(MalformedURLException ex) { ex.printStackTrace(); new RuntimeException(ex); }
View Full Code Here

    }

    public void executeJSCode(String code)
    {
        // El código a ejecutar es que está en un link
        Window win = WindowWrapperUtil.getWindow(winWrapper);
        RhinoInterpreterFixed interpreter = (RhinoInterpreterFixed)win.getInterpreter();
        interpreter.evaluateString(winWrapper,code);
    }
View Full Code Here

    }

    public void executeJSCode(String code)
    {
        // El código a ejecutar es que está en un link
        Window win = WindowWrapperUtil.getWindow(winWrapper);
        RhinoInterpreterFixed interpreter = (RhinoInterpreterFixed)win.getInterpreter();
        interpreter.evaluateString(winWrapper,code);
    }
View Full Code Here

                                     Scriptable thisObj,
                                     Object[] args,
                                     Function funObj)
        throws JavaScriptException {
        int len = args.length;
        Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
        if (len < 2) {
            throw Context.reportRuntimeError("invalid argument count");
        }
        long to = ((Long)Context.toType(args[1], Long.TYPE)).longValue();
        if (args[0] instanceof Function) {
            RhinoInterpreter interp =
                (RhinoInterpreter)window.getInterpreter();
            FunctionWrapper fw;
            fw = new FunctionWrapper(interp, (Function)args[0],
                                     EMPTY_ARGUMENTS);
            return window.setInterval(fw, to);
        }
        String script =
    (String)Context.toType(args[0], String.class);
        return window.setInterval(script, to);
    }
View Full Code Here

TOP

Related Classes of org.apache.batik.script.Window

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.