Search in sources :

Example 1 with JFXTreeTableCell

use of com.jfoenix.controls.cells.editors.base.JFXTreeTableCell in project JFoenix by jfoenixadmin.

the class JFXTreeTableColumn method init.

private void init() {
    this.setCellFactory(new Callback<TreeTableColumn<S, T>, TreeTableCell<S, T>>() {

        @Override
        public TreeTableCell<S, T> call(TreeTableColumn<S, T> param) {
            return new JFXTreeTableCell<S, T>() {

                @Override
                protected void updateItem(T item, boolean empty) {
                    if (item == getItem())
                        return;
                    super.updateItem(item, empty);
                    if (item == null) {
                        super.setText(null);
                        super.setGraphic(null);
                    } else if (item instanceof Node) {
                        super.setText(null);
                        super.setGraphic((Node) item);
                    } else {
                        super.setText(item.toString());
                        super.setGraphic(null);
                    }
                }
            };
        }
    });
    Platform.runLater(() -> {
        final ContextMenu contextMenu = new ContextMenu();
        //			contextMenu.setOnShowing((showing)->{
        //				System.out.println("showing");
        //			});
        //			contextMenu.setOnShown((shown)->{
        //				System.out.println("shown");
        //			});
        MenuItem item1 = new MenuItem("Group");
        item1.setOnAction((action) -> {
            ((JFXTreeTableView) getTreeTableView()).group(this);
        });
        MenuItem item2 = new MenuItem("UnGroup");
        item2.setOnAction((action) -> {
            ((JFXTreeTableView) getTreeTableView()).unGroup(this);
        });
        contextMenu.getItems().addAll(item1, item2);
        setContextMenu(contextMenu);
    });
}
Also used : TreeTableCell(javafx.scene.control.TreeTableCell) JFXTreeTableCell(com.jfoenix.controls.cells.editors.base.JFXTreeTableCell) Node(javafx.scene.Node) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) TreeTableColumn(javafx.scene.control.TreeTableColumn)

Aggregations

JFXTreeTableCell (com.jfoenix.controls.cells.editors.base.JFXTreeTableCell)1 Node (javafx.scene.Node)1 ContextMenu (javafx.scene.control.ContextMenu)1 MenuItem (javafx.scene.control.MenuItem)1 TreeTableCell (javafx.scene.control.TreeTableCell)1 TreeTableColumn (javafx.scene.control.TreeTableColumn)1