All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.perfs.ui.fx.ContextsPane Maven / Gradle / Ivy

There is a newer version: 0.52.0
Show newest version
package cdc.perfs.ui.fx;

import cdc.perfs.Context;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;

public class ContextsPane extends BorderPane {
    private final TableView wTable = new TableView<>();

    public ContextsPane(ContextsTableModel model) {
        wTable.setEditable(true);
        wTable.setItems(model.asObservableList());

        final TableColumn wContextCol = new TableColumn<>("Context");
        final TableColumn wVisibleCol = new TableColumn<>("Visible");

        wTable.getColumns().add(wContextCol);
        wTable.getColumns().add(wVisibleCol);

        wContextCol.setCellValueFactory(new PropertyValueFactory<>("context"));
        wContextCol.setCellFactory(column -> new ContextTableCell());

        wVisibleCol.setCellValueFactory(f -> f.getValue().visibleProperty());
        wVisibleCol.setEditable(true);
        //        wVisibleCol.setCellFactory(CheckBoxTableCell.forTableColumn(wVisibleCol));
        wVisibleCol.setCellFactory(column -> new VisibleTableCell());
        //        wVisibleCol.setCellFactory(column -> new BooleanCell<>());

        wVisibleCol.setOnEditCommit(event -> event
                .getTableView()
                .getItems()
                .get(event.getTablePosition().getRow())
                .setVisible(event.getNewValue()));

        setCenter(wTable);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy