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());
});
});
});
}
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);
});
});
});
});
}
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);
});
});
});
}
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);
});
}
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);
}
});
}
Aggregations