Search in sources :

Example 1 with JSObject

use of netscape.javascript.JSObject in project screenbird by adamhub.

the class Launch method redirectWebPage.

/**
     * Redirects to screenbird homepage.
     */
private void redirectWebPage() {
    try {
        JSObject win = JSObject.getWindow(this);
        System.out.println("Redirecting window");
        win.call("redirectHome", new Object[] {});
        System.out.println("Redirected window");
    } catch (Exception e) {
        System.err.println(e);
        System.err.println("Window already closed");
    }
}
Also used : JSObject(netscape.javascript.JSObject)

Example 2 with JSObject

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

the class FrameFX method loadEventHandler.

private static void loadEventHandler() {
    synchronized (dumbLock) {
        Platform.runLater(() -> {
            Object o = NestedPrivate.webEngine.executeScript("window.event42");
            assert o instanceof JSObject : o.toString();
            JSObject jsobj = (JSObject) o;
            FrameFX.eventCollector = new EventCollected();
            jsobj.setMember("eventCollector", eventCollector);
            NestedPrivate.webEngine.setOnAlert(event -> {
                Alert alert = new Alert(AlertType.INFORMATION);
                alert.setTitle("Information Dialog");
                alert.setHeaderText(null);
                alert.setContentText(event.getData());
                alert.showAndWait();
            });
            //<a href="" onclick="java.add('bla');">here</a>
            synchronized (dumbLock) {
                dumbLock.notifyAll();
            }
        });
        waitForCompletion();
    }
}
Also used : JSObject(netscape.javascript.JSObject) JSObject(netscape.javascript.JSObject) Alert(javafx.scene.control.Alert)

Example 3 with JSObject

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

the class JobViewFxUtil method startFx.

public static Object startFx(Object composite, final String webUrl, Object jobUtils) {
    try {
        Class compositeClass = Class.forName("org.eclipse.swt.widgets.Composite");
        Class[] paramTypes = { compositeClass, int.class };
        Constructor con = FXCanvas.class.getConstructor(paramTypes);
        Object[] parames = { composite, 1 << 16 };
        final FXCanvas canvas = (FXCanvas) con.newInstance(parames);
        Platform.setImplicitExit(false);
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                final WebView webView = new WebView();
                Scene scene = new Scene(webView);
                canvas.setScene(scene);
                WebEngine webEngine = webView.getEngine();
                webEngine.load(webUrl);
                webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {

                    @Override
                    public void changed(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", new JobUtilsForEclipse());
                        }
                    }
                });
            }
        });
        return canvas;
    } catch (Exception e) {
        return e;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) ObservableValue(javafx.beans.value.ObservableValue) JSObject(netscape.javascript.JSObject) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine) Worker(javafx.concurrent.Worker) JSObject(netscape.javascript.JSObject) ChangeListener(javafx.beans.value.ChangeListener) FXCanvas(javafx.embed.swt.FXCanvas) WebView(javafx.scene.web.WebView)

Example 4 with JSObject

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

the class NSFieldManager method initialize.

public void initialize(Repository data, String dataPath) {
    debug("initializing...");
    // abort if we have been terminated.
    if (!isRunning)
        return;
    this.data = data;
    this.dataPath = dataPath;
    debug("get document...");
    JSObject document = (JSObject) window.getMember("document");
    debug("get forms...");
    JSObject formList = (JSObject) document.getMember("forms");
    // Build an internal list of all the elements on the form. (This
    // is necessary because otherwise Netscape 6 has a nasty habit of
    // reordering the list of elements in the form as we initialize
    // them.)
    Vector allElements = new Vector();
    if (formList != null) {
        debug("get forms.length...");
        int numForms = intValue(formList.getMember("length"));
        for (int formIdx = 0; formIdx < numForms; formIdx++) {
            debug("get a form...");
            JSObject form = (JSObject) formList.getSlot(formIdx);
            debug("get elements...");
            JSObject elementList = (JSObject) form.getMember("elements");
            debug("get elements.length...");
            int numElements = intValue(elementList.getMember("length"));
            for (int elementIdx = 0; elementIdx < numElements; elementIdx++) {
                // abort if we have been terminated
                if (!isRunning)
                    return;
                debug("add an element...");
                allElements.addElement(elementList.getSlot(elementIdx));
            }
        }
    }
    // Discard any previous input listeners
    for (int i = inputListeners.size(); i-- > 0; ) destroyInputListener(i);
    // Now walk through our list of elements and initialize them.
    for (int elemNum = 0; elemNum < allElements.size(); elemNum++) {
        // abort if we have been terminated
        if (!isRunning)
            return;
        reinititializeFormElement((JSObject) allElements.elementAt(elemNum));
    }
    debug("initialization complete.");
}
Also used : JSObject(netscape.javascript.JSObject) Vector(java.util.Vector)

Example 5 with JSObject

use of netscape.javascript.JSObject in project screenbird by adamhub.

the class Launch method closeApplet.

/**
     * Using the Javascript located on the web page which opened this applet,
     * we close the web page; thus closing the applet with it. 
     */
public boolean closeApplet() {
    try {
        JSObject win = JSObject.getWindow(this);
        System.out.println("Closing window");
        win.call("closeRecorderForm", new Object[] {});
        System.out.println("Closed window");
    } catch (Exception e) {
        System.err.println(e);
        System.err.println("Window already closed");
    }
    return false;
}
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