Search in sources :

Example 6 with Control

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

the class JFXTextFieldSkinAndroid method updateGraphic.

private final void updateGraphic(Node graphic, String id) {
    Node old = getSkinnable().lookup("#" + id);
    getChildren().remove(old);
    if (graphic != null) {
        graphic.setId(id);
        graphic.setManaged(false);
        // add tab events handler as there is a bug in javafx traversing engine
        Set<Control> controls = JFXNodeUtils.getAllChildren(graphic, Control.class);
        controls.forEach(control -> {
            control.addEventHandler(KeyEvent.KEY_PRESSED, JFXNodeUtils.TRAVERSE_HANDLER);
            control.addEventHandler(KeyEvent.KEY_TYPED, Event::consume);
        });
        getChildren().add(graphic);
    }
}
Also used : Control(javafx.scene.control.Control) IFXLabelFloatControl(com.jfoenix.controls.base.IFXLabelFloatControl) Node(javafx.scene.Node) Event(javafx.event.Event) KeyEvent(javafx.scene.input.KeyEvent)

Example 7 with Control

use of javafx.scene.control.Control 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 8 with Control

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

the class CheckBoxFxControlsTreeItem method createNode.

/**
	 * 파일 트리를 생성하기 위한 노드를 반환한다.
	 *
	 * @Date 2015. 10. 14.
	 * @param f
	 * @return
	 * @User KYJ
	 */
public TreeItem<Node> createNode(final Node f) {
    TreeItem<Node> treeItem = new CheckBoxTreeItem<Node>(f) {

        private boolean isLeaf;

        private boolean isFirstTimeChildren = true;

        private boolean isFirstTimeLeaf = true;

        @Override
        public ObservableList<TreeItem<Node>> getChildren() {
            if (isFirstTimeChildren) {
                isFirstTimeChildren = false;
                super.getChildren().setAll(buildChildren(this));
            }
            return super.getChildren();
        }

        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                Node f = getValue();
                if (f == null) {
                    isLeaf = true;
                } else if (f instanceof Control) {
                    isLeaf = ((Control) f).getChildrenUnmodifiable().isEmpty();
                } else if (f instanceof Parent) {
                    isLeaf = ((Parent) f).getChildrenUnmodifiable().isEmpty();
                } else if (f instanceof Shape)
                    isLeaf = true;
                else
                    isLeaf = false;
            }
            return isLeaf;
        }

        private ObservableList<TreeItem<Node>> buildChildren(TreeItem<Node> treeItem) {
            Node f = treeItem.getValue();
            if (f == null) {
                return FXCollections.emptyObservableList();
            }
            treeItem.setGraphic(getImage(getName(f)));
            List<Node> childrens = getChildrens(f);
            if (childrens == null || childrens.isEmpty()) {
                return FXCollections.emptyObservableList();
            } else {
                ObservableList<TreeItem<Node>> children = FXCollections.observableArrayList();
                for (Node child : childrens) {
                    children.add(createNode(child));
                }
                return children;
            }
        }
    };
    treeItem.setGraphic(getImage(getName(f)));
    return treeItem;
}
Also used : Control(javafx.scene.control.Control) Shape(javafx.scene.shape.Shape) TreeItem(javafx.scene.control.TreeItem) CheckBoxTreeItem(javafx.scene.control.CheckBoxTreeItem) Parent(javafx.scene.Parent) CheckBoxTreeItem(javafx.scene.control.CheckBoxTreeItem) Node(javafx.scene.Node)

Example 9 with Control

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

the class FxControlsTreeItem method getChildrens.

/**
	 * node로부터 구성된 하위 노드들을 반환받음.
	 * 
	 * @param node
	 * @return
	 */
public List<Node> getChildrens(Node node) {
    List<Node> controls = new ArrayList<>();
    if (node instanceof Control) {
        Control c = (Control) node;
        controls.add(c);
        controls = c.getChildrenUnmodifiable();
    } else if (node instanceof Parent) {
        Parent p = (Parent) node;
        controls = p.getChildrenUnmodifiable();
    } else {
        controls.add(node);
    }
    return controls;
}
Also used : Control(javafx.scene.control.Control) Parent(javafx.scene.Parent) Node(javafx.scene.Node) ArrayList(java.util.ArrayList)

Example 10 with Control

use of javafx.scene.control.Control in project org.csstudio.display.builder by kasemir.

the class EditorDemoGUI method createElements.

private void createElements(final Stage stage) {
    editor = new DisplayEditor(toolkit, 50);
    tree = new WidgetTree(editor);
    property_panel = new PropertyPanel(editor);
    // Left: Widget tree
    Label header = new Label("Widgets");
    header.setMaxWidth(Double.MAX_VALUE);
    header.getStyleClass().add("header");
    final Control tree_control = tree.create();
    VBox.setVgrow(tree_control, Priority.ALWAYS);
    final VBox tree_box = new VBox(header, tree_control);
    // Center: Editor
    final Node editor_scene = editor.create();
    extendToolbar(editor.getToolBar());
    // Right: Properties
    header = new Label("Properties");
    header.setMaxWidth(Double.MAX_VALUE);
    header.getStyleClass().add("header");
    final VBox properties_box = new VBox(header, property_panel);
    final SplitPane center_split = new SplitPane(tree_box, editor_scene, properties_box);
    center_split.setDividerPositions(0.2, 0.8);
    final BorderPane layout = new BorderPane();
    layout.setCenter(center_split);
    BorderPane.setAlignment(center_split, Pos.TOP_LEFT);
    editor_scene.addEventFilter(MouseEvent.MOUSE_MOVED, mouse_tracker);
    layout.addEventFilter(KeyEvent.KEY_PRESSED, key_handler);
    stage.setTitle("Editor");
    stage.setWidth(1200);
    stage.setHeight(600);
    final Scene scene = new Scene(layout, 1200, 600);
    stage.setScene(scene);
    EditorUtil.setSceneStyle(scene);
    // If ScenicView.jar is added to classpath, open it here
    // ScenicView.show(scene);
    stage.show();
}
Also used : WidgetTree(org.csstudio.display.builder.editor.tree.WidgetTree) Control(javafx.scene.control.Control) BorderPane(javafx.scene.layout.BorderPane) Node(javafx.scene.Node) Label(javafx.scene.control.Label) SplitPane(javafx.scene.control.SplitPane) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) PropertyPanel(org.csstudio.display.builder.editor.properties.PropertyPanel)

Aggregations

Control (javafx.scene.control.Control)14 Node (javafx.scene.Node)12 Parent (javafx.scene.Parent)6 Scene (javafx.scene.Scene)4 IFXLabelFloatControl (com.jfoenix.controls.base.IFXLabelFloatControl)3 Method (java.lang.reflect.Method)3 List (java.util.List)3 Application (javafx.application.Application)3 ObservableList (javafx.collections.ObservableList)3 FXMLLoader (javafx.fxml.FXMLLoader)3 Parameter (com.scythe.instrumenter.InstrumentationProperties.Parameter)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 File (java.io.File)2 Field (java.lang.reflect.Field)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Modifier (java.lang.reflect.Modifier)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2