Search in sources :

Example 1 with ExternalSystem

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);
}
Also used : EventHandler(javafx.event.EventHandler) ButtonData(javafx.scene.control.ButtonBar.ButtonData) java.util(java.util) javafx.collections(javafx.collections) Initializable(javafx.fxml.Initializable) ExternalSystem(eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) URL(java.net.URL) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) Source(eu.ggnet.dwoss.customer.ee.entity.Customer.Source) Sex(eu.ggnet.dwoss.customer.ee.entity.Contact.Sex) Ui(eu.ggnet.saft.Ui) InvalidationListener(javafx.beans.InvalidationListener) CustomerFlag(eu.ggnet.dwoss.rules.CustomerFlag) Insets(javafx.geometry.Insets) AlertType(javafx.scene.control.Alert.AlertType) WINDOW_MODAL(javafx.stage.Modality.WINDOW_MODAL) javafx.beans.property(javafx.beans.property) AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) eu.ggnet.dwoss.customer.ee.entity(eu.ggnet.dwoss.customer.ee.entity) Node(javafx.scene.Node) StringConverter(javafx.util.StringConverter) Collectors(java.util.stream.Collectors) eu.ggnet.saft.api.ui(eu.ggnet.saft.api.ui) Consumer(java.util.function.Consumer) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) Data(lombok.Data) AllArgsConstructor(lombok.AllArgsConstructor) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)

Example 2 with ExternalSystem

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);
    });
}
Also used : HashMap(java.util.HashMap) ExternalSystem(eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem) JLabel(javax.swing.JLabel) AdditionalCustomerIdsView(eu.ggnet.dwoss.customer.ui.old.AdditionalCustomerIdsView)

Aggregations

ExternalSystem (eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem)2 eu.ggnet.dwoss.customer.ee.entity (eu.ggnet.dwoss.customer.ee.entity)1 Sex (eu.ggnet.dwoss.customer.ee.entity.Contact.Sex)1 Source (eu.ggnet.dwoss.customer.ee.entity.Customer.Source)1 AddressLabel (eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)1 AdditionalCustomerIdsView (eu.ggnet.dwoss.customer.ui.old.AdditionalCustomerIdsView)1 CustomerFlag (eu.ggnet.dwoss.rules.CustomerFlag)1 Ui (eu.ggnet.saft.Ui)1 eu.ggnet.saft.api.ui (eu.ggnet.saft.api.ui)1 URL (java.net.URL)1 java.util (java.util)1 HashMap (java.util.HashMap)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Platform (javafx.application.Platform)1 InvalidationListener (javafx.beans.InvalidationListener)1 javafx.beans.property (javafx.beans.property)1 javafx.collections (javafx.collections)1 ActionEvent (javafx.event.ActionEvent)1 EventHandler (javafx.event.EventHandler)1