use of eu.ggnet.dwoss.uniqueunit.ui.product.ProductFx.AdditionalPartNo in project dwoss by gg-net.
the class MyDoubleStringConverter method accept.
@Override
public void accept(Product product) {
this.pfx.setId(product.getId());
this.pfx.setOptLock(product.getOptLock());
this.pfx.setName(product.getName());
this.pfx.setDescription(product.getDescription());
this.pfx.setGtin(product.getGtin());
this.pfx.setImageId(product.getImageId());
this.pfx.setPartNo(product.getPartNo());
if (product.getEol() == null) {
pfx.setEol(null);
} else {
this.pfx.setEol(product.getEol().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
}
this.pfx.setTradeName(product.getTradeName());
if (product.getSalesChannel() != null) {
this.pfx.setSalesChannel(product.getSalesChannel());
} else {
this.pfx.setSalesChannel(SalesChannel.UNKNOWN);
}
this.pfx.setProductGroup(product.getGroup());
// product.getAdditionalPartNos().forEach((t, u) -> this.pfx.getAdditionalPartNos().add(new AdditionalPartNo(t, u)));
this.pfx.getAdditionalPartNos().addAll(product.getAdditionalPartNos().entrySet().stream().map(e -> new AdditionalPartNo(e.getKey(), e.getValue())).collect(Collectors.toList()));
product.getPrices().forEach((PriceType pT, Double price) -> {
Prices pr = new Prices();
pr.setPrice(price);
pr.setPriceType(pT);
this.pfx.getPrices().add(pr);
});
}
use of eu.ggnet.dwoss.uniqueunit.ui.product.ProductFx.AdditionalPartNo in project dwoss by gg-net.
the class MyDoubleStringConverter method handleAdditionalPartNoTableSubmitButtonAction.
@FXML
private void handleAdditionalPartNoTableSubmitButtonAction(ActionEvent event) {
String textFieldString = additionalPartNoTextField.getText().trim();
TradeName tradeName = additionalPartNoTableComboBox.getValue();
if (textFieldString.length() == 0) {
Ui.exec(() -> {
Ui.build(additionalPartNoTableSubmitButton).alert().title("Fehler!").message("Hinzufügen der Artikelnummer nicht möglich.").nl("Es ist keine Artikelnummer angegeben.").show(AlertType.ERROR);
});
return;
}
if (additionalPartNoTable.getItems().stream().map(AdditionalPartNo::getContractor).anyMatch(contractor -> contractor == tradeName)) {
Ui.exec(() -> {
Ui.build(additionalPartNoTableSubmitButton).alert().title("Fehler!").message("Hinzufügen der Artikelnummer nicht möglich").nl("Der Lieferant ist bereits vorhanden.").show(AlertType.ERROR);
});
return;
}
AdditionalPartNo apN = new AdditionalPartNo();
apN.setContractor(additionalPartNoTableComboBox.getValue());
apN.setPartNo(textFieldString);
pfx.getAdditionalPartNos().add(apN);
}
use of eu.ggnet.dwoss.uniqueunit.ui.product.ProductFx.AdditionalPartNo in project dwoss by gg-net.
the class MyDoubleStringConverter method initialize.
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
fillTableComboBoxes();
additionalPartNoTable.setItems(pfx.getAdditionalPartNos());
priceTable.setItems(pfx.getPrices());
additionalPartNoTable.setEditable(true);
priceTable.setEditable(true);
tradeNameColumn.setCellValueFactory(new PropertyValueFactory<>("contractor"));
partNoColumn.setCellFactory(TextFieldTableCell.forTableColumn());
partNoColumn.setCellValueFactory(new PropertyValueFactory<>("partNo"));
partNoColumn.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<AdditionalPartNo, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<AdditionalPartNo, String> e) {
((AdditionalPartNo) e.getTableView().getItems().get(e.getTablePosition().getRow())).setPartNo(e.getNewValue());
}
});
partNoColumn.setEditable(true);
priceTypeColumn.setCellValueFactory(new PropertyValueFactory<>("priceType"));
priceDoubleColumn.setCellValueFactory(new PropertyValueFactory<>("price"));
// see CustomTableCell documentation
// this is necessary if we want an editable Double Column representing a FXProperty
// priceDoubleColumn.setCellFactory(CustomTableCell.forTableColumn(new DoubleStringConverter()));
priceDoubleColumn.setEditable(true);
priceDoubleColumn.setCellFactory(TextFieldTableCell.<Prices, Double>forTableColumn(new MyDoubleStringConverter()));
priceDoubleColumn.setOnEditCommit(event -> {
final Double value = event.getNewValue() != null ? event.getNewValue() : event.getOldValue();
((Prices) event.getTableView().getItems().get(event.getTablePosition().getRow())).setPrice(value);
event.getTableView().refresh();
});
pfx.nameProperty().bindBidirectional(nameTextArea.textProperty());
pfx.descriptionProperty().bindBidirectional(descriptionTextArea.textProperty());
pfx.partNoProperty().bindBidirectional(partNoTextField.textProperty());
pfx.eolProperty().bindBidirectional(eolDatePicker.valueProperty());
imageIdTextField.textProperty().bindBidirectional(pfx.imageIdProperty(), new NumberStringConverter());
gtinTextField.textProperty().bindBidirectional(pfx.gtinProperty(), new NumberStringConverter());
pfx.tradeNameProperty().bindBidirectional(tradeNameComboBox.valueProperty());
pfx.productGroupProperty().bindBidirectional(productGroupComboBox.valueProperty());
pfx.salesChannelProperty().bindBidirectional(salesChannelComboBox.valueProperty());
// Defaults
pfx.setProductGroup(ProductGroup.values()[0]);
pfx.setSalesChannel(SalesChannel.UNKNOWN);
pfx.setTradeName(TradeName.values()[0]);
}
Aggregations