Search in sources :

Example 1 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project TeachingInSimulation by ScOrPiOzzy.

the class TypicalCase3D method showPopupMenu.

/**
 * 显示元器件弹出菜单
 * @param def
 */
public void showPopupMenu(ElecCompDef def) {
    ContextMenu menu = null;
    String key = def.getProxy().getUuid();
    if (menus.containsKey(key)) {
        menu = menus.get(key);
    } else {
        MenuItem tag = new MenuItem(MsgUtil.getMessage("button.tag"));
        tag.setOnAction(e -> {
            TextInputDialog steamIdDialog = new TextInputDialog(def.getProxy().getTagName());
            steamIdDialog.setTitle(MsgUtil.getMessage("button.tag"));
            steamIdDialog.setHeaderText(null);
            steamIdDialog.getEditor().textProperty().addListener((b, o, n) -> {
                Pattern pat = Pattern.compile(REGEX_CHINESE);
                Matcher mat = pat.matcher(n);
                if (mat.find()) {
                    steamIdDialog.getEditor().setText(o);
                }
            });
            steamIdDialog.setContentText(MsgUtil.getMessage("typical.case.prompt.input.comp.tag"));
            steamIdDialog.showAndWait().ifPresent(tagName -> {
                def.getProxy().setTagName(tagName);
                CircuitState state = jmeApp.getStateManager().getState(CircuitState.class);
                if (state == null) {
                    return;
                }
                state.setTagNameChanged(true);
            });
        });
        MenuItem del = new MenuItem(MsgUtil.getMessage("button.delete"));
        del.setOnAction(e -> {
            CircuitState state = jmeApp.getStateManager().getState(CircuitState.class);
            if (state == null) {
                return;
            }
            boolean enable = state.detachFromCircuit(def);
            if (enable) {
                menus.remove(key);
            } else {
                AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.wiring"));
            }
        });
        menu = new ContextMenu(tag, del);
    }
    Point anchor = MouseInfo.getPointerInfo().getLocation();
    menu.show(GUIState.getStage(), anchor.x, anchor.y);
}
Also used : CircuitState(com.cas.sim.tis.app.state.CircuitState) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Point(java.awt.Point) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 2 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project jphp by jphp-compiler.

the class UXDialog method input.

@Signature
public static String input(String text, String defaultValue, Window owner) {
    TextInputDialog dialog = new TextInputDialog(defaultValue);
    if (owner != null) {
        dialog.initOwner(owner);
    }
    dialog.setContentText(text);
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        return result.get();
    }
    return null;
}
Also used : TextInputDialog(javafx.scene.control.TextInputDialog) Signature(php.runtime.annotation.Reflection.Signature)

Example 3 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project graphysica by Graphysica.

the class MainApp method showDialog.

public void showDialog() {
    Dialog dialog = new TextInputDialog();
    dialog.setHeaderText("Nouveau fichier");
    dialog.setContentText("Titre: ");
    dialog.setTitle("Nouveau fichier");
    dialog.showAndWait().get();
}
Also used : Dialog(javafx.scene.control.Dialog) TextInputDialog(javafx.scene.control.TextInputDialog) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 4 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project Money-Manager by krHasan.

the class MakeATransactionController method exbtnAdvancedAdjustBalance.

