Search in sources :

Example 1 with MULTIPLE

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);
        }
    });
}
Also used : Title(eu.ggnet.saft.api.ui.Title) java.util(java.util) Initializable(javafx.fxml.Initializable) MouseButton(javafx.scene.input.MouseButton) javafx.scene.control(javafx.scene.control) URL(java.net.URL) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) MULTIPLE(javafx.scene.control.SelectionMode.MULTIPLE) Ui(eu.ggnet.saft.Ui) Dl(eu.ggnet.saft.Dl) FxController(eu.ggnet.saft.api.ui.FxController) AlertType(eu.ggnet.saft.core.ui.AlertType) ResolveRepayment(eu.ggnet.dwoss.misc.ee.ResolveRepayment) javafx.beans.property(javafx.beans.property) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Consumer(java.util.function.Consumer) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) ResolveResult(eu.ggnet.dwoss.misc.ee.ResolveRepayment.ResolveResult) Guardian(eu.ggnet.saft.core.auth.Guardian) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) ForkJoinPool(java.util.concurrent.ForkJoinPool) MouseEvent(javafx.scene.input.MouseEvent) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory)

Example 2 with MULTIPLE

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);
}
Also used : java.util(java.util) Initializable(javafx.fxml.Initializable) TradeName(eu.ggnet.dwoss.rules.TradeName) javafx.scene.control(javafx.scene.control) URL(java.net.URL) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) MULTIPLE(javafx.scene.control.SelectionMode.MULTIPLE) Ui(eu.ggnet.saft.Ui) FxController(eu.ggnet.saft.api.ui.FxController) java.time(java.time) ProductTask(eu.ggnet.dwoss.uniqueunit.ui.ProductTask) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) DateFormats(eu.ggnet.dwoss.util.DateFormats) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Predicate(java.util.function.Predicate) ProductGroup(eu.ggnet.dwoss.rules.ProductGroup) FilteredList(javafx.collections.transformation.FilteredList) ClosedListener(eu.ggnet.saft.api.ui.ClosedListener) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) FxSaft(eu.ggnet.saft.core.ui.FxSaft) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct)

Aggregations

Ui (eu.ggnet.saft.Ui)2 FxController (eu.ggnet.saft.api.ui.FxController)2 URL (java.net.URL)2 java.util (java.util)2 FXCollections (javafx.collections.FXCollections)2 FXML (javafx.fxml.FXML)2 Initializable (javafx.fxml.Initializable)2 javafx.scene.control (javafx.scene.control)2 MULTIPLE (javafx.scene.control.SelectionMode.MULTIPLE)2 PropertyValueFactory (javafx.scene.control.cell.PropertyValueFactory)2 ResolveRepayment (eu.ggnet.dwoss.misc.ee.ResolveRepayment)1 ResolveResult (eu.ggnet.dwoss.misc.ee.ResolveRepayment.ResolveResult)1 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)1 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)1 ProductGroup (eu.ggnet.dwoss.rules.ProductGroup)1 TradeName (eu.ggnet.dwoss.rules.TradeName)1 PicoProduct (eu.ggnet.dwoss.uniqueunit.api.PicoProduct)1 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)1 ProductTask (eu.ggnet.dwoss.uniqueunit.ui.ProductTask)1 DateFormats (eu.ggnet.dwoss.util.DateFormats)1