use of javafx.beans.DefaultProperty 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;
}
Aggregations