Search in sources :

Example 21 with WebView

use of javafx.scene.web.WebView 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 22 with WebView

use of javafx.scene.web.WebView in project Retrospector by NonlinearFruit.

the class Cheatsheet method start.

@Override
public void start(Stage primaryStage) {
    WebView web = new WebView();
    //        web.getEngine().load(getClass().getResource("web/materialtable.css").toExternalForm());
    String webContent = new PumpkinEater("Search Cheatsheet", new String[] { "Symbol", "Name", "Example", "Explanation" }, new String[] { ":", "and", "lord:rings", "contains 'lord' and 'rings'" }, new String[] { "|", "or", "Marvel|DC", "contains 'marvel' or 'dc'" }, new String[] { "!", "not", "!rebecca black", "contains no 'rebecca black'" }, new String[] { "`", "cmd", "[See Below]", "[See Below]" }, new String[] { "`T", "title", "`T~civil war", "title contains 'civil war'" }, new String[] { "`C", "creator", "`C=BBC", "creator equals 'bbc'" }, new String[] { "`S", "season", "`S=1", "season equals '1'" }, new String[] { "`E", "episode", "`E~13", "episode contains '13'" }, new String[] { "`A", "category", "`A~Book", "category contains 'book'" }, new String[] { "Example", "-->", "batman|superman:`A=Movie:!vs", "contains 'batman' or 'superman',<br>category equals 'movie' and<br>contains no 'vs'" }, new String[] { "Example", "-->", "sherlock:doyle:baskervilles", "contains 'sherlock',<br>contains 'doyle' and<br>contains 'baskervilles'" }).getHtml();
    web.getEngine().loadContent(webContent);
    StackPane root = new StackPane(web);
    Scene scene = new Scene(root, 800, 600);
    primaryStage.setTitle("Search Cheatsheet");
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : PumpkinEater(retrospector.util.PumpkinEater) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 23 with WebView

use of javafx.scene.web.WebView in project jabref by JabRef.

the class MathSciNetPaneView method getPane.

StackPane getPane() {
    StackPane root = new StackPane();
    ProgressIndicator progress = new ProgressIndicator();
    progress.setMaxSize(100, 100);
    WebView browser = new WebView();
    // Quick hack to disable navigating
    browser.addEventFilter(javafx.scene.input.MouseEvent.ANY, javafx.scene.input.MouseEvent::consume);
    browser.setContextMenuEnabled(false);
    root.getChildren().addAll(browser, progress);
    mathSciNetId.getExternalURI().ifPresent(url -> browser.getEngine().load(url.toASCIIString()));
    // Hide progress indicator if finished (over 70% loaded)
    browser.getEngine().getLoadWorker().progressProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue.doubleValue() >= 0.7) {
            progress.setVisible(false);
        }
    });
    return root;
}
Also used : ProgressIndicator(javafx.scene.control.ProgressIndicator) WebView(javafx.scene.web.WebView) StackPane(javafx.scene.layout.StackPane)

Example 24 with WebView

use of javafx.scene.web.WebView in project L42 by ElvisResearchGroup.

the class Frame method initWeb.

private Void initWeb(CountDownLatch latch, JFXPanel jfxPanel, String html) {
    Group root = new Group();
    Scene scene = new Scene(root);
    WebView browser = new WebView();
    this.webEngine = browser.getEngine();
    this.webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            latch.countDown();
        }
    });
    this.webEngine.loadContent(html);
    this.webEngine.setOnAlert(event -> {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle("Information Dialog");
        alert.setHeaderText(null);
        alert.setContentText(event.getData());
        alert.showAndWait();
    });
    root.getChildren().add(browser);
    jfxPanel.setScene(scene);
    return null;
}
Also used : Group(javafx.scene.Group) Alert(javafx.scene.control.Alert) Scene(javafx.scene.Scene) WebView(javafx.scene.web.WebView)

Example 25 with WebView

use of javafx.scene.web.WebView in project Gargoyle by callakrsos.

the class MimeViewerExam method start.

@Override
public void start(Stage primaryStage) throws Exception {
    WebView center = new WebView();
    WebEngine engine = center.getEngine();
    URL resource = MimeViewerExam.class.getResource("Sample.html");
    // String externalForm = resource.toExternalForm();
    String readToString = FileUtil.readToString(resource.openStream());
    System.out.println("##########################################");
    System.out.println("mime string");
    System.out.println(readToString);
    System.out.println("##########################################");
    final MessageBuilder builder = new DefaultMessageBuilder();
    final Message message = builder.parseMessage(resource.openStream());
    Body body = ((Entity) message).getBody();
    StringBuilder sb = new StringBuilder();
    extracted(sb, body);
    Document parse = Jsoup.parse(sb.toString());
    Elements select = parse.select("img");
    select.forEach(e -> {
        String attr = e.attr("src");
        if (attr.startsWith("cid:")) {
            String cid = attr.replace("cid:", "");
            String string = meta.get(cid);
            e.attr("src", "data:image/jpg;base64,".concat(string));
        }
    });
    System.out.println("##########################################");
    System.out.println("html string");
    System.out.println(sb.toString());
    System.out.println("##########################################");
    System.out.println(parse.toString());
    engine.loadContent(sb.toString(), "text/html");
    primaryStage.setScene(new Scene(new BorderPane(center)));
    primaryStage.show();
}
Also used : Entity(org.apache.james.mime4j.dom.Entity) BorderPane(javafx.scene.layout.BorderPane) Message(org.apache.james.mime4j.dom.Message) DefaultMessageBuilder(org.apache.james.mime4j.message.DefaultMessageBuilder) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine) URL(java.net.URL) MessageBuilder(org.apache.james.mime4j.dom.MessageBuilder) DefaultMessageBuilder(org.apache.james.mime4j.message.DefaultMessageBuilder) WebView(javafx.scene.web.WebView) Body(org.apache.james.mime4j.dom.Body) TextBody(org.apache.james.mime4j.dom.TextBody) BinaryBody(org.apache.james.mime4j.dom.BinaryBody)

Aggregations

WebView (javafx.scene.web.WebView)50 Scene (javafx.scene.Scene)31 WebEngine (javafx.scene.web.WebEngine)15 BorderPane (javafx.scene.layout.BorderPane)10 Button (javafx.scene.control.Button)9 URL (java.net.URL)8 ObservableValue (javafx.beans.value.ObservableValue)7 Label (javafx.scene.control.Label)7 Tooltip (javafx.scene.control.Tooltip)7 StackPane (javafx.scene.layout.StackPane)6 VBox (javafx.scene.layout.VBox)6 Stage (javafx.stage.Stage)6 State (javafx.concurrent.Worker.State)5 JFXPanel (javafx.embed.swing.JFXPanel)5 ScrollPane (javafx.scene.control.ScrollPane)5 JFrame (javax.swing.JFrame)5 URI (java.net.URI)4 InvalidationListener (javafx.beans.InvalidationListener)4 FXCollections (javafx.collections.FXCollections)4 javafx.scene.layout (javafx.scene.layout)4