Search in sources :

Example 11 with ScrollPane

use of javafx.scene.control.ScrollPane in project trex-stateless-gui by cisco-system-traffic-generator.

the class LogsView method buildUI.

private void buildUI() {
    contentWrapper = new ScrollPane();
    contentWrapper.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    getChildren().add(contentWrapper);
    setTopAnchor(contentWrapper, 0d);
    setLeftAnchor(contentWrapper, 0d);
    setBottomAnchor(contentWrapper, 0d);
    setRightAnchor(contentWrapper, 0d);
    logsContent = new VBox();
    logsContent.setId("logs_view");
    logsContent.heightProperty().addListener((observable, oldValue, newValue) -> contentWrapper.setVvalue((Double) newValue));
    logsContent.setSpacing(5);
    contentWrapper.setContent(logsContent);
}
Also used : ScrollPane(javafx.scene.control.ScrollPane) VBox(javafx.scene.layout.VBox)

Example 12 with ScrollPane

use of javafx.scene.control.ScrollPane in project JFoenix by jfoenixadmin.

the class JFXResponsiveHandler method scanAllNodes.

/**
	 * scans all nodes in the scene and apply the css pseduoClass to them.
	 * 
	 * @param parent stage parent node
	 * @param pseudoClass css class for certain device
	 */
private void scanAllNodes(Parent parent, PseudoClass pseudoClass) {
    parent.getChildrenUnmodifiable().addListener(new ListChangeListener<Node>() {

        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
            while (c.next()) if (!c.wasPermutated() && !c.wasUpdated())
                for (Node addedNode : c.getAddedSubList()) if (addedNode instanceof Parent)
                    scanAllNodes((Parent) addedNode, pseudoClass);
        }
    });
    for (Node component : parent.getChildrenUnmodifiable()) {
        if (component instanceof Pane) {
            ((Pane) component).getChildren().addListener(new ListChangeListener<Node>() {

                @Override
                public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
                    while (c.next()) {
                        if (!c.wasPermutated() && !c.wasUpdated()) {
                            for (Node addedNode : c.getAddedSubList()) {
                                if (addedNode instanceof Parent)
                                    scanAllNodes((Parent) addedNode, pseudoClass);
                            }
                        }
                    }
                }
            });
            //if the component is a container, scan its children
            scanAllNodes((Pane) component, pseudoClass);
        } else if (component instanceof ScrollPane) {
            ((ScrollPane) component).contentProperty().addListener((o, oldVal, newVal) -> {
                scanAllNodes((Parent) newVal, pseudoClass);
            });
            //if the component is a container, scan its children
            if (((ScrollPane) component).getContent() instanceof Parent) {
                scanAllNodes((Parent) ((ScrollPane) component).getContent(), pseudoClass);
            }
        } else if (component instanceof Control) {
            //if the component is an instance of IInputControl, add to list	        	
            ((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_EX_SMALL, pseudoClass == PSEUDO_CLASS_EX_SMALL);
            ((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_SMALL, pseudoClass == PSEUDO_CLASS_SMALL);
            ((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_MEDIUM, pseudoClass == PSEUDO_CLASS_MEDIUM);
            ((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_LARGE, pseudoClass == PSEUDO_CLASS_LARGE);
        }
    }
}
Also used : Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) ListChangeListener(javafx.collections.ListChangeListener) Stage(javafx.stage.Stage) PseudoClass(javafx.css.PseudoClass) Node(javafx.scene.Node) Control(javafx.scene.control.Control) Pane(javafx.scene.layout.Pane) Control(javafx.scene.control.Control) Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) Node(javafx.scene.Node) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane) ListChangeListener(javafx.collections.ListChangeListener)

Example 13 with ScrollPane

use of javafx.scene.control.ScrollPane in project Gargoyle by callakrsos.

the class ComponentClassifier method recursive.

/**
	 *
	 * @param node
	 * @return
	 */
