Example usage for javafx.scene.control TreeTableView getColumns

List of usage examples for javafx.scene.control TreeTableView getColumns

Introduction

In this page you can find the example usage for javafx.scene.control TreeTableView getColumns.

Prototype

public final ObservableList<TreeTableColumn<S, ?>> getColumns() 

Source Link

Document

The TreeTableColumns that are part of this TableView.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    final Scene scene = new Scene(new Group(), 200, 400);
    Group sceneRoot = (Group) scene.getRoot();

    TreeItem<String> childNode1 = new TreeItem<>("Node 1");
    TreeItem<String> childNode2 = new TreeItem<>("Node 2");
    TreeItem<String> childNode3 = new TreeItem<>("Node 3");

    TreeItem<String> root = new TreeItem<>("Root");
    root.setExpanded(true);//from w w  w . j  av  a  2 s  . c o m

    root.getChildren().setAll(childNode1, childNode2, childNode3);

    TreeTableColumn<String, String> column = new TreeTableColumn<>("Column");
    column.setPrefWidth(150);

    column.setCellValueFactory(
            (CellDataFeatures<String, String> p) -> new ReadOnlyStringWrapper(p.getValue().getValue()));

    TreeTableView<String> treeTableView = new TreeTableView<>(root);
    treeTableView.getColumns().add(column);
    sceneRoot.getChildren().add(treeTableView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    root.setExpanded(true);//from  www . j a va2 s.  c o m
    employees.stream().forEach((employee) -> {
        root.getChildren().add(new TreeItem<>(employee));
    });
    Scene scene = new Scene(new Group(), 400, 400);
    Group sceneRoot = (Group) scene.getRoot();

    TreeTableColumn<Employee, String> empColumn = new TreeTableColumn<>("Employee");
    empColumn.setPrefWidth(150);
    empColumn.setCellValueFactory(
            (TreeTableColumn.CellDataFeatures<Employee, String> param) -> new ReadOnlyStringWrapper(
                    param.getValue().getValue().getName()));

    TreeTableColumn<Employee, String> emailColumn = new TreeTableColumn<>("Email");
    emailColumn.setPrefWidth(190);
    emailColumn.setCellValueFactory(
            (TreeTableColumn.CellDataFeatures<Employee, String> param) -> new ReadOnlyStringWrapper(
                    param.getValue().getValue().getEmail()));

    TreeTableView<Employee> treeTableView = new TreeTableView<>(root);
    treeTableView.getColumns().setAll(empColumn, emailColumn);

    treeTableView.setTableMenuButtonVisible(true);

    sceneRoot.getChildren().add(treeTableView);
    stage.setScene(scene);
    stage.show();
}

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java

/**
 * Gets the rendered text of a TreeTableCell
 * //from w  w w  .  j av  a2s.c om
 * @param node
 *            this can be a cell or a tree item
 * @param col
 *            if node is a tree item this parameter is used to find the cell
 *            to get the rendered text from
 * @return the rendered text
 */
private String getRenderedTextFromCell(final Object node, final int col) {
    if (node instanceof TreeItem<?>) {
        scrollNodeToVisible(node);
    }
    String result = EventThreadQueuerJavaFXImpl.invokeAndWait("getRenderedText", new Callable<String>() { //$NON-NLS-1$

        @Override
        public String call() throws Exception {
            if (node instanceof TreeTableCell) {
                TreeTableCell<?, ?> cell = (TreeTableCell<?, ?>) node;
                return cell.getText();
            } else if (node instanceof TreeItem) {
                TreeItem<?> item = (TreeItem<?>) node;
                TreeTableView<?> treeTable = getTree();
                List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>().getInstancesOf(treeTable,
                        TreeTableCell.class);
                for (TreeTableCell<?, ?> cell : cells) {
                    // Nullchecks because of the virtual flow cells
                    // are created which might not be associated
                    // with a row or an item
                    TreeTableRow<?> ttRow = cell.getTreeTableRow();
                    if (ttRow == null) {
                        continue;
                    }
                    TreeItem<?> checkItem = ttRow.getTreeItem();
                    if (checkItem == null) {
                        continue;
                    }
                    if (item != null && checkItem.equals(item)
                            && treeTable.getColumns().indexOf(cell.getTableColumn()) == col) {
                        return cell.getText();
                    }
                }
            }
            return null;
        }
    });
    return result;
}

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java

@Override
public Rectangle getNodeBounds(final Object node) {
    scrollNodeToVisible(node);/*from  www  .  j  a va2s  .  c  om*/
    return EventThreadQueuerJavaFXImpl.invokeAndWait("getNodeBounds", new Callable<Rectangle>() { //$NON-NLS-1$

        @Override
        public Rectangle call() throws Exception {
            TreeTableView<?> treeTable = getTree();
            treeTable.layout();
            TreeItem<?> item = (TreeItem<?>) node;
            List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>().getInstancesOf(treeTable,
                    TreeTableCell.class);
            for (TreeTableCell<?, ?> cell : cells) {
                // Nullchecks because of the virtual flow cells
                // are created which might not be associated
                // with a row or an item
                TreeTableRow<?> ttRow = cell.getTreeTableRow();
                if (ttRow == null) {
                    continue;
                }
                TreeItem<?> checkItem = ttRow.getTreeItem();
                if (checkItem == null) {
                    continue;
                }
                if (item != null && checkItem.equals(item)
                        && treeTable.getColumns().indexOf(cell.getTableColumn()) == m_column) {
                    Rectangle b = NodeBounds.getAbsoluteBounds(cell);
                    Rectangle treeB = NodeBounds.getAbsoluteBounds(treeTable);
                    return new Rectangle(Math.abs(treeB.x - b.x), Math.abs(treeB.y - b.y),
                            Rounding.round(b.getWidth()), Rounding.round(b.getHeight()));
                }
            }
            return null;
        }
    });
}