Search in sources :

Example 1 with IDebugClient

use of com.servoy.j2db.IDebugClient in project servoy-client by Servoy.

the class DebugClientHandler method setSolution.

public void setSolution(Solution solution) {
    currentSolution = solution;
    if (debugJ2DBClient != null) {
        debugJ2DBClient.shutDownAndDispose();
        debugJ2DBClient = null;
    }
    if (debugWebClient != null) {
        debugWebClient.shutDown(true);
        debugWebClient = null;
    }
    if (debugNGClient != null) {
        debugNGClient.shutDown(true);
        debugNGClient = null;
    }
    if (debugHeadlessClient != null) {
        debugHeadlessClient.shutDown(true);
        debugHeadlessClient = null;
    }
    for (IDebugClient c : customDebugClients.values()) {
        c.shutDown(true);
    }
    customDebugClients.clear();
}
Also used : IDebugClient(com.servoy.j2db.IDebugClient)

Example 2 with IDebugClient

use of com.servoy.j2db.IDebugClient in project servoy-client by Servoy.

the class DebugClientHandler method setDesignerCallback.

/**
 * @param designerCallback the designerCallback to set
 */
public void setDesignerCallback(IDesignerCallback designerCallback) {
    this.designerCallback = designerCallback;
    if (debugJ2DBClient != null && debugJ2DBClient.getSolution() != null) {
        SolutionScope solutionScope = debugJ2DBClient.getScriptEngine().getSolutionScope();
        designerCallback.addScriptObjects(debugJ2DBClient, solutionScope);
    }
    if (debugWebClient != null && debugWebClient.getSolution() != null) {
        SolutionScope solutionScope = debugWebClient.getScriptEngine().getSolutionScope();
        designerCallback.addScriptObjects(debugWebClient, solutionScope);
    }
    if (debugNGClient != null && debugNGClient.getSolution() != null) {
        SolutionScope solutionScope = debugNGClient.getScriptEngine().getSolutionScope();
        designerCallback.addScriptObjects(debugNGClient, solutionScope);
    }
    if (debugHeadlessClient != null && debugHeadlessClient.getSolution() != null) {
        SolutionScope solutionScope = debugHeadlessClient.getScriptEngine().getSolutionScope();
        designerCallback.addScriptObjects(debugHeadlessClient, solutionScope);
    }
    for (IDebugClient c : customDebugClients.values()) {
        if (c.getSolution() != null) {
            SolutionScope solutionScope = c.getScriptEngine().getSolutionScope();
            designerCallback.addScriptObjects(c, solutionScope);
        }
    }
}
Also used : IDebugClient(com.servoy.j2db.IDebugClient) SolutionScope(com.servoy.j2db.scripting.SolutionScope)

Example 3 with IDebugClient

use of com.servoy.j2db.IDebugClient in project servoy-client by Servoy.

the class WebServiceScriptable method getScript.

private static Script getScript(Context context, URL serverScript, IApplication app) throws URISyntaxException, IOException {
    Pair<Script, Long> pair = scripts.get(serverScript.toURI());
    long lastModified = -1;
    URLConnection connection = serverScript.openConnection();
    connection.setUseCaches(false);
    if (connection instanceof JarURLConnection) {
        try (JarFile jarFile = ((JarURLConnection) connection).getJarFile()) {
            lastModified = new File(jarFile.getName()).lastModified();
        }
    } else
        lastModified = connection.getLastModified();
    if (pair == null || pair.getRight().longValue() < lastModified) {
        String name = "";
        URI uri = serverScript.toURI();
        if ("file".equals(uri.getScheme())) {
            File file = new File(uri);
            if (file.exists()) {
                name = file.getAbsolutePath();
            }
        }
        Debugger debugger = null;
        int lvl = context.getOptimizationLevel();
        Script script;
        try {
            if (app instanceof IDebugClient) {
                if ("".endsWith(name)) {
                    context.setGeneratingDebug(false);
                    debugger = context.getDebugger();
                    if (debugger != null) {
                        context.setOptimizationLevel(9);
                        context.setDebugger(null, null);
                    }
                } else if (context.getDebugger() == null) {
                    // this is a refresh/recreate forms, could be because of a server side script edit/change
                    // then the debugger is not attached because it is not the event thread. make sure that
                    // code optimization level is disabled.
                    context.setGeneratingDebug(true);
                    context.setOptimizationLevel(-1);
                }
            } else {
                // in none debug client, don't compile to a java file (classloading problems)
                // but also don't generate debug info
                context.setGeneratingDebug(false);
                context.setOptimizationLevel(-1);
            }
            context.setGeneratingSource(false);
            script = context.compileString(Utils.getURLContent(serverScript), name, 1, null);
        } finally {
            if (debugger != null) {
                context.setDebugger(debugger, null);
                context.setOptimizationLevel(lvl);
            }
        }
        pair = new Pair<Script, Long>(script, Long.valueOf(lastModified));
        scripts.put(uri, pair);
    }
    return pair.getLeft();
}
Also used : Debugger(org.mozilla.javascript.debug.Debugger) Script(org.mozilla.javascript.Script) IDebugClient(com.servoy.j2db.IDebugClient) JarURLConnection(java.net.JarURLConnection) JarFile(java.util.jar.JarFile) URI(java.net.URI) URLConnection(java.net.URLConnection) JarURLConnection(java.net.JarURLConnection) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 4 with IDebugClient

