/** * Create the legalality column, which holds the legality of a filter and also creates a callback * to the string property behind it. */ private void setUpLegalityColumn(TableView<FilterInput> tableView) { // Set up priority column final TableColumn<FilterInput, Boolean> legalColumn = new TableColumn<>("Authorized"); legalColumn.setMinWidth(70); legalColumn.setPrefWidth(70); tableView.getColumns().add(legalColumn); legalColumn.setCellValueFactory(p -> p.getValue().getLegalProperty()); }
/** * Create the priority column, which holds the priority of a filter and also creates a callback to * the integer property behind it. */ private void setUpPriorityColumn(TableView<FilterInput> tableView) { // Set up priority column final TableColumn<FilterInput, Integer> priorityColumn = new TableColumn<>("Priority"); priorityColumn.setMinWidth(50); priorityColumn.setPrefWidth(50); tableView.getColumns().add(priorityColumn); priorityColumn.setCellValueFactory(p -> p.getValue().getPriorityProperty().asObject()); }
/** * Create the origin column, which holds the type of the origin and also creates a callback to the * string property behind it. */ private void setUpOriginColumn(TableView<FilterInput> tableView) { // Set up origin column final TableColumn<FilterInput, String> originColumn = new TableColumn<>("Filtered By"); originColumn.setMinWidth(90); originColumn.setPrefWidth(90); tableView.getColumns().add(originColumn); originColumn.setCellValueFactory(p -> p.getValue().getFilterTypeProperty()); }
/** * Create the type column, which holds the type of the filter and also creates a callback to the * string property behind it. */ private void setUpTypeColumn(TableView<FilterInput> tableView) { // Set up type column final TableColumn<FilterInput, String> typeColumn = new TableColumn<>("Selection Model"); typeColumn.setMinWidth(90); typeColumn.setPrefWidth(90); tableView.getColumns().add(typeColumn); typeColumn.setCellValueFactory(p -> p.getValue().getSelectionModelProperty()); }
/** * Create the filter column, which holds the name of the filter and also creates a callback to the * string property behind it. */ private void setUpFilterColumn(TableView<FilterInput> tableView) { // Set up filter column final TableColumn<FilterInput, String> filterColumn = new TableColumn<>("Filter"); filterColumn.setMinWidth(120); filterColumn.setPrefWidth(120); tableView.getColumns().add(filterColumn); filterColumn.setCellValueFactory(p -> p.getValue().getNameProperty()); }
/** * Create the active column, which holds the activity state and also creates a callback to the * string property behind it. */ private void setUpActiveColumn(TableView<FilterInput> tableView) { // Set up active column final TableColumn<FilterInput, Boolean> activeColumn = new TableColumn<>("Active"); activeColumn.setMinWidth(50); activeColumn.setPrefWidth(50); tableView.getColumns().add(activeColumn); activeColumn.setSortable(false); activeColumn.setCellFactory( CheckBoxTableCell.forTableColumn( (Callback<Integer, ObservableValue<Boolean>>) param -> { final FilterInput input = tableView.getItems().get(param); input .getActiveProperty() .addListener( l -> { notifyUpdateCommand(input); }); return input.getActiveProperty(); })); }
/** * Create the color column, which holds the color and also creates a callback to the string * property behind it. */ private void setUpColorColumn(TableView<FilterInput> tableView) { final TableColumn<FilterInput, Color> colorColumn = new TableColumn<>("Color"); colorColumn.setMinWidth(50); colorColumn.setPrefWidth(50); colorColumn.setSortable(false); tableView.getColumns().add(colorColumn); // Set the cell value factory for the color colorColumn.setCellValueFactory(p -> p.getValue().getColorProperty()); // Set the cell factory for the color colorColumn.setCellFactory( param -> new TableCell<FilterInput, Color>() { final Rectangle rectangle = new Rectangle(); @Override public void updateItem(Color item, boolean empty) { // Add the color to the row if (item != null) { HBox hBox = new HBox(); hBox.getChildren().add(rectangle); rectangle.setHeight(20); rectangle.setWidth(30); hBox.setAlignment(Pos.CENTER); rectangle.setFill(item); setGraphic(hBox); } // Remove the color if the row has been removed if (empty) { setGraphic(null); } } }); }