Search in sources :

Example 1 with UiParent

use of eu.ggnet.saft.core.ui.UiParent in project dwoss by gg-net.

the class OldCustomerUpi method updateCustomer.

@Override
public boolean updateCustomer(UiParent parent, long customerId) {
    OldCustomer customer = Dl.remote().lookup(OldCustomerAgent.class).findById(customerId);
    CustomerEditView ec = new CustomerEditView();
    ec.setCustomer(customer);
    // HINT: This was RedTapeView as parrent. If users complain about the location of create customer, add it to Workspace or else.
    OkCancelDialog<CustomerEditView> dialog = new OkCancelDialog<>(SwingCore.windowAncestor(Optional.ofNullable(parent).map(UiParent::swingOrMain).orElse(null)).orElse(SwingCore.mainFrame()), Dialog.ModalityType.DOCUMENT_MODAL, "Kunden editieren", ec);
    dialog.setVisible(true);
    boolean changed = false;
    if (dialog.getCloseType() == CloseType.OK) {
        Dl.remote().lookup(OldCustomerAgent.class).store(ec.getCustomer());
        for (AddressChange addressChange : ec.getChangedAdresses()) {
            if (JOptionPane.showOptionDialog(dialog, "Adresse wurde geändert, soll diese Änderung an allen Dokumenten des Kunden übernommen werden?", "Adressänderung", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null) == JOptionPane.YES_OPTION) {
                Dl.remote().lookup(AddressService.class).notifyAddressChange(addressChange);
            }
            changed = true;
        }
    }
    return changed;
}
Also used : OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) OldCustomerAgent(eu.ggnet.dwoss.customer.ee.priv.OldCustomerAgent) AddressService(eu.ggnet.dwoss.customer.opi.AddressService) AddressChange(eu.ggnet.dwoss.event.AddressChange) OkCancelDialog(eu.ggnet.dwoss.util.OkCancelDialog) UiParent(eu.ggnet.saft.core.ui.UiParent)

Aggregations

OldCustomer (eu.ggnet.dwoss.customer.ee.priv.OldCustomer)1 OldCustomerAgent (eu.ggnet.dwoss.customer.ee.priv.OldCustomerAgent)1 AddressService (eu.ggnet.dwoss.customer.opi.AddressService)1 AddressChange (eu.ggnet.dwoss.event.AddressChange)1 OkCancelDialog (eu.ggnet.dwoss.util.OkCancelDialog)1 UiParent (eu.ggnet.saft.core.ui.UiParent)1