use of com.servoy.j2db.IDebugClient in project servoy-client by Servoy.

the class ConsoleObject method error.

/**
 * Report an error to the console.
 *
 * @sample
 * console.error('ERROR')
 *
 * @param value the error object
 */
@JSFunction
public void error(Object value) {
    if (app instanceof IDebugClient) {
        ((IDebugClient) app).reportToDebugger(getValueAsString(value), true);
    } else {
        EvaluatorException e = new EvaluatorException(getValueAsString(value));
        app.reportJSWarning(e.getMessage());
        app.reportJSWarning(e.getScriptStackTrace());
    }
}
Also used : IDebugClient(com.servoy.j2db.IDebugClient) EvaluatorException(org.mozilla.javascript.EvaluatorException) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 5 with IDebugClient

use of com.servoy.j2db.IDebugClient in project servoy-client by Servoy.

the class DebugClientHandler method refreshDebugClients.

public void refreshDebugClients(ITable table) {
    if (debugJ2DBClient != null && debugJ2DBClient.getSolution() != null) {
        String dataSource = debugJ2DBClient.getFoundSetManager().getDataSource(table);
        ((FoundSetManager) debugJ2DBClient.getFoundSetManager()).flushSQLSheet(dataSource);
    }
    if (debugWebClient != null && debugWebClient.getSolution() != null) {
        String dataSource = debugWebClient.getFoundSetManager().getDataSource(table);
        ((FoundSetManager) debugWebClient.getFoundSetManager()).flushSQLSheet(dataSource);
    }
    if (debugNGClient != null && debugNGClient.getSolution() != null) {
        String dataSource = debugNGClient.getFoundSetManager().getDataSource(table);
        ((FoundSetManager) debugNGClient.getFoundSetManager()).flushSQLSheet(dataSource);
    }
    if (debugHeadlessClient != null && debugHeadlessClient.getSolution() != null) {
        String dataSource = debugHeadlessClient.getFoundSetManager().getDataSource(table);
        ((FoundSetManager) debugHeadlessClient.getFoundSetManager()).flushSQLSheet(dataSource);
    }
    if (debugAuthenticator != null && debugAuthenticator.getSolution() != null) {
        String dataSource = debugAuthenticator.getFoundSetManager().getDataSource(table);
        ((FoundSetManager) debugAuthenticator.getFoundSetManager()).flushSQLSheet(dataSource);
    }
    for (IDebugClient c : customDebugClients.values()) {
        if (c.getSolution() != null) {
            String dataSource = c.getFoundSetManager().getDataSource(table);
            ((FoundSetManager) c.getFoundSetManager()).flushSQLSheet(dataSource);
        }
    }
}
Also used : FoundSetManager(com.servoy.j2db.dataprocessing.FoundSetManager) IDebugClient(com.servoy.j2db.IDebugClient)

Aggregations

IDebugClient (com.servoy.j2db.IDebugClient)5 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)1 SolutionScope (com.servoy.j2db.scripting.SolutionScope)1 File (java.io.File)1 JarURLConnection (java.net.JarURLConnection)1 URI (java.net.URI)1 URLConnection (java.net.URLConnection)1 JarFile (java.util.jar.JarFile)1 EvaluatorException (org.mozilla.javascript.EvaluatorException)1 Script (org.mozilla.javascript.Script)1 JSFunction (org.mozilla.javascript.annotations.JSFunction)1 Debugger (org.mozilla.javascript.debug.Debugger)1