Search in sources :

Example 1 with CustomerContinue

use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.

the class CustomerSearchController method buildContextMenu.

/**
 * Build a ContextMenu for ListView of the search results for a better navigation
 *
 * @return ContextMenu the filled ContextMenu
 */
private ContextMenu buildContextMenu() {
    // Create a ContextMenu
    ContextMenu contextMenu = new ContextMenu();
    MenuItem viewCustomer = new MenuItem("Detailansicht");
    MenuItem viewCompleteCustomer = new MenuItem("Detailansicht inc. aller Mandatendetails");
    MenuItem editCustomer = new MenuItem("Bearbeiten");
    // adding actions to the context menu
    viewCustomer.setOnAction((ActionEvent event) -> {
        // open toHtml(String matchcode, DefaultCustomerSalesdata defaults)
        if (resultListView.getSelectionModel().getSelectedItem() == null)
            return;
        PicoCustomer selectedCustomer = resultListView.getSelectionModel().getSelectedItem();
        Ui.exec(() -> {
            Ui.build(statusHbox).title("Kunde mit Mandant").fx().show(() -> Css.toHtml5WithStyle(AGENT.findCustomerAsMandatorHtml(selectedCustomer.getId())), () -> new HtmlPane());
        });
    });
    viewCompleteCustomer.setOnAction((ActionEvent event) -> {
        // open toHtml(String salesRow, String comment)
        if (resultListView.getSelectionModel().getSelectedItem() == null)
            return;
        PicoCustomer selectedCustomer = resultListView.getSelectionModel().getSelectedItem();
        Ui.exec(() -> {
            Ui.build(statusHbox).title("Kunden Ansicht").fx().show(() -> Css.toHtml5WithStyle(AGENT.findCustomerAsHtml(selectedCustomer.getId())), () -> new HtmlPane());
        });
    });
    editCustomer.setOnAction((ActionEvent event) -> {
        if (resultListView.getSelectionModel().getSelectedItem() == null)
            return;
        PicoCustomer picoCustomer = resultListView.getSelectionModel().getSelectedItem();
        Ui.exec(() -> {
            Customer customer = Ui.progress().call(() -> AGENT.findByIdEager(Customer.class, picoCustomer.getId()));
            if (!customer.isValid()) {
                Ui.build(resultListView).title("Fehlerhafter Datensatz").alert().message("Kundendaten sind invalid (aktuell normal): " + customer.getViolationMessage()).show(AlertType.WARNING);
            } else if (customer.isSimple()) {
                L.info("Edit Simple Customer {}", customer.getId());
                Optional<CustomerContinue> result = Ui.build(resultListView).fxml().eval(() -> customer, CustomerSimpleController.class).opt();
                if (!result.isPresent())
                    return;
                Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
                if (!Ui.failure().handle(reply))
                    return;
                if (!result.get().continueEnhance)
                    return;
                Ui.build(statusHbox).fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build(statusHbox).alert("Would store + " + c));
            } else if (customer.isBusiness()) {
                L.info("Edit (Complex) Customer {}", customer.getId());
                Ui.build(statusHbox).fxml().eval(() -> customer, CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build(statusHbox).alert("Would store + " + c));
            }
        });
    });
    // add MenuItemes to ContextMenu
    contextMenu.getItems().addAll(viewCustomer, viewCompleteCustomer, editCustomer);
    return contextMenu;
}
Also used : java.util(java.util) Initializable(javafx.fxml.Initializable) javafx.scene.control(javafx.scene.control) URL(java.net.URL) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) CustomerContinue(eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue) Ui(eu.ggnet.saft.Ui) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) Dl(eu.ggnet.saft.Dl) AlertType(eu.ggnet.saft.core.ui.AlertType) READY(javafx.concurrent.Worker.State.READY) CustomerAgent(eu.ggnet.dwoss.customer.ee.CustomerAgent) KeyCode(javafx.scene.input.KeyCode) HBox(javafx.scene.layout.HBox) Logger(org.slf4j.Logger) Css(eu.ggnet.dwoss.rules.Css) CustomerTaskService(eu.ggnet.dwoss.customer.ui.CustomerTaskService) eu.ggnet.saft.api.ui(eu.ggnet.saft.api.ui) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) MAX_VALUE(java.lang.Double.MAX_VALUE) SearchField(eu.ggnet.dwoss.customer.ee.entity.Customer.SearchField) FxSaft(eu.ggnet.saft.core.ui.FxSaft) Reply(eu.ggnet.saft.api.Reply) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) HtmlPane(eu.ggnet.dwoss.util.HtmlPane) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) ActionEvent(javafx.event.ActionEvent) Reply(eu.ggnet.saft.api.Reply) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) HtmlPane(eu.ggnet.dwoss.util.HtmlPane)

Example 2 with CustomerContinue

use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.

the class CustomerSimpleController method saveAndCloseButtonHandling.

@FXML
private void saveAndCloseButtonHandling() {
    try {
        SimpleCustomer simpleCustomer = getSimpleCustomer();
        result = new CustomerContinue(getSimpleCustomer(), false);
        Ui.closeWindowOf(kid);
    } catch (IllegalStateException e) {
        Alert alert = new Alert(javafx.scene.control.Alert.AlertType.ERROR, e.getMessage(), OK);
        alert.show();
    }
}
Also used : SimpleCustomer(eu.ggnet.dwoss.customer.ee.entity.dto.SimpleCustomer) CustomerContinue(eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue) FXML(javafx.fxml.FXML)

