use of javafx.scene.control.SelectionMode.MULTIPLE in project dwoss by gg-net.
the class ResolveRepaymentController method initialize.
@Override
public void initialize(URL url, ResourceBundle rb) {
TableColumn<ReportLine, Long> id = new TableColumn<>("Id");
id.setCellValueFactory((p) -> new SimpleObjectProperty<>(p.getValue().getId()));
TableColumn<ReportLine, String> refurbishId = new TableColumn<>("RefurbishId");
refurbishId.setCellValueFactory(new PropertyValueFactory("refurbishId"));
refurbishId.setMinWidth(110);
TableColumn<ReportLine, Date> reportingDate = new TableColumn<>("Reported");
reportingDate.setCellValueFactory(new PropertyValueFactory("reportingDate"));
reportingDate.setMinWidth(110);
TableColumn<ReportLine, Long> unqiueUnitId = new TableColumn<>("UniqueUnit Id");
unqiueUnitId.setCellValueFactory(new PropertyValueFactory("uniqueUnitId"));
TableColumn<ReportLine, TradeName> contractorColumn = new TableColumn<>("contractor");
contractorColumn.setCellValueFactory(new PropertyValueFactory("contractor"));
TableColumn<ReportLine, String> partNo = new TableColumn<>("PartNo");
partNo.setCellValueFactory(new PropertyValueFactory("partNo"));
partNo.setMinWidth(110);
TableColumn<ReportLine, String> productName = new TableColumn<>("productName");
productName.setCellValueFactory(new PropertyValueFactory("productName"));
TableColumn<ReportLine, Double> amount = new TableColumn<>("amount");
amount.setCellValueFactory(new PropertyValueFactory("amount"));
TableColumn<ReportLine, Double> price = new TableColumn<>("price");
price.setCellValueFactory(new PropertyValueFactory("price"));
TableColumn<ReportLine, Double> purchasePrice = new TableColumn<>("purchasePrice");
purchasePrice.setCellValueFactory(new PropertyValueFactory("purchasePrice"));
TableColumn<ReportLine, Double> contractorReferencePrice = new TableColumn<>("Ref.Price");
contractorReferencePrice.setCellValueFactory(new PropertyValueFactory("contractorReferencePrice"));
TableColumn<ReportLine, DocumentType> documentType = new TableColumn<>("documentType");
documentType.setCellValueFactory(new PropertyValueFactory("documentType"));
TableColumn<ReportLine, PositionType> positionType = new TableColumn<>("positionType");
positionType.setCellValueFactory(new PropertyValueFactory("positionType"));
reportLineTable.getColumns().addAll(reportingDate, refurbishId, partNo, productName, contractorColumn, amount, contractorReferencePrice, price, purchasePrice, documentType, positionType, unqiueUnitId, id);
reportLineTable.getSelectionModel().setSelectionMode(MULTIPLE);
reportLineTable.getSelectionModel().selectedIndexProperty().addListener((ov, o, n) -> {
double ref = reportLineTable.getSelectionModel().getSelectedItems().stream().map((srl) -> srl.getContractorReferencePrice()).reduce(0., (interimResult, elem) -> interimResult + elem);
referencePriceProperty.set(ref);
});
reportLineTable.setOnMouseClicked((MouseEvent mouseEvent) -> {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
String refurbishId1 = reportLineTable.getSelectionModel().getSelectedItem().getRefurbishId();
sopoField.setText(refurbishId1);
}
});
}
use of javafx.scene.control.SelectionMode.MULTIPLE in project dwoss by gg-net.
the class ProductListController method initialize.
/**
* Adding the filters to the combo box. Setting the cell values and the
* filtered list containing the data.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
tableView.getSelectionModel().setSelectionMode(MULTIPLE);
menuTradeName.getItems().addAll(FXCollections.observableArrayList(TradeName.values()));
menuProductGroup.getItems().addAll(ProductGroup.values());
tableView.setOnDragDetected((MouseEvent event) -> {
ArrayList<Product> selectedProducts = new ArrayList<>();
selectedProducts.addAll(tableView.getSelectionModel().getSelectedItems());
ArrayList<PicoProduct> selectedPicoProducts = new ArrayList<>();
if (selectedProducts.isEmpty())
return;
Dragboard db = tableView.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
selectedPicoProducts.addAll(selectedProducts.stream().map(p -> new PicoProduct(p.getId(), p.getName())).collect(Collectors.toList()));
content.put(PICO_PRODUCT_DATA_FORMAT, selectedPicoProducts);
db.setContent(content);
event.consume();
});
setCellValues();
progressBar.progressProperty().bind(LOADING_TASK.progressProperty());
progressBar.visibleProperty().bind(LOADING_TASK.runningProperty());
filteredProducts = new FilteredList<>(LOADING_TASK.getPartialResults(), p -> true);
// filteredList does not allow sorting so it needs to be wrapped in a sortedList
SortedList<Product> sortedProducts = new SortedList<>(filteredProducts);
sortedProducts.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedProducts);
editButton.disableProperty().bind(tableView.getSelectionModel().selectedItemProperty().isNull());
Ui.progress().observe(LOADING_TASK);
Ui.exec(LOADING_TASK);
}
Aggregations