Search in sources :

Example 6 with JSObject

use of netscape.javascript.JSObject in project azure-tools-for-java by Microsoft.

the class JobViewPanel method init.

private void init(final JFXPanel panel) {
    String url = rootPath + "/com.microsoft.hdinsight/hdinsight/job/html/index.html";
    url = url.replace("\\", "/");
    final String queryString = "?projectid=" + id + "&engintype=javafx";
    final String weburl = "file:///" + url + queryString;
    Platform.setImplicitExit(false);
    Platform.runLater(() -> {
        webView = new WebView();
        webEngine = webView.getEngine();
        webEngine.setJavaScriptEnabled(true);
        webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) -> {
            if (newState == Worker.State.SUCCEEDED) {
                JSObject win = (JSObject) webEngine.executeScript("window");
                win.setMember("JobUtils", jobUtil);
            }
        });
        panel.setScene(new Scene(webView));
        if (!alreadyLoad) {
            webEngine.load(weburl);
            alreadyLoad = true;
        }
    });
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) JSObject(netscape.javascript.JSObject) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene)

Example 7 with JSObject

use of netscape.javascript.JSObject in project L42 by ElvisResearchGroup.

the class Frame method createHtmlContent.

private void createHtmlContent(JFXPanel jfxPanel, String html) {
    CountDownLatch latch = new CountDownLatch(1);
    FutureTask<Void> future = new FutureTask<Void>(() -> initWeb(latch, jfxPanel, html));
    Platform.runLater(future);
    try {
        future.get();
    } catch (ExecutionException e) {
        throw propagateException(e.getCause());
    } catch (InterruptedException e) {
        throw propagateException(e);
    }
    try {
        latch.await();
    } catch (InterruptedException e) {
        throw propagateException(e);
    }
    future = new FutureTask<Void>(() -> {
        Object o = this.webEngine.executeScript("window.event42=function(s){ if(event42.eventCollector){event42.eventCollector.add(s);return 'Event '+s+' added '+event42.eventCollector.toString();} return 'Event '+s+' not added';}");
        assert o instanceof JSObject : o.toString();
        JSObject jsobj = (JSObject) o;
        jsobj.setMember("eventCollector", this.events);
        return null;
    });
    Platform.runLater(future);
    try {
        future.get();
    } catch (ExecutionException e) {
        throw propagateException(e.getCause());
    } catch (InterruptedException e) {
        throw propagateException(e);
    }
}
Also used : FutureTask(java.util.concurrent.FutureTask) JSObject(netscape.javascript.JSObject) JSObject(netscape.javascript.JSObject) CountDownLatch(java.util.concurrent.CountDownLatch) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with JSObject

use of netscape.javascript.JSObject in project intellij-plugins by StepicOrg.

the class StudyBrowserWindow method initConsoleListener.

private void initConsoleListener() {
    engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != Worker.State.SUCCEEDED) {
            return;
        }
        JSObject window = (JSObject) engine.executeScript("window");
        window.setMember("java", bridge);
        @Language("JavaScript") String script = "console.error = function (message) {\n" + "    java.error(message);\n" + "};\n" + "console.warn = function (message) {\n" + "    java.warn(message);\n" + "};\n" + "console.log = function (message) {\n" + "    java.log(message);\n" + "};\n" + "console.debug = function (message) {\n" + "    java.debug(message);\n" + "};\n" + "window.addEventListener('error', function (e) {\n" + "    java.doError(e.filename, e.lineno, e.colno, e.message);\n" + "    return true;\n" + "});";
        engine.executeScript(script);
    });
}
Also used : Language(org.intellij.lang.annotations.Language) JSObject(netscape.javascript.JSObject)

Example 9 with JSObject

use of netscape.javascript.JSObject in project processdash by dtuma.

the class NSSelectField method getOptionValue.

private static String getOptionValue(JSObject formOptions, int idx) {
    JSObject option = (JSObject) formOptions.getSlot(idx);
    String result = (String) option.getMember("value");
    if (result == null || result.trim().length() == 0) {
        result = (String) option.getMember("text");
        if (result != null)
            result = result.trim();
    }
    return result;
}
Also used : JSObject(netscape.javascript.JSObject)

Aggregations

JSObject (netscape.javascript.JSObject)9 ObservableValue (javafx.beans.value.ObservableValue)2 Scene (javafx.scene.Scene)2 WebView (javafx.scene.web.WebView)2 Constructor (java.lang.reflect.Constructor)1 Vector (java.util.Vector)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutionException (java.util.concurrent.ExecutionException)1 FutureTask (java.util.concurrent.FutureTask)1 ChangeListener (javafx.beans.value.ChangeListener)1 Worker (javafx.concurrent.Worker)1 FXCanvas (javafx.embed.swt.FXCanvas)1 Alert (javafx.scene.control.Alert)1 WebEngine (javafx.scene.web.WebEngine)1 Language (org.intellij.lang.annotations.Language)1