Search in sources :

Example 1 with HTMLEditor

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

the class HTMLEditorCustomizationSample method start.

@Override
public void start(Stage stage) {
    // create a new html editor and show it before we start modifying it.
    final HTMLEditor htmlEditor = new HTMLEditor();
    stage.setScene(new Scene(htmlEditor));
    stage.show();
    // hide controls we don't need.
    hideImageNodesMatching(htmlEditor, Pattern.compile(".*(Cut|Copy|Paste).*"), 0);
    Node seperator = htmlEditor.lookup(".separator");
    seperator.setVisible(false);
    seperator.setManaged(false);
    // modify font selections.
    int i = 0;
    for (Node candidate : (htmlEditor.lookupAll("MenuButton"))) {
        // fonts are selected by the second menu in the htmlEditor.
        if (candidate instanceof MenuButton && i == 1) {
            // limit the font selections to our predefined list.
            MenuButton menuButton = (MenuButton) candidate;
            List<MenuItem> removalList = FXCollections.observableArrayList();
            final List<MenuItem> fontSelections = menuButton.getItems();
            for (MenuItem item : fontSelections) {
                if (!limitedFonts.contains(item.getText())) {
                    removalList.add(item);
                }
            }
            fontSelections.removeAll(removalList);
            // Select a font from out limited font selection.
            // Selection done in Platform.runLater because if you try to do
            // the selection immediately, it won't take place.
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    boolean fontSelected = false;
                    for (final MenuItem item : fontSelections) {
                        if ("Comic Sans MS".equals(item.getText())) {
                            if (item instanceof RadioMenuItem) {
                                ((RadioMenuItem) item).setSelected(true);
                                fontSelected = true;
                            }
                        }
                    }
                    if (!fontSelected && fontSelections.size() > 0 && fontSelections.get(0) instanceof RadioMenuItem) {
                        ((RadioMenuItem) fontSelections.get(0)).setSelected(true);
                    }
                }
            });
        }
        i++;
    }
    // add a custom button to the top toolbar.
    Node node = htmlEditor.lookup(".top-toolbar");
    if (node instanceof ToolBar) {
        ToolBar bar = (ToolBar) node;
        ImageView graphic = new ImageView(new Image("http://bluebuddies.com/gallery/title/jpg/Smurf_Fun_100x100.jpg", 32, 32, true, true));
        graphic.setEffect(new DropShadow());
        Button smurfButton = new Button("", graphic);
        bar.getItems().add(smurfButton);
        smurfButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent arg0) {
                htmlEditor.setHtmlText("<font face='Comic Sans MS' color='blue'>Smurfs are having fun :-)</font>");
            }
        });
    }
}
Also used : HTMLEditor(javafx.scene.web.HTMLEditor)

Example 2 with HTMLEditor

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

the class ComponentClassifier method start.

