Java Code Examples for javafx.scene.control.TreeItem#getGraphic()

The following examples show how to use javafx.scene.control.TreeItem#getGraphic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScenegraphTreeView.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This is a patch for TreeView indentation issue
 * 
 * @param realNode
 */
void patchRoot(final TreeItem<SVNode> realNode) {
    this.patchedNode = realNode;
    final TreeItem<SVNode> real = new TreeItem<>(realNode.getValue(), realNode.getGraphic());
    real.getChildren().addAll(realNode.getChildren());
    setRoot(real);
}
 
Example 2
Source File: JFXTreeCell.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void updateDisplay(T item, boolean empty) {
    if (item == null || empty) {
        hbox = null;
        setText(null);
        setGraphic(null);
    } else {
        TreeItem<T> treeItem = getTreeItem();
        if (treeItem != null && treeItem.getGraphic() != null) {
            if (item instanceof Node) {
                setText(null);
                if (hbox == null) {
                    hbox = new HBox(3);
                }
                hbox.getChildren().setAll(treeItem.getGraphic(), (Node) item);
                setGraphic(hbox);
            } else {
                hbox = null;
                setText(item.toString());
                setGraphic(treeItem.getGraphic());
            }
        } else {
            hbox = null;
            if (item instanceof Node) {
                setText(null);
                setGraphic((Node) item);
            } else {
                setText(item.toString());
                setGraphic(null);
            }
        }
    }
}
 
Example 3
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 4 votes vote down vote up
static Node getGraphic(TreeItem<?> treeItem) {
    return treeItem == null ? null : treeItem.getGraphic();
}
 
Example 4
Source File: CellUtiles.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
static Node getGraphic(TreeItem<?> treeItem) {
    return treeItem == null ? null : treeItem.getGraphic();
}
 
Example 5
Source File: CheckBoxTreeCell.java    From LiveDirsFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected void updateItem(C item, boolean empty) {
    super.updateItem(item, empty);

    if (empty || item == null) {
        setText(null);
        checkBox.setGraphic(null);
        setGraphic(null);
    } else {
        // update the text
        setText(stringConverter.apply(getItem()));

        // update the graphic
        TreeItem<C> treeItem = getTreeItem();
        Node graphic = treeItem.getGraphic();
        checkBox.setGraphic( graphic != null ? graphic : null);
        setGraphic(checkBox);

        // unbind properties
        if (state != null) {
            checkBox.selectedProperty().unbindBidirectional(select);
            intermediateState.unsubscribe();
            state.removeListener(stateInvalidations);
        }

        // rebind properties
        state = treeItem.getValue().stateProperty();
        select = state.mapBidirectional(
                s -> s == CheckBoxContent.State.CHECKED,
                val -> val ? CheckBoxContent.State.CHECKED : CheckBoxContent.State.UNCHECKED
        );
        checkBox.selectedProperty().bindBidirectional(select);

        // using checkBox.intermediateProperty().bind(state.map(s -> s == UNDEFINED)); results in a
        // RunTimeException: a bounded property cannot be set
        // So, get around it by feeding state values into it.
        intermediateState = state.values()
                .map(s -> s == CheckBoxContent.State.UNDEFINED)
                .feedTo(checkBox.indeterminateProperty());

        state.addListener(stateInvalidations);
    }
}