javafx.scene.web.HTMLEditor Java Examples

The following examples show how to use javafx.scene.web.HTMLEditor. 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: RFXHTMLEditorTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void getText() {
    HTMLEditor editor = (HTMLEditor) getPrimaryStage().getScene().getRoot().lookup(".html-editor");
    LoggingRecorder lr = new LoggingRecorder();
    String text = "This is a test text";
    final String htmlText = "<html><font color=\"RED\"><h1><This is also content>" + text + "</h1></html>";
    List<String> attributeText = new ArrayList<>();
    Platform.runLater(() -> {
        RFXHTMLEditor rfxhtmlEditor = new RFXHTMLEditor(editor, null, null, lr);
        editor.setHtmlText(htmlText);
        rfxhtmlEditor.focusLost(null);
        attributeText.add(rfxhtmlEditor.getAttribute("text"));
    });
    new Wait("Waiting for html editor text.") {
        @Override
        public boolean until() {
            return attributeText.size() > 0;
        }
    };
    AssertJUnit.assertEquals(htmlText, attributeText.get(0));
}
 
Example #2
Source File: RFXHTMLEditorTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    HTMLEditor editor = (HTMLEditor) getPrimaryStage().getScene().getRoot().lookup(".html-editor");
    LoggingRecorder lr = new LoggingRecorder();
    String text = "This is a test text";
    final String htmlText = "<html><font color=\"RED\"><h1><This is also content>" + text + "</h1></html>";
    Platform.runLater(() -> {
        RFXHTMLEditor rfxhtmlEditor = new RFXHTMLEditor(editor, null, null, lr);
        editor.setHtmlText(htmlText);
        rfxhtmlEditor.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals(htmlText, recording.getParameters()[0]);
}
 
Example #3
Source File: JavaFXHTMLEditorTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    HTMLEditor htmlEditorNode = (HTMLEditor) getPrimaryStage().getScene().getRoot().lookup(".html-editor");
    Platform.runLater(() -> {
        htmlEditor.marathon_select("This html editor test");
    });
    try {
        new Wait("Waiting for html text to be set.") {
            @Override
            public boolean until() {
                String htmlText = htmlEditorNode.getHtmlText();
                return htmlText.equals(
                        "<html dir=\"ltr\"><head></head><body contenteditable=\"true\">This html editor test</body></html>");
            }
        };
    } catch (Throwable t) {
    }
    AssertJUnit.assertEquals(
            "<html dir=\"ltr\"><head></head><body contenteditable=\"true\">This html editor test</body></html>",
            htmlEditor.getText());
    AssertJUnit.assertEquals(
            "<html dir=\"ltr\"><head></head><body contenteditable=\"true\">This html editor test</body></html>",
            htmlEditorNode.getHtmlText());
}
 
Example #4
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(650);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final HTMLEditor htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(245);
    htmlEditor.setHtmlText(INITIAL_TEXT);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setStyle("-fx-background-color: white");
    scrollPane.setContent(browser);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Load Content in Browser");
    root.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction((ActionEvent arg0) -> {
        webEngine.loadContent(htmlEditor.getHtmlText());
    });

    root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}
 
Example #5
Source File: AnchorFX_test.java    From AnchorFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
    public void start(Stage primaryStage) {

        DockStation station = AnchorageSystem.createStation();

        Scene scene = new Scene(station, 1024, 768);
        
        DockNode node1 = AnchorageSystem.createDock("Not floatable", new HTMLEditor());
        node1.dock(station, DockNode.DockPosition.LEFT);
        node1.floatableProperty().set(false);
        
        DockNode node2 = AnchorageSystem.createDock("Not resizable", new HTMLEditor());
        node2.dock(station, DockNode.DockPosition.RIGHT);
        node2.resizableProperty().set(false);
        
      
//        DockNode node1 = AnchorageSystem.createDock("Tree", generateRandomTree());
//        node1.dock(station, DockNode.DockPosition.CENTER);
//  
//        DockNode node2 = AnchorageSystem.createDock("Editor", new HTMLEditor());
//        node2.dock(station, DockNode.DockPosition.RIGHT);
//        
//        DockNode node3 = AnchorageSystem.createDock("Below the editor", generateRandomTree());
//        node3.dock(node2, DockNode.DockPosition.BOTTOM,0.8);

        AnchorageSystem.installDefaultStyle();

        primaryStage.setTitle("AnchorFX");
        primaryStage.setScene(scene);
        primaryStage.show();
        
//        DockNode node4 = AnchorageSystem.createDock("Floating", new TableView());
//        node4.dockAsFloating(primaryStage, station, 0, 0, 400, 200);

        
        AnchorageSystem.installDefaultStyle();
    }
 
Example #6
Source File: HTMLEditorApp.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    root.getChildren().addAll(vRoot);
}
 
