Search in sources :

Example 36 with WebView

use of javafx.scene.web.WebView in project phoenicis by PhoenicisOrg.

the class ApplicationPanel method populateCenter.

private void populateCenter() {
    this.appDescription = new WebView();
    this.appDescription.getEngine().loadContent("<body>" + application.getDescription() + "</body>");
    themeManager.bindWebEngineStylesheet(appDescription.getEngine().userStyleSheetLocationProperty());
    this.installers = new Label(tr("Installers"));
    this.installers.getStyleClass().add("descriptionTitle");
    this.scriptGrid = new GridPane();
    filteredScripts.addListener((InvalidationListener) change -> this.refreshScripts());
    this.refreshScripts();
    this.miniaturesPane = new HBox();
    this.miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
    this.miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
    this.miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
    for (URI miniatureUri : application.getMiniatures()) {
        Region image = new Region();
        image.getStyleClass().add("appMiniature");
        image.setStyle(String.format("-fx-background-image: url(\"%s\");", miniatureUri.toString()));
        image.prefHeightProperty().bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
        image.prefWidthProperty().bind(image.prefHeightProperty().multiply(1.5));
        miniaturesPane.getChildren().add(image);
    }
    this.center = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
    VBox.setVgrow(appDescription, Priority.ALWAYS);
    this.setCenter(center);
}
Also used : Button(javafx.scene.control.Button) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) javafx.scene.layout(javafx.scene.layout) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) InvalidationListener(javafx.beans.InvalidationListener) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Consumer(java.util.function.Consumer) ScrollPane(javafx.scene.control.ScrollPane) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) PhoenicisFilteredList(org.phoenicis.javafx.views.common.lists.PhoenicisFilteredList) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) ThemeManager(org.phoenicis.javafx.views.common.ThemeManager) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) URI(java.net.URI)

Example 37 with WebView

use of javafx.scene.web.WebView in project browsermator by pcalkins.

the class BrowserMatorFileCloud method ShowHTMLWindow.

