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);
}
}
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;
}
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;
}
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;
}
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();
}
Aggregations