List<Node> recursive(Node node) {
    List<Node> controls = new ArrayList<>();
    if (node == null) {
        return controls;
    }
    if (node instanceof Control) {
        Control c = (Control) node;
        DefaultProperty annotation = c.getClass().getAnnotation(DefaultProperty.class);
        if (annotation != null) {
            String value = annotation.value();
            try {
                Object invoke = getMethod(c, value + "Property");
                if (ReadOnlyProperty.class.isAssignableFrom(invoke.getClass())) {
                    ReadOnlyProperty prop = (ReadOnlyProperty) invoke;
                    Node bean2 = (Node) prop.getBean();
                    if (bean2 == null) {
                        return controls;
                    }
                    System.out.println("컨트롤 : " + bean2);
                    controls.add((Control) bean2);
                } else {
                    System.out.println("컨트롤 : " + c);
                    controls.add(c);
                }
            } catch (Exception e) {
                ObservableList<Node> childrenUnmodifiable = c.getChildrenUnmodifiable();
                ObservableList<Node> collect = childrenUnmodifiable.stream().flatMap(new Function<Node, Stream<Node>>() {

                    @Override
                    public Stream<Node> apply(Node t) {
                        return recursive(t).stream();
                    }
                }).collect(FXCollections::observableArrayList, (collections, item) -> collections.add(item), (collections, item) -> collections.addAll(item));
                controls.addAll(collect);
            }
        } else /*
			 * if (node instanceof ScrollPane || node instanceof TabPane) { //
			 * scrollpane, TabPane은 컨트롤요소에 추가하지않음. // controls.add(c);
			 * ObservableList<Control> recursive = recursive(((ScrollPane)
			 * node).getContent()); controls.addAll(recursive); }
			 */
        {
            controls.add(c);
            ObservableList<Node> childrenUnmodifiable = c.getChildrenUnmodifiable();
            ObservableList<Node> collect = childrenUnmodifiable.stream().flatMap(new Function<Node, Stream<Node>>() {

                @Override
                public Stream<Node> apply(Node t) {
                    return recursive(t).stream();
                }
            }).collect(FXCollections::observableArrayList, (collections, item) -> collections.add(item), (collections, item) -> collections.addAll(item));
            controls.addAll(collect);
        /* 개선 */
        // childrenUnmodifiable.forEach(n -> {
        // ObservableList<Node> recursive = recursive(n);
        // controls.addAll(recursive);
        // });
        }
        return controls;
    } else if (node instanceof Parent) {
        Parent p = (Parent) node;
        // ObservableList<Node> collect =
        // childrenUnmodifiable.stream().map(n->this).collect(FXCollections::observableArrayList,
        // (collections, item) -> collections.add(item), (collections, item)
        // -> collections.addAll(item));
        // controls.addAll(collect);
        ObservableList<Node> childrenUnmodifiable = p.getChildrenUnmodifiable();
        // childrenUnmodifiable.forEach(n -> {
        // ObservableList<Node> recursive = recursive(n);
        // controls.addAll(recursive);
        // });
        ObservableList<Node> collect = childrenUnmodifiable.stream().flatMap(new Function<Node, Stream<Node>>() {

            @Override
            public Stream<Node> apply(Node t) {
                return recursive(t).stream();
            }
        }).collect(FXCollections::observableArrayList, (collections, item) -> collections.add(item), (collections, item) -> collections.addAll(item));
        controls.addAll(collect);
    } else {
        System.err.println("her.! : " + node);
    }
    return controls;
}
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) ReadOnlyProperty(javafx.beans.property.ReadOnlyProperty) Parent(javafx.scene.Parent) Node(javafx.scene.Node) ArrayList(java.util.ArrayList) FXCollections(javafx.collections.FXCollections) DefaultProperty(javafx.beans.DefaultProperty) IOException(java.io.IOException) Function(java.util.function.Function) Control(javafx.scene.control.Control) ObservableList(javafx.collections.ObservableList) Stream(java.util.stream.Stream)

Example 14 with ScrollPane

use of javafx.scene.control.ScrollPane 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 15 with ScrollPane

use of javafx.scene.control.ScrollPane 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)

Aggregations

ScrollPane (javafx.scene.control.ScrollPane)18 Button (javafx.scene.control.Button)6 Insets (javafx.geometry.Insets)5 Scene (javafx.scene.Scene)5 Node (javafx.scene.Node)4 BorderPane (javafx.scene.layout.BorderPane)4 VBox (javafx.scene.layout.VBox)4 HTMLEditor (javafx.scene.web.HTMLEditor)4 JFXButton (com.jfoenix.controls.JFXButton)3 MaterialDesignIconView (de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView)3 DefaultProperty (javafx.beans.DefaultProperty)3 FXCollections (javafx.collections.FXCollections)3 Parent (javafx.scene.Parent)3 Control (javafx.scene.control.Control)3 Label (javafx.scene.control.Label)3 TextArea (javafx.scene.control.TextArea)3 GridPane (javafx.scene.layout.GridPane)3 HBox (javafx.scene.layout.HBox)3 Paint (javafx.scene.paint.Paint)3 Stage (javafx.stage.Stage)3