use of eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem in project dwoss by gg-net.
the class CustomerEnhanceController method buildExternalSystemIdBox.
private void buildExternalSystemIdBox() {
additionalCustomerIDsListView.setCellFactory((ListView<AdditionalCustomerID> p) -> {
ListCell<AdditionalCustomerID> cell = new ListCell<AdditionalCustomerID>() {
@Override
protected void updateItem(AdditionalCustomerID item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
setText("");
} else {
HBox flagbox = new HBox();
Label flagLabel = new Label(item.type.name() + ":");
flagLabel.setPrefWidth(65.0);
flagLabel.setStyle("-fx-font-weight: bold");
Label customerIdLabel = new Label();
customerIdLabel.setText(item.getValue());
flagbox.getChildren().addAll(flagLabel, customerIdLabel);
flagbox.setSpacing(2.0);
setText(null);
setGraphic(flagbox);
}
}
};
return cell;
});
Label ExternalSystemIDsLabel = new Label("Zusätzliche Kundennummern: ");
// create a dialog to add AdditionalCustomerId instances to the additionalCustomerIDsListView
Button addButton = new Button("Hinzufügen");
addButton.setMinWidth(80.0);
addButton.setOnAction(new AdditionalCustomerIDsDialogHandler());
Button deleteButton = new Button("Löschen");
deleteButton.setMinWidth(80.0);
deleteButton.setOnAction((event) -> {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Externe Kundennummer löschen");
alert.setHeaderText("Bestätigen der Löschung einer Kundennummer");
alert.setContentText("Wollen sie die Kundennummer wirklich löschen?");
// TODO: JACOB
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
additionalCustomerIDsListView.getItems().remove(additionalCustomerIDsListView.getSelectionModel().getSelectedItem());
}
});
Button editButton = new Button("Bearbeiten");
editButton.setOnAction(new AdditionalCustomerIDsDialogHandler(additionalCustomerIDsListView.getSelectionModel()));
// disable the add button if every type of ExternalSystem enum is already contained in the listView
additionalCustomerIDsListView.getItems().addListener((javafx.beans.Observable observable) -> {
addButton.setDisable(additionalCustomerIDsListView.getItems().stream().map(additionalCustomerID -> additionalCustomerID.type).collect(Collectors.toList()).containsAll(Arrays.asList(ExternalSystem.values())));
});
editButton.setDisable(true);
deleteButton.setDisable(true);
additionalCustomerIDsListView.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> {
editButton.setDisable(newValue.intValue() < 0);
deleteButton.setDisable(newValue.intValue() < 0);
});
HBox buttonsHBox = new HBox();
buttonsHBox.getChildren().addAll(addButton, editButton, deleteButton);
buttonsHBox.setSpacing(3.0);
additionalCustomerIDsVBox.getChildren().addAll(ExternalSystemIDsLabel, buttonsHBox, additionalCustomerIDsListView);
additionalCustomerIDsVBox.setMinWidth(120.0);
}
use of eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem in project dwoss by gg-net.
the class AdditionalcustomerIdsViewTryout method main.
public static void main(String[] args) {
UiCore.startSwing(() -> new JLabel("Main"));
Map<ExternalSystem, String> in = new HashMap<>();
in.put(ExternalSystem.SAGE, "123412");
Ui.exec(() -> {
Ui.build().dialog().eval(() -> in, () -> new AdditionalCustomerIdsView()).opt().ifPresent(System.out::println);
});
}
Aggregations