@FXML
private void exbtnAdvancedAdjustBalance(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog();
    dialog.setTitle("Adjust Wallet Balance");
    dialog.setHeaderText("Provide Balance Status at Your Hand Now.");
    dialog.setContentText("Please enter the amount:");
    Stage MakeATransactionStage = (Stage) exbtnAdjustBalance.getScene().getWindow();
    dialog.setX(MakeATransactionStage.getX() + 200);
    dialog.setY(MakeATransactionStage.getY() + 170);
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        String typedAmount = result.get();
        if (!validAmount(typedAmount)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText(InvalidInput);
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else if (amountIsZero(typedAmount)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("Zero is not approved.");
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            long dbWalletBalance = currentWalletBalance();
            long typedBalance = stringToLong(typedAmount);
            String exAdvAdjustBalAfter = typedAmount;
            String exAdvAdjustAmount;
            if (dbWalletBalance < typedBalance) {
                exAdvAdjustAmount = "added " + longToString(typedBalance - dbWalletBalance) + " to Wallet";
            } else if (dbWalletBalance > typedBalance) {
                exAdvAdjustAmount = exWalletBalanceAfter(typedAmount);
            } else {
                exAdvAdjustAmount = "0.0";
            }
            try {
                Map<String, String> expenseData = new HashMap<>();
                expenseData.put("exTime", timeToSave());
                expenseData.put("exDate", (new DateFormatManager()).toString(exdateAdvancedDate.getValue()));
                expenseData.put("exMonth", monthToSave(exdateAdvancedDate.getValue()));
                expenseData.put("exAmount", exAdvAdjustAmount);
                if (exIsAdvDescripionEmpty()) {
                    expenseData.put("exDescription", "You have adjusted your Wallet Balance");
                } else {
                    expenseData.put("exDescription", extxtAdvancedDescription.getText());
                }
                expenseData.put("exSector", "Adjusted Balance");
                expenseData.put("exWalletBalanceBefore", getWalletBalance());
                expenseData.put("exWalletBalanceAfter", exAdvAdjustBalAfter);
                setCurrentWalletBalance(exAdvAdjustBalAfter);
                (new Expense()).saveExpenseData(expenseData);
                (new ComboboxList()).setAllMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
                (new ComboboxList()).setAllExMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
                exInitialize();
                extxtAdvancedDescription.clear();
                Alert confirmationMsg = new Alert(AlertType.INFORMATION);
                confirmationMsg.setTitle("Successfull Transaction");
                confirmationMsg.setHeaderText(null);
                confirmationMsg.setContentText("Successful");
                confirmationMsg.setX(MakeATransactionStage.getX() + 200);
                confirmationMsg.setY(MakeATransactionStage.getY() + 29);
                Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent event) {
                        confirmationMsg.hide();
                    }
                }));
                idlestage.setCycleCount(1);
                idlestage.play();
                confirmationMsg.showAndWait();
            } catch (Exception e) {
                Alert alert = new Alert(AlertType.WARNING);
                alert.setTitle("Transaction Failed");
                alert.setHeaderText(null);
                alert.setContentText("There something is wrong.");
                alert.setX(MakeATransactionStage.getX() + 200);
                alert.setY(MakeATransactionStage.getY() + 170);
                Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent event) {
                        alert.hide();
                    }
                }));
                idlestage.setCycleCount(1);
                idlestage.play();
                alert.showAndWait();
            }
        }
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) DateFormatManager(system.DateFormatManager) EventHandler(javafx.event.EventHandler) Timeline(javafx.animation.Timeline) Expense(tab.Expense) ComboboxList(operation.ComboboxList) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) Map(java.util.Map) HashMap(java.util.HashMap) TextInputDialog(javafx.scene.control.TextInputDialog) FXML(javafx.fxml.FXML)

Example 5 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project Money-Manager by krHasan.

the class SettingsController method changeName.

@FXML
private void changeName(ActionEvent event) {
    try {
        if (!nameChangeClicked) {
            TextInputDialog dialog = new TextInputDialog();
            dialog.setTitle("Name Change");
            dialog.setHeaderText("Enter password for authentication");
            dialog.setContentText("Your Password :");
            Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
            dialog.setX(SettingsStage.getX() + 200);
            dialog.setY(SettingsStage.getY() + 170);
            Optional<String> result = dialog.showAndWait();
            if (result.isPresent()) {
                if (getPassword().equals(result.get())) {
                    systemtxtName.setDisable(false);
                    systembtnChangeName.setText("Save Name");
                    nameChangeClicked = true;
                } else {
                    Alert alert = new Alert(AlertType.WARNING);
                    alert.setTitle("Message");
                    alert.setHeaderText(null);
                    alert.setContentText("Wrong Password");
                    alert.setX(SettingsStage.getX() + 200);
                    alert.setY(SettingsStage.getY() + 170);
                    Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                        @Override
                        public void handle(ActionEvent event) {
                            alert.hide();
                        }
                    }));
                    idlestage.setCycleCount(1);
                    idlestage.play();
                    alert.showAndWait();
                }
            }
        } else {
            setUserFullName(systemtxtName.getText());
            nameChangeClicked = false;
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Message");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Information updated successfully");
            Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
            confirmationMsg.setX(SettingsStage.getX() + 200);
            confirmationMsg.setY(SettingsStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    confirmationMsg.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            confirmationMsg.showAndWait();
            lblUserFullName.setText(getUserFullName());
            tabSystemInitialize();
        }
    } catch (Exception e) {
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) Alert(javafx.scene.control.Alert) TextInputDialog(javafx.scene.control.TextInputDialog) FXML(javafx.fxml.FXML)

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