public void ShowHTMLWindow(String url) {
    try {
        URLConnection connection = new URL(url).openConnection();
        connection.setDoOutput(true);
        BufferedReader in = new BufferedReader(new InputStreamReader(((HttpURLConnection) connection).getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) HTML_TO_SEND += inputLine;
        in.close();
    } catch (Exception ex) {
        HTML_TO_SEND = "Unable to connect to browsermator.com.";
        System.out.println("Exception browsing cloud: " + ex.toString());
        LoadingLabel.setVisible(false);
    }
    // String HTML_TO_SEND = HTML;
    Platform.runLater(new Runnable() {

        @Override
        public void run() {
            browser2 = new WebView();
            webEngine = browser2.getEngine();
            webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {

                @Override
                public void changed(ObservableValue ov, State oldState, State newState) {
                    if (newState == Worker.State.SUCCEEDED) {
                        JavaApp appREF = new JavaApp(webEngine);
                        JSObject win = (JSObject) webEngine.executeScript("window");
                        win.setMember("app", appREF);
                    }
                }
            });
            if (HTML_TO_SEND == "Unable to connect to browsermator.com.") {
                webEngine.loadContent(HTML_TO_SEND);
            } else {
                webEngine.load(url);
            }
            Scene scene = new Scene(browser2);
            fxPanel.setScene(scene);
            LoadingLabel.setVisible(false);
            webEngine.locationProperty().addListener(new ChangeListener<String>() {

                @Override
                public void changed(ObservableValue<? extends String> observableValue, String oldLoc, String newLoc) {
                    if (newLoc.contains("serve_file")) {
                        String[] filename_parts = newLoc.split("\\?");
                        String[] queryvalues = filename_parts[1].split("&");
                        String[] filename_value = queryvalues[0].split("=");
                        String[] file_idvalue = queryvalues[1].split("=");
                        String[] filedate_value = queryvalues[2].split("=");
                        String file_id = file_idvalue[1];
                        String filename = filename_value[1];
                        try {
                            filename = URLDecoder.decode(filename_value[1], "UTF-8");
                        } catch (Exception ex) {
                            System.out.println("Exception when decoding HTML: " + ex.toString());
                        }
                        String file_date = filedate_value[1];
                        String extension = ".browsermation";
                        File thisFile = new File(CLOUDFOLDER + filename + extension);
                        if (thisFile.exists()) {
                            Boolean checkdate = CheckIfFileIsNew(file_date, file_id);
                            if (checkdate) {
                                try {
                                    org.apache.commons.io.FileUtils.copyURLToFile(new URL(newLoc), new File(CLOUDFOLDER + filename + extension));
                                    mainAppController.OpenFile(thisFile, false, true);
                                    UpdateCloudConfig(file_id, file_date);
                                    cloudFrame.dispose();
                                } catch (Exception x) {
                                    System.out.println("Exception downloading file" + x.toString());
                                }
                            } else {
                                mainAppController.OpenFile(thisFile, false, true);
                                // Platform.exit();
                                cloudFrame.dispose();
                            }
                        } else {
                            try {
                                org.apache.commons.io.FileUtils.copyURLToFile(new URL(newLoc), new File(CLOUDFOLDER + filename + extension));
                                UpdateCloudConfig(file_id, file_date);
                                mainAppController.OpenFile(thisFile, false, true);
                                // Platform.exit();
                                cloudFrame.dispose();
                            } catch (Exception x) {
                                System.out.println("Exception downloading file" + x.toString());
                            }
                        }
                    }
                }
            });
        }
    });
    JPanel topPanel = new JPanel();
    FlowLayout newFlow = new FlowLayout();
    topPanel.setLayout(newFlow);
    // mainApp.LoadNameAndPassword();
    mainAppController.LookUpUser(mainAppController.loginName, mainAppController.loginPassword);
    if (mainAppController.user_id > 0) {
        loginLabelText = new JLabel("Welcome " + mainAppController.loginName + " you are currently logged in. ");
        loginButton = new JButton("Switch user");
        addloginButtonActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                LoginDialogLauncher();
            }
        });
        topPanel.add(loginLabelText);
        topPanel.add(loginButton);
    } else {
        loginLabelText = new JLabel("You are not logged in. Login to view private files: ");
        // JLabel loginLabelName = new JLabel ("Name:");
        // JLabel loginLabelPassword = new JLabel ("Password:");
        // JTextField loginFieldName = new JTextField("", 10);
        // JPasswordField loginFieldPassword = new JPasswordField("",10);
        topPanel.add(loginLabelText);
        loginButton = new JButton("Login");
        addloginButtonActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                LoginDialogLauncher();
            }
        });
        // topPanel.add(loginLabelName);
        // topPanel.add(loginFieldName);
        // topPanel.add(loginLabelPassword);
        // topPanel.add(loginFieldPassword);
        topPanel.add(loginButton);
    }
    fxPanel.setVisible(true);
    fxPanel.setSize(800, 800);
    mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(topPanel, BorderLayout.NORTH);
    mainPanel.add(fxPanel, BorderLayout.CENTER);
    mainPanel.add(bottomPanel, BorderLayout.SOUTH);
    mainPanel.setVisible(true);
    cloudFrame = new JFrame("BrowserMation File Cloud");
    cloudFrame.add(mainPanel);
    cloudFrame.setSize(800, 800);
    cloudFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ObservableValue(javafx.beans.value.ObservableValue) JButton(javax.swing.JButton) JSObject(netscape.javascript.JSObject) URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) ChangeListener(javafx.beans.value.ChangeListener) WebView(javafx.scene.web.WebView) InputStreamReader(java.io.InputStreamReader) JLabel(javax.swing.JLabel) Scene(javafx.scene.Scene) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) ActionListener(java.awt.event.ActionListener) State(javafx.concurrent.Worker.State) BufferedReader(java.io.BufferedReader) File(java.io.File)

Example 38 with WebView

use of javafx.scene.web.WebView in project dwoss by gg-net.

the class ReportHtmlTryout method tryout.

@Test
public void tryout() throws InterruptedException, InvocationTargetException, MalformedURLException {
    Report report = new Report("TestReport", ALSO, _2011_10_01, _2011_10_07);
    report.setComment("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.");
    // Implicit start the platform.
    new JFXPanel();
    Platform.runLater(() -> {
        Stage stage = new Stage();
        stage.setTitle("HtmlViewer");
        WebView view = new WebView();
        view.getEngine().loadContent(Css.toHtml5WithStyle(report.toHtml()));
        BorderPane p = new BorderPane(view);
        Scene scene = new Scene(p, Color.ALICEBLUE);
        stage.setScene(scene);
        stage.showAndWait();
        complete = true;
    });
    while (!complete) {
        Thread.sleep(500);
    }
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) Report(eu.ggnet.dwoss.report.ee.entity.Report) Stage(javafx.stage.Stage) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) Test(org.junit.Test)

Example 39 with WebView

use of javafx.scene.web.WebView in project dwoss by gg-net.

the class ReportLineHtmlTryout method tryout.

