Search in sources :

Example 1 with Ui

use of eu.ggnet.saft.Ui in project dwoss by gg-net.

the class DocumentPrintAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Ui.exec(() -> {
        // TODO: This is a very special case, there the Ui needs the result on construction. So the consumer pattern cannot be used.
        // This meeans, for now no progress display.
        JasperPrint print = Dl.remote().lookup(DocumentSupporter.class).render(document, type);
        CustomerMetaData customer = Dl.remote().lookup(CustomerService.class).asCustomerMetaData(customerId);
        boolean mailAvailable = customer.getEmail() != null && !customer.getEmail().trim().isEmpty();
        Ui.exec(() -> {
            Ui.build().parent(controller.getView()).swing().eval(() -> new JRViewerCask(print, document, type, mailAvailable)).opt().filter(c -> c.isCorrectlyBriefed()).ifPresent(c -> Ui.progress().call(() -> {
                CustomerDocument customerDocument = new CustomerDocument(customer.getFlags(), document, customer.getShippingCondition(), customer.getPaymentMethod());
                for (StateTransition<CustomerDocument> stateTransition : Dl.remote().lookup(RedTapeWorker.class).getPossibleTransitions(customerDocument)) {
                    RedTapeStateTransition redTapeStateTransition = (RedTapeStateTransition) stateTransition;
                    for (RedTapeStateTransition.Hint hint : redTapeStateTransition.getHints()) {
                        if (hint == RedTapeStateTransition.Hint.SENDED_INFORMATION) {
                            this.document = Optional.of(Dl.remote().lookup(RedTapeWorker.class).stateChange(customerDocument, redTapeStateTransition, Lookup.getDefault().lookup(Guardian.class).getUsername())).filter(Ui.failure()::handle).map(Reply::getPayload).orElse(document);
                        }
                    }
                }
                controller.reloadSelectionOnStateChange(Dl.remote().lookup(DocumentSupporter.class).briefed(document, Dl.local().lookup(Guardian.class).getUsername()));
                return null;
            }));
        });
    });
}
Also used : Lookup(org.openide.util.Lookup) JasperPrint(net.sf.jasperreports.engine.JasperPrint) CustomerService(eu.ggnet.dwoss.customer.opi.CustomerService) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) DocumentViewType(eu.ggnet.dwoss.mandator.api.DocumentViewType) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) RedTapeController(eu.ggnet.dwoss.redtapext.ui.cao.RedTapeController) Ui(eu.ggnet.saft.Ui) ActionEvent(java.awt.event.ActionEvent) StateTransition(eu.ggnet.statemachine.StateTransition) Dl(eu.ggnet.saft.Dl) Guardian(eu.ggnet.saft.core.auth.Guardian) AbstractAction(javax.swing.AbstractAction) RedTapeStateTransition(eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) DocumentSupporter(eu.ggnet.dwoss.redtapext.ee.DocumentSupporter) Reply(eu.ggnet.saft.api.Reply) Optional(java.util.Optional) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument) CustomerService(eu.ggnet.dwoss.customer.opi.CustomerService) RedTapeStateTransition(eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition) DocumentSupporter(eu.ggnet.dwoss.redtapext.ee.DocumentSupporter) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) JasperPrint(net.sf.jasperreports.engine.JasperPrint) StateTransition(eu.ggnet.statemachine.StateTransition) RedTapeStateTransition(eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)

Example 2 with Ui

use of eu.ggnet.saft.Ui in project dwoss by gg-net.

the class DeleteUnitAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Ui.exec(() -> {
        Ui.build().title("SopoNr die gelöscht werden soll").dialog().eval(() -> {
            TextInputDialog dialog = new TextInputDialog();
            dialog.setContentText("SopoNr die gelöscht werden soll:");
            return dialog;
        }).opt().filter(s -> !StringUtils.isBlank(s)).ifPresent(r -> {
            Ui.build().dialog().eval(() -> new Alert(CONFIRMATION, "SopoNr " + r + " wirklich gelöschen ?")).opt().map(s -> ReplyUtil.wrap(() -> Dl.remote().lookup(UnitDestroyer.class).verifyScarpOrDeleteAble(r))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(u -> {
                Dl.remote().lookup(UnitDestroyer.class).delete(u, "Löschung aus UI", Dl.local().lookup(Guardian.class).getUsername());
                Ui.build().alert().message("SopoNr " + r + " ist gelöscht.").show(AlertType.INFO);
            });
        });
    });
}
Also used : Alert(javafx.scene.control.Alert) AccessableAction(eu.ggnet.saft.core.auth.AccessableAction) Ui(eu.ggnet.saft.Ui) DELETE_UNIQUE_UNIT(eu.ggnet.dwoss.rights.api.AtomicRight.DELETE_UNIQUE_UNIT) ActionEvent(java.awt.event.ActionEvent) StringUtils(org.apache.commons.lang3.StringUtils) Dl(eu.ggnet.saft.Dl) CONFIRMATION(javafx.scene.control.Alert.AlertType.CONFIRMATION) Guardian(eu.ggnet.saft.core.auth.Guardian) AlertType(eu.ggnet.saft.core.ui.AlertType) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Reply(eu.ggnet.saft.api.Reply) UnitDestroyer(eu.ggnet.dwoss.receipt.ee.UnitDestroyer) Alert(javafx.scene.control.Alert) UnitDestroyer(eu.ggnet.dwoss.receipt.ee.UnitDestroyer) TextInputDialog(javafx.scene.control.TextInputDialog)

Aggregations

Dl (eu.ggnet.saft.Dl)2 Ui (eu.ggnet.saft.Ui)2 Reply (eu.ggnet.saft.api.Reply)2 Guardian (eu.ggnet.saft.core.auth.Guardian)2 ActionEvent (java.awt.event.ActionEvent)2 ReplyUtil (eu.ggnet.dwoss.common.ReplyUtil)1 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)1 CustomerService (eu.ggnet.dwoss.customer.opi.CustomerService)1 DocumentViewType (eu.ggnet.dwoss.mandator.api.DocumentViewType)1 UnitDestroyer (eu.ggnet.dwoss.receipt.ee.UnitDestroyer)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 DocumentSupporter (eu.ggnet.dwoss.redtapext.ee.DocumentSupporter)1 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)1 CustomerDocument (eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)1 RedTapeStateTransition (eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition)1 RedTapeController (eu.ggnet.dwoss.redtapext.ui.cao.RedTapeController)1 DELETE_UNIQUE_UNIT (eu.ggnet.dwoss.rights.api.AtomicRight.DELETE_UNIQUE_UNIT)1 AccessableAction (eu.ggnet.saft.core.auth.AccessableAction)1 AlertType (eu.ggnet.saft.core.ui.AlertType)1 StateTransition (eu.ggnet.statemachine.StateTransition)1