@Override
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(SystemLayoutViewController.class.getResource("VoEditorView.fxml"));
    try {
        Node node = loader.load();
        // {
        //
        // ObservableList<Node> recursive = recursive(node);
        // print(recursive);
        //
        // }
        // {
        // Group group = new Group();
        //
        // // Text는 Shape클래스의 하위클래스
        // group.getChildren().add(new Text());
        // group.getChildren().add(new Button());
        // group.getChildren().add(new Button());
        // group.getChildren().add(new Label());
        // ObservableList<Node> recursive = recursive(group);
        // print(recursive);
        //
        // }
        // {
        // ScrollPane scrollPane = new ScrollPane();
        // ScrollPane scrollPane2 = new ScrollPane();
        // scrollPane2.setContent(new TextArea());
        // scrollPane.setContent(new BorderPane(scrollPane2));
        // ObservableList<Node> recursive = recursive(scrollPane);
        // print(recursive);
        // }
        {
            BorderPane borderPane = new BorderPane();
            ScrollPane scrollPane2 = new ScrollPane();
            scrollPane2.setContent(new TextArea());
            borderPane.setTop(new HBox(new Button(), new Button(), new HTMLEditor()));
            borderPane.setCenter(new BorderPane(scrollPane2));
            FxControlTreeView tv = new FxControlTreeView(borderPane);
            tv.setOnMouseClicked(event -> {
                System.out.println(tv.getSelectionModel().getSelectedItem());
            });
            Scene scene = new Scene(tv);
            primaryStage.setScene(scene);
            primaryStage.show();
        // List<Node> recursive = recursive(borderPane);
        // print(recursive);
        }
    //
    // Scene scene = new Scene((Parent) node);
    // primaryStage.setScene(scene);
    // primaryStage.show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Button(javafx.scene.control.Button) SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) Scene(javafx.scene.Scene) TextArea(javafx.scene.control.TextArea) Control(javafx.scene.control.Control) FXCollections(javafx.collections.FXCollections) Skin(javafx.scene.control.Skin) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Application(javafx.application.Application) Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) FXMLLoader(javafx.fxml.FXMLLoader) ReadOnlyProperty(javafx.beans.property.ReadOnlyProperty) Method(java.lang.reflect.Method) HBox(javafx.scene.layout.HBox) Node(javafx.scene.Node) IOException(java.io.IOException) List(java.util.List) Stream(java.util.stream.Stream) Stage(javafx.stage.Stage) FxControlTreeView(com.kyj.fx.voeditor.visual.component.FxControlTreeView) DefaultProperty(javafx.beans.DefaultProperty) HTMLEditor(javafx.scene.web.HTMLEditor) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) BorderPane(javafx.scene.layout.BorderPane) HBox(javafx.scene.layout.HBox) TextArea(javafx.scene.control.TextArea) Node(javafx.scene.Node) IOException(java.io.IOException) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) FxControlTreeView(com.kyj.fx.voeditor.visual.component.FxControlTreeView) Button(javafx.scene.control.Button) ScrollPane(javafx.scene.control.ScrollPane) HTMLEditor(javafx.scene.web.HTMLEditor)

Example 3 with HTMLEditor

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

the class HtmlEditorExam method start.

@Override
public void start(Stage stage) {
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(500);
    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(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            webEngine.loadContent(htmlEditor.getHtmlText());
        }
    });
    root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
    scene.setRoot(root);
    stage.setScene(scene);
    stage.show();
}
Also used : Group(javafx.scene.Group) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) ScrollPane(javafx.scene.control.ScrollPane) ActionEvent(javafx.event.ActionEvent) HTMLEditor(javafx.scene.web.HTMLEditor) Scene(javafx.scene.Scene) WebView(javafx.scene.web.WebView) VBox(javafx.scene.layout.VBox) WebEngine(javafx.scene.web.WebEngine)

Example 4 with HTMLEditor

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

the class FxControlsTreeViewExam method getTestNod.

Node getTestNod() {
    /* [시작] 분석하고자하는 UI구조 */
    BorderPane borderPane = new BorderPane();
    ScrollPane scrollPane2 = new ScrollPane();
    scrollPane2.setContent(new TextArea());
    borderPane.setTop(new HBox(new Button(), new Button(), new HTMLEditor()));
    borderPane.setCenter(new BorderPane(scrollPane2));
    /* [끝] 분석하고자하는 UI구조 */
    return borderPane;
}
Also used : BorderPane(javafx.scene.layout.BorderPane) HBox(javafx.scene.layout.HBox) TextArea(javafx.scene.control.TextArea) Button(javafx.scene.control.Button) ScrollPane(javafx.scene.control.ScrollPane) HTMLEditor(javafx.scene.web.HTMLEditor)

Aggregations

HTMLEditor (javafx.scene.web.HTMLEditor)4 Button (javafx.scene.control.Button)3 ScrollPane (javafx.scene.control.ScrollPane)3 Scene (javafx.scene.Scene)2 TextArea (javafx.scene.control.TextArea)2 BorderPane (javafx.scene.layout.BorderPane)2 HBox (javafx.scene.layout.HBox)2 FxControlTreeView (com.kyj.fx.voeditor.visual.component.FxControlTreeView)1 SystemLayoutViewController (com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Function (java.util.function.Function)1 Stream (java.util.stream.Stream)1 Application (javafx.application.Application)1 DefaultProperty (javafx.beans.DefaultProperty)1 ReadOnlyProperty (javafx.beans.property.ReadOnlyProperty)1 FXCollections (javafx.collections.FXCollections)1 ObservableList (javafx.collections.ObservableList)1