/** * Sets up the OverlayMenu with all buttons from the existing table view. * * @param tableView The table view to put on the overlay menu. * @return A {@link BorderPane} containing the full menu. */ private BorderPane setUpMenu(TableView<FilterInput> tableView) { final Button addButton = setAddButton(); final Button removeButton = setRemoveButton(tableView); final Button editButton = setEditButton(tableView); final Button selectionButton = setSelectionButton(); // Set up components on overlay final BorderPane borderPane = new BorderPane(); borderPane.setCenter(tableView); tableView.setMinHeight(300); AnchorPane anchorPane = new AnchorPane(); anchorPane.getChildren().addAll(addButton, removeButton, editButton, selectionButton); borderPane.setBottom(anchorPane); AnchorPane.setBottomAnchor(addButton, 0d); AnchorPane.setRightAnchor(addButton, 0d); AnchorPane.setBottomAnchor(removeButton, 0d); AnchorPane.setRightAnchor(removeButton, 30d); AnchorPane.setBottomAnchor(editButton, 0d); AnchorPane.setRightAnchor(editButton, 60d); AnchorPane.setBottomAnchor(selectionButton, 0d); AnchorPane.setRightAnchor(selectionButton, 95d); return borderPane; }
/** * Sets up the entire TableView with all its functionalities. * * @return The created TableView. */ private TableView<FilterInput> setUpTableView() { // Set up table view final TableView<FilterInput> tableView = new TableView<>(); tableView.setEditable(true); tableView.setMinWidth(522); tableView.setMinHeight(280); // Set up columns setUpFilterColumn(tableView); setUpTypeColumn(tableView); setUpOriginColumn(tableView); setUpColorColumn(tableView); setUpPriorityColumn(tableView); setUpLegalityColumn(tableView); setUpActiveColumn(tableView); // Insert data from database into table tableView.setItems(data); // Set select/deselect on mouse click tableView.setRowFactory( tableViewLambda -> { final TableRow<FilterInput> row = new TableRow<>(); row.addEventFilter( MouseEvent.MOUSE_PRESSED, event -> { final int index = row.getIndex(); if (index >= 0 && index < tableView.getItems().size() && tableView.getSelectionModel().isSelected(index)) { tableView.getSelectionModel().clearSelection(); event.consume(); } }); return row; }); return tableView; }