Example #7
Source File: RFXHTMLEditor.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void focusLost(RFXComponent next) {
    String currentText = getHTMLEditorText((HTMLEditor) node);
    if (currentText != null && !currentText.equals(prevText)) {
        recorder.recordSelect(this, currentText);
    }
}
 
Example #8
Source File: DialogHelper.java    From Notebook with Apache License 2.0 5 votes vote down vote up
public static void showArticle(String content) {
	AlertDialog alertDialog = new AlertDialog.Builder()
		.view("dialog_article_detail")
		.title("��������")
		.build();
	HTMLEditor htmlEditor = alertDialog.findView("#et_html", HTMLEditor.class);
	htmlEditor.setHtmlText(content);
	alertDialog.show();
}
 
Example #9
Source File: JavaFXElementFactory.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static void reset() {
    add(Node.class, JavaFXElement.class);
    add(TextInputControl.class, JavaFXTextInputControlElement.class);
    add(HTMLEditor.class, JavaFXHTMLEditor.class);
    add(CheckBox.class, JavaFXCheckBoxElement.class);
    add(ToggleButton.class, JavaFXToggleButtonElement.class);
    add(Slider.class, JavaFXSliderElement.class);
    add(Spinner.class, JavaFXSpinnerElement.class);
    add(SplitPane.class, JavaFXSplitPaneElement.class);
    add(ProgressBar.class, JavaFXProgressBarElement.class);
    add(ChoiceBox.class, JavaFXChoiceBoxElement.class);
    add(ColorPicker.class, JavaFXColorPickerElement.class);
    add(ComboBox.class, JavaFXComboBoxElement.class);
    add(DatePicker.class, JavaFXDatePickerElement.class);
    add(TabPane.class, JavaFXTabPaneElement.class);
    add(ListView.class, JavaFXListViewElement.class);
    add(TreeView.class, JavaFXTreeViewElement.class);
    add(TableView.class, JavaFXTableViewElement.class);
    add(TreeTableView.class, JavaFXTreeTableViewElement.class);
    add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class);
    add(ChoiceBoxListCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxListCell.class, JavaFXComboBoxCellElement.class);
    add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class);
    add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxTreeCell.class, JavaFXComboBoxCellElement.class);
    add(TableCell.class, JavaFXTableViewCellElement.class);
    add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class);
    add(ChoiceBoxTableCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxTableCell.class, JavaFXComboBoxCellElement.class);
    add(TreeTableCell.class, JavaFXTreeTableCellElement.class);
    add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class);
    add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxTreeTableCell.class, JavaFXComboBoxCellElement.class);
    add(WebView.class, JavaFXWebViewElement.class);
    add(GenericStyledArea.GENERIC_STYLED_AREA_CLASS, RichTextFXGenericStyledAreaElement.class);
}
 
Example #10
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    getChildren().addAll(vRoot);

    // REMOVE ME
    // Workaround for RT-16781 - HTML editor in full screen has wrong border
    javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
    for(javafx.scene.Node child: grid.getChildren()) {
        javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
    }
    // END REMOVE ME
}
 
Example #11
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    final VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(10);

    final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:"));

    sendTo.setPrefWidth(100);
    GridPane.setConstraints(sendTo, 0, 0);
    grid.getChildren().add(sendTo);

    final TextField tbTo = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbTo, 1, 0);
    grid.getChildren().add(tbTo);

    final Label subjectLabel = new Label("Subject:");
    GridPane.setConstraints(subjectLabel, 0, 1);
    grid.getChildren().add(subjectLabel);

    final TextField tbSubject = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbSubject, 1, 1);
    grid.getChildren().add(tbSubject);

    root.getChildren().add(grid);

    Platform.runLater(() -> {
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(370);
        root.getChildren().addAll(htmlEditor, new Button("Send"));
    });

    final Label htmlLabel = new Label();
    htmlLabel.setWrapText(true);
    getChildren().add(root);
}
 
Example #12
Source File: RFXHTMLEditor.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void focusGained(RFXComponent prev) {
    prevText = getHTMLEditorText((HTMLEditor) node);
}
 
Example #13
Source File: JavaFXHTMLEditor.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public String _getText() {
    return getHTMLEditorText((HTMLEditor) getComponent());
}
 
Example #14
Source File: RFXHTMLEditor.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public String _getText() {
    return getHTMLEditorText((HTMLEditor) node);
}
 
Example #15
Source File: JavaFXHTMLEditor.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean marathon_select(String value) {
    HTMLEditor htmlEditor = (HTMLEditor) getComponent();
    htmlEditor.setHtmlText(value);
    return true;
}
 
Example #16
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
protected String getHTMLEditorText(HTMLEditor htmlEditor) {
    return htmlEditor.getHtmlText();
}
 
Example #17
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    getChildren().addAll(vRoot);

    // REMOVE ME
    // Workaround for RT-16781 - HTML editor in full screen has wrong border
    javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
    for(javafx.scene.Node child: grid.getChildren()) {
        javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
    }
    // END REMOVE ME
}