Example 3 with CustomerContinue

use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.

the class CustomerSimpleTryout method main.

public static void main(String[] args) {
    // stub for the new Costumer modell with generator needed
    Dl.remote().add(CustomerAgent.class, new CustomerAgentStub());
    JButton close = new JButton("Schliessen");
    close.addActionListener(e -> Ui.closeWindowOf(close));
    JButton consumerCustomerButton = new JButton("Consumer Customer");
    consumerCustomerButton.addActionListener(ev -> {
        Customer consumerCustomer = makeValidCustomer();
        System.out.println("IS simple: " + consumerCustomer.getSimpleViolationMessage());
        System.out.println("Consumer Customer: " + consumerCustomer.isConsumer());
        Ui.exec(() -> {
            Optional<CustomerContinue> result = Ui.build().parent(consumerCustomerButton).fxml().eval(() -> consumerCustomer, CustomerSimpleController.class).opt();
            if (!result.isPresent())
                return;
            Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
            if (!Ui.failure().handle(reply))
                return;
            if (!result.get().continueEnhance)
                return;
            Ui.build().fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build().alert("Would store + " + c));
        });
    });
    JButton bussinesCustomer = new JButton("Bussines Customer");
    bussinesCustomer.addActionListener(ev -> {
        Customer bussnisCustomer = makeValidCustomer();
        Contact tempcon = bussnisCustomer.getContacts().get(0);
        Company company = gen.makeCompany();
        company.getContacts().clear();
        company.getContacts().add(tempcon);
        company.getCommunications().clear();
        bussnisCustomer.getContacts().clear();
        bussnisCustomer.getCompanies().add(company);
        System.out.println("IS simple: " + bussnisCustomer.getSimpleViolationMessage());
        System.out.println("Bussines Customer: " + bussnisCustomer.isBusiness());
        Ui.exec(() -> {
            Optional<CustomerContinue> result = Ui.build().parent(consumerCustomerButton).fxml().eval(() -> bussnisCustomer, CustomerSimpleController.class).opt();
            if (!result.isPresent())
                return;
            Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
            if (!Ui.failure().handle(reply))
                return;
            if (!result.get().continueEnhance)
                return;
            Ui.build().fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build().alert("Would store + " + c));
        });
    });
    JButton nullCustomer = new JButton(" Create SimpleCustomer");
    nullCustomer.addActionListener(ev -> {
        Ui.exec(() -> {
            Optional<CustomerContinue> result = Ui.build().parent(consumerCustomerButton).fxml().eval(CustomerSimpleController.class).opt();
            if (!result.isPresent())
                return;
            Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
            if (!Ui.failure().handle(reply))
                return;
            if (!result.get().continueEnhance)
                return;
            Ui.build().fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build().alert("Would store + " + c));
        });
    });
    JPanel p = new JPanel();
    p.add(consumerCustomerButton);
    p.add(bussinesCustomer);
    p.add(nullCustomer);
    p.add(close);
    UiCore.startSwing(() -> p);
}
Also used : JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) CustomerAgentStub(tryout.stub.CustomerAgentStub) CustomerAgent(eu.ggnet.dwoss.customer.ee.CustomerAgent) CustomerSimpleController(eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController) CustomerContinue(eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue)

Example 4 with CustomerContinue

use of eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue in project dwoss by gg-net.

the class CustomerSimpleController method saveAndEnhanceUIButtonHandling.

@FXML
private void saveAndEnhanceUIButtonHandling() {
    try {
        SimpleCustomer simpleCustomer = getSimpleCustomer();
        result = new CustomerContinue(getSimpleCustomer(), true);
        Ui.closeWindowOf(kid);
    } catch (IllegalStateException e) {
        Alert alert = new Alert(javafx.scene.control.Alert.AlertType.ERROR, e.getMessage(), OK);
        alert.show();
    }
}
Also used : SimpleCustomer(eu.ggnet.dwoss.customer.ee.entity.dto.SimpleCustomer) CustomerContinue(eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue) FXML(javafx.fxml.FXML)

Aggregations

CustomerContinue (eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue)4 FXML (javafx.fxml.FXML)3 CustomerAgent (eu.ggnet.dwoss.customer.ee.CustomerAgent)2 SimpleCustomer (eu.ggnet.dwoss.customer.ee.entity.dto.SimpleCustomer)2 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)1 SearchField (eu.ggnet.dwoss.customer.ee.entity.Customer.SearchField)1 PicoCustomer (eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer)1 CustomerTaskService (eu.ggnet.dwoss.customer.ui.CustomerTaskService)1 CustomerSimpleController (eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController)1 Css (eu.ggnet.dwoss.rules.Css)1 HtmlPane (eu.ggnet.dwoss.util.HtmlPane)1 Dl (eu.ggnet.saft.Dl)1 Ui (eu.ggnet.saft.Ui)1 Reply (eu.ggnet.saft.api.Reply)1 eu.ggnet.saft.api.ui (eu.ggnet.saft.api.ui)1 AlertType (eu.ggnet.saft.core.ui.AlertType)1 FxSaft (eu.ggnet.saft.core.ui.FxSaft)1 MAX_VALUE (java.lang.Double.MAX_VALUE)1 URL (java.net.URL)1 java.util (java.util)1