Search in sources :

Example 31 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project dwoss by gg-net.

the class PriceBlockerAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Ui.exec(() -> {
        Optional<String> sopoOptional = Ui.build().dialog().eval(() -> {
            TextInputDialog dialog = new TextInputDialog();
            dialog.setTitle("SopoNr Eingabe");
            dialog.setHeaderText("SopoNr:");
            dialog.setContentText("Bitte SopoNr zur Fixierung eines Preises eingeben:");
            return dialog;
        }).opt();
        sopoOptional.map(sopoNr -> ReplyUtil.wrap(() -> Dl.remote().lookup(Exporter.class).load(sopoNr))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(priceEngineResult -> {
            PriceBlockerViewCask pbp = new PriceBlockerViewCask(sopoOptional.get(), priceEngineResult.getProductDescription(), priceEngineResult.getCustomerPrice(), priceEngineResult.getRetailerPrice());
            Ui.build().swing().eval(() -> OkCancelWrap.vetoResult(pbp)).opt().ifPresent(reply -> {
                priceEngineResult.setCustomerPrice(pbp.getCustomerPrice());
                priceEngineResult.setRetailerPrice(pbp.getRetailerPrice());
                priceEngineResult.setUnitPriceFixed(Change.SET);
                Dl.remote().lookup(Importer.class).store(priceEngineResult, "Set directly via PriceBlocker", Dl.local().lookup(Guardian.class).getUsername());
            });
        });
    });
}
Also used : Change(eu.ggnet.dwoss.price.engine.PriceEngineResult.Change) Dl(eu.ggnet.saft.Dl) Guardian(eu.ggnet.saft.core.auth.Guardian) UPDATE_SET_UNIT_PRICE(eu.ggnet.dwoss.rights.api.AtomicRight.UPDATE_SET_UNIT_PRICE) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Reply(eu.ggnet.saft.api.Reply) OkCancelWrap(eu.ggnet.saft.core.swing.OkCancelWrap) AccessableAction(eu.ggnet.saft.core.auth.AccessableAction) Optional(java.util.Optional) Ui(eu.ggnet.saft.Ui) ActionEvent(java.awt.event.ActionEvent) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 32 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project dwoss by gg-net.

the class ScrapUnitAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Ui.exec(() -> {
        Ui.build().title("SopoNr die verschrottet werden soll").dialog().eval(() -> {
            TextInputDialog dialog = new TextInputDialog();
            dialog.setContentText("SopoNr die verschrottet werden soll:");
            return dialog;
        }).opt().filter(s -> !StringUtils.isBlank(s)).ifPresent(r -> {
            Ui.build().dialog().eval(() -> new Alert(CONFIRMATION, "SopoNr " + r + " wirklich verschrotten ?")).opt().filter(b -> b == OK).map(u -> ReplyUtil.wrap(() -> Dl.remote().lookup(UnitDestroyer.class).verifyScarpOrDeleteAble(r))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(u -> {
                Ui.build().title("Bitte Grund angeben").dialog().eval(() -> {
                    TextInputDialog dialog = new TextInputDialog();
                    dialog.setContentText("Bitte Grund angeben");
                    dialog.getDialogPane().lookupButton(OK).disableProperty().bind(Bindings.createBooleanBinding(() -> dialog.getEditor().getText().trim().isEmpty(), dialog.getEditor().textProperty()));
                    return dialog;
                }).opt().filter(s -> !StringUtils.isBlank(s)).ifPresent(c -> {
                    Dl.remote().lookup(UnitDestroyer.class).scrap(u, c, Dl.local().lookup(Guardian.class).getUsername());
                    Ui.build().alert().message("SopoNr " + r + " ist verschrottet.").show(AlertType.INFO);
                });
            });
        });
    });
}
Also used : Alert(javafx.scene.control.Alert) UPDATE_UNIQUE_UNIT_TO_SCRAP_UNIT(eu.ggnet.dwoss.rights.api.AtomicRight.UPDATE_UNIQUE_UNIT_TO_SCRAP_UNIT) AccessableAction(eu.ggnet.saft.core.auth.AccessableAction) Ui(eu.ggnet.saft.Ui) ActionEvent(java.awt.event.ActionEvent) Bindings(javafx.beans.binding.Bindings) 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) OK(javafx.scene.control.ButtonType.OK) Alert(javafx.scene.control.Alert) UnitDestroyer(eu.ggnet.dwoss.receipt.ee.UnitDestroyer) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 33 with TextInputDialog

use of javafx.scene.control.TextInputDialog 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)

Example 34 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project dwoss by gg-net.

the class UpdateProductAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Ui.exec(() -> {
        Ui.build().title("Bitte Artikelnummer des Herstellers eingeben").dialog().eval(() -> {
            TextInputDialog dialog = new TextInputDialog();
            dialog.setContentText("Bitte Artikelnummer des Herstellers eingeben:");
            return dialog;
        }).opt().map(s -> ReplyUtil.wrap(() -> Dl.remote().lookup(UniqueUnitAgent.class).findProductByPartNo(s))).filter(Ui.failure()::handle).map(Reply::getPayload).map(p -> ReplyUtil.wrap(() -> UiProductSupport.createOrEditPart(p.getTradeName().getManufacturer(), p.getPartNo(), UiCore.getMainFrame()))).filter(Ui.failure()::handle);
    });
}
Also used : UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Reply(eu.ggnet.saft.api.Reply) AccessableAction(eu.ggnet.saft.core.auth.AccessableAction) UiProductSupport(eu.ggnet.dwoss.receipt.UiProductSupport) ActionEvent(java.awt.event.ActionEvent) eu.ggnet.saft(eu.ggnet.saft) UPDATE_PRODUCT(eu.ggnet.dwoss.rights.api.AtomicRight.UPDATE_PRODUCT) Reply(eu.ggnet.saft.api.Reply) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 35 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project Smartcity-Smarthouse by TechnionYP5777.

