netscape.javascript.JSException Java Examples

The following examples show how to use netscape.javascript.JSException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DevToolsDebuggerJsBridge.java    From Javafx-WebView-Debugger with MIT License 6 votes vote down vote up
/**
 * Inject JSBridge and initialize the JavaScript helper
 * <p>
 * Call when engine transitions state to READY after a page load is started in WebView or requested
 * by Chrome dev tools.
 * <p>
 * This means after either the {@link #pageReloading()} is called or {@link #pageReloadStarted()}
 * is invoked to inform of page reloading operation.
 */
public void connectJsBridge() {
    JSObject jsObject = (JSObject) myWebView.getEngine().executeScript("window");
    jsObject.setMember("__MarkdownNavigatorArgs", myJfxScriptArgAccessor); // this interface stays for the duration, does not give much
    jsObject.setMember("__MarkdownNavigator", getJfxDebugProxyJsBridge()); // this interface is captured by the helper script since incorrect use can bring down the whole app
    try {
        if (mySuppressNoMarkdownException) {
            myWebView.getEngine().executeScript("var markdownNavigator; markdownNavigator && markdownNavigator.setJsBridge(window.__MarkdownNavigator);");
        } else {
            myWebView.getEngine().executeScript("markdownNavigator.setJsBridge(window.__MarkdownNavigator);");
        }
    } catch (JSException e) {
        e.printStackTrace();
        LOG.warn("jsBridgeHelperScript: exception", e);
    }
    jsObject.removeMember("__MarkdownNavigator");
}
 
Example #2
Source File: MdConvertController.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the vertical scroll value, i.e. thumb position. This is
 * equivalent to {@link javafx.scene.control.ScrollBar#getValue()}.
 *
 * @param view web view that shall be scrolled
 * @return vertical scroll value
 */
public int getVScrollValue(WebView view) {
    try {
        return (Integer) view.getEngine().executeScript("document.body.scrollTop");
    }
    catch(JSException e) {
        logger.trace(e.getMessage(), e);
        return 0;
    }
}
 
Example #3
Source File: MdConvertController.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the horizontal scroll value, i.e. thumb position. This is
 * equivalent to {@link javafx.scene.control.ScrollBar#getValue()}.
 *
 * @param view
 * @return horizontal scroll value
 */
public int getHScrollValue(WebView view) {
    try {
        return (Integer) view.getEngine().executeScript("document.body.scrollLeft");
    }
    catch(JSException e) {
        logger.trace(e.getMessage(), e);
        return 0;
    }
}
 
Example #4
Source File: Distance.java    From GMapsFX with Apache License 2.0 5 votes vote down vote up
public Double getValue(){
    try{
        return (1.0 * (Integer) getJSObject().getMember("value"));
    } catch(JSException | NumberFormatException e){
        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "", e);
    }
    return null;
}
 
Example #5
Source File: Distance.java    From GMapsFX with Apache License 2.0 5 votes vote down vote up
public String getText(){
    try{
        return (String) getJSObject().getMember("text");
    } catch(JSException | NumberFormatException e){
        Logger.getLogger(this.getClass().getName()).log(Level.FINE, "", e);
    }
    return null;
}
 
Example #6
Source File: JSObjectProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Return a JSObject for the window containing the given applet.
 * Implementations of this class should return null if not connected to a
 * browser, for example, when running in AppletViewer.
 *
 * @param applet The applet.
 * @return JSObject for the window containing the given applet or null if we
 * are not connected to a browser.
 * @throws JSException when an error is encountered.
 */
public JSObject getWindow(Applet applet) throws JSException;