@Test
public void tryout() throws InterruptedException, InvocationTargetException, MalformedURLException {
    ReportLine rl = new ReportLine();
    rl.setActual(new Date());
    rl.setContractor(TradeName.EBAY);
    rl.setContractorPartNo("123.131");
    rl.setCustomerId(12322);
    rl.setDescription("AMD E Series E-450 (1.65 Ghz), Memory (in MB): 4096, AMD Radeon HD 6000 Series" + "6320, Festplatte(n): 320GB HDD, Optische(s) Laufwerk(e): DVD Super Multi, Display:" + "15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: grau, Ausstattung:" + "Webcam, WLAN b + g + n, Kartenleser, Videokonnektor(en) : HDMI, VGA, Windows 7" + "Home Premium 64");
    rl.setDocumentIdentifier("SR_00001");
    rl.setDocumentType(DocumentType.INVOICE);
    rl.setDossierIdentifier("DW00110");
    rl.setDossierId(110);
    rl.setInvoiceAddress("Max Mustermann, Musterstrasse 22, 20031 Hamburg");
    rl.setMfgDate(new Date());
    rl.setName("Acer Aspire 5250-4504G32Mnkk (NX.RJYED.004)");
    rl.setPartNo("LX.AAA12.312");
    rl.setPositionType(PositionType.UNIT);
    rl.setProductBrand(TradeName.ACER);
    rl.setProductGroup(ProductGroup.NOTEBOOK);
    rl.setProductName("Aspire 5250-4504G32Mnkk");
    rl.setRefurbishId("13213");
    rl.setReportingDate(new Date());
    rl.setSalesChannel(SalesChannel.RETAILER);
    rl.setSerial("AAAAABBBABABABADFSA23423");
    // Implicit start the platform.
    new JFXPanel();
    Platform.runLater(() -> {
        Stage stage = new Stage();
        stage.setTitle("HtmlViewer");
        WebView view = new WebView();
        view.getEngine().loadContent(Css.toHtml5WithStyle(rl.toHtml()));
        BorderPane p = new BorderPane(view);
        Scene scene = new Scene(p, Color.ALICEBLUE);
        stage.setScene(scene);
        stage.showAndWait();
        complete = true;
    });
    while (!complete) {
        Thread.sleep(500);
    }
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Stage(javafx.stage.Stage) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) Date(java.util.Date) Test(org.junit.Test)

Example 40 with WebView

use of javafx.scene.web.WebView in project POL-POM-5 by PlayOnLinux.

the class ApplicationInformationPanelSkin method initialise.

/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final WebView appDescription = new WebView();
    appDescription.getEngine().userStyleSheetLocationProperty().bind(getControl().webEngineStylesheetProperty());
    VBox.setVgrow(appDescription, Priority.ALWAYS);
    getControl().applicationProperty().addListener((Observable invalidation) -> updateDescription(appDescription));
    updateDescription(appDescription);
    final Label installers = new Label(tr("Installers"));
    installers.getStyleClass().add("descriptionTitle");
    final GridPane scriptGrid = new GridPane();
    filteredScripts.addListener((InvalidationListener) change -> updateScripts(scriptGrid));
    getControl().showScriptSourceProperty().addListener((Observable invalidation) -> updateScripts(scriptGrid));
    updateScripts(scriptGrid);
    final HBox miniaturesPane = new HBox();
    miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
    Bindings.bindContent(miniaturesPane.getChildren(), miniatures);
    final ScrollPane miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
    miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
    miniatureHeight.bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
    final VBox container = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
    getChildren().add(container);
    // ensure that the content of the details panel changes when the to be shown application changes
    getControl().applicationProperty().addListener((Observable invalidation) -> updateApplication());
    // initialise the content of the details panel correct
    updateApplication();
}
Also used : Button(javafx.scene.control.Button) OperatingSystem(org.phoenicis.entities.OperatingSystem) javafx.scene.layout(javafx.scene.layout) MappedList(org.phoenicis.javafx.collections.MappedList) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Bindings(javafx.beans.binding.Bindings) InvalidationListener(javafx.beans.InvalidationListener) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) ScrollPane(javafx.scene.control.ScrollPane) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Value(org.graalvm.polyglot.Value) FilteredList(javafx.collections.transformation.FilteredList) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) ApplicationInformationPanel(org.phoenicis.javafx.components.application.control.ApplicationInformationPanel) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Platform(javafx.application.Platform) Installer(org.phoenicis.scripts.Installer) ImageView(javafx.scene.image.ImageView) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) OperatingSystemFetcher(org.phoenicis.tools.system.OperatingSystemFetcher) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) Observable(javafx.beans.Observable)

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