the class MappingController method drawMapping.

private void drawMapping() {
    final GraphicsContext g = canvas.getGraphicsContext2D();
    g.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
    g.setFont(new Font(14.0));
    g.setStroke(Color.BLACK);
    for (final Room room : mappingInformaton.getHouse().getRooms()) {
        g.strokeRect(room.x, room.y, room.width, room.height);
        g.strokeLine(room.x, room.y + 20, room.x + room.width, room.y + 20);
        g.setFill(Color.BLACK);
        g.fillText(room.location, room.x + 4, room.y + 15);
        if (mappingInformaton.getLocationsContents().containsKey(room.location)) {
            int dy = 20;
            for (final Pair<String, String> p : mappingInformaton.getLocationsContents().get(room.location)) {
                String alias = this.getModel().getFileSystem().getData(getPath_alias(p.getKey(), p.getValue()));
                g.fillText(" (" + alias + ")", room.x + 10, room.y + dy + 20);
                dy += 20;
            }
        }
    }
    int xPlusRoom = mappingInformaton.calcxPlusRoom(), yPlusRoom = mappingInformaton.calcyPlusRoom();
    g.strokeRect(xPlusRoom, yPlusRoom, MappingInformation.getWidth(), MappingInformation.getHeight());
    g.setFont(new Font(45.0));
    g.fillText("+", xPlusRoom + 150, yPlusRoom + 85);
    g.setFill(Color.BLUE);
    g.setFont(new Font(84.0));
    canvas.setOnMouseClicked(mouseEvent -> {
        double x = mouseEvent.getX(), y = mouseEvent.getY();
        if (mouseEvent.getButton() == MouseButton.SECONDARY) {
            mappingInformaton.getHouse().getRooms().forEach(r -> {
                if (x > r.x && x < r.x + MappingInformation.getWidth() && y > r.y && y < r.y + MappingInformation.getHeight()) {
                    if (r.location.equals(SensorLocation.UNDEFINED))
                        return;
                    final TextInputDialog dialog = new TextInputDialog(r.location);
                    dialog.setTitle("Update Room");
                    dialog.setHeaderText("Config your smarthouse");
                    dialog.setContentText("Please enter new room name:");
                    final Optional<String> result = dialog.showAndWait();
                    if (!result.isPresent())
                        return;
                    final String name = result.get();
                    mappingInformaton.getAllLocations().add(name);
                    List<Pair<String, String>> currSensors = mappingInformaton.getLocationsContents().get(r.location);
                    mappingInformaton.getAllLocations().remove(r.location);
                    mappingInformaton.getLocationsContents().remove(r.location);
                    r.location = name;
                    sensors.values().forEach(e -> e.updateRooms());
                    for (Pair<String, String> p : currSensors) sensors.get(p.getKey()).setLocation(name);
                }
            });
            return;
        }
        if (x > xPlusRoom && x < xPlusRoom + MappingInformation.getWidth() && y > yPlusRoom && y < yPlusRoom + MappingInformation.getHeight()) {
            final TextInputDialog dialog = new TextInputDialog("rooms name");
            dialog.setTitle("Create Room");
            dialog.setHeaderText("Config your smarthouse");
            dialog.setContentText("Please enter room name:");
            final Optional<String> result = dialog.showAndWait();
            if (!result.isPresent())
                return;
            final String name = result.get();
            addRoom(name);
        }
    });
}
Also used : GraphicsContext(javafx.scene.canvas.GraphicsContext) Font(javafx.scene.text.Font) TextInputDialog(javafx.scene.control.TextInputDialog) Pair(javafx.util.Pair)

Aggregations

TextInputDialog (javafx.scene.control.TextInputDialog)38 Alert (javafx.scene.control.Alert)12 FXML (javafx.fxml.FXML)9 ActionEvent (javafx.event.ActionEvent)8 EventHandler (javafx.event.EventHandler)8 KeyFrame (javafx.animation.KeyFrame)7 Timeline (javafx.animation.Timeline)7 Stage (javafx.stage.Stage)7 ReplyUtil (eu.ggnet.dwoss.common.ReplyUtil)6 AccessableAction (eu.ggnet.saft.core.auth.AccessableAction)6 ActionEvent (java.awt.event.ActionEvent)6 Dl (eu.ggnet.saft.Dl)5 Ui (eu.ggnet.saft.Ui)5 Reply (eu.ggnet.saft.api.Reply)5 IOException (java.io.IOException)4 Guardian (eu.ggnet.saft.core.auth.Guardian)3 Point (java.awt.Point)3 Optional (java.util.Optional)3 StringUtils (org.apache.commons.lang3.StringUtils)3 CircuitState (com.cas.sim.tis.app.state.CircuitState)2