Example usage for javafx.application HostServices showDocument

List of usage examples for javafx.application HostServices showDocument

Introduction

In this page you can find the example usage for javafx.application HostServices showDocument.

Prototype

public final void showDocument(String uri) 

Source Link

Document

Opens the specified URI in a new browser window or tab.

Usage

From source file:org.noroomattheinn.visibletesla.dialogs.VersionUpdater.java

public static boolean checkForNewerVersion(String thisVersion, Stage stage, final HostServices svcs,
        boolean experimentalOK) {

    final Versions versions = Versions.getVersionInfo(VersionsFile);
    if (versions == null)
        return false; // Missing, empty, or corrupt versions file

    List<Release> releases = versions.getReleases();

    if (releases != null && !releases.isEmpty()) {
        Release lastRelease = null;/*  www  . j  ava 2 s .  c o  m*/
        for (Release cur : releases) {
            if (cur.getInvisible())
                continue;
            if (cur.getExperimental() && !experimentalOK)
                continue;
            lastRelease = cur;
            break;
        }
        if (lastRelease == null)
            return false;
        String releaseNumber = lastRelease.getReleaseNumber();
        if (Utils.compareVersions(thisVersion, releaseNumber) < 0) {
            VBox customPane = new VBox();
            String msgText = String.format(
                    "A newer version of VisibleTesla is available:\n" + "Version: %s, Date: %tD", releaseNumber,
                    lastRelease.getReleaseDate());
            Label msg = new Label(msgText);
            Hyperlink platformLink = null;
            final URL platformURL;
            final String linkText;
            if (SystemUtils.IS_OS_MAC) {
                linkText = "Download the latest Mac version";
                platformURL = lastRelease.getMacURL();
            } else if (SystemUtils.IS_OS_WINDOWS) {
                linkText = "Download the latest Windows version";
                platformURL = lastRelease.getWindowsURL();
            } else {
                linkText = "Download the latest Generic version";
                platformURL = lastRelease.getReleaseURL();
            }
            if (platformURL != null) {
                platformLink = new Hyperlink(linkText);
                platformLink.setStyle("-fx-color: blue; -fx-text-fill: blue;");
                platformLink.setOnAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent t) {
                        svcs.showDocument(platformURL.toExternalForm());

                    }
                });
            }
            Hyperlink rnLink = new Hyperlink("Click to view the release notes");
            rnLink.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent t) {
                    svcs.showDocument(versions.getReleaseNotes().toExternalForm());

                }
            });
            customPane.getChildren().addAll(msg, rnLink);
            customPane.getChildren().add(platformLink);
            Dialogs.showCustomDialog(stage, customPane, "Newer Version Available", "Checking for Updates",
                    Dialogs.DialogOptions.OK, null);
            return true;
        }
    }
    return false;
}

From source file:org.pdfsam.App.java

@EventListener
public void openUrl(OpenUrlRequest event) {
    HostServices services = getHostServices();
    if (services != null) {
        services.showDocument(event.getUrl());
    } else {//w w  w .  ja  v  a  2  s . co m
        LOG.warn("Unable to open '{}', please copy and paste the url to your browser.", event.getUrl());
    }
}