Search in sources :

Example 16 with TextInputDialog

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

the class MakeATransactionController method exCreateSectorBtn.

// function for creating a sector
@FXML
private void exCreateSectorBtn(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog();
    dialog.setTitle("Create Sector");
    dialog.setHeaderText("Create your expenditure sector, where you expense Tk.");
    dialog.setContentText("Please Type a Name :");
    Stage MakeATransactionStage = (Stage) exbtnCreateSector.getScene().getWindow();
    dialog.setX(MakeATransactionStage.getX() + 150);
    dialog.setY(MakeATransactionStage.getY() + 170);
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        String typedName = result.get();
        if (typedName.length() == 0) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Operation Failed");
            alert.setHeaderText(null);
            alert.setContentText("Write a Sector Name Please");
            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();
        } else if (countWords(typedName) == 0) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Operation Failed");
            alert.setHeaderText(null);
            alert.setContentText("Write a Sector Name Please");
            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();
        } else if (new Sector().createSector(typedName)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Operation Failed");
            alert.setHeaderText(null);
            alert.setContentText("Sector Name Already Exist");
            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();
        } else {
            new Sector().createSector(typedName);
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Message");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Sector " + typedName + " created successfully");
            confirmationMsg.setX(MakeATransactionStage.getX() + 200);
            confirmationMsg.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    confirmationMsg.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            confirmationMsg.showAndWait();
            exLoadSector();
            excmboSector.getSelectionModel().selectLast();
        }
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Sector(tab.Sector) 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)

Example 17 with TextInputDialog

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

the class MakeATransactionController method bnkAdjustBalAction.

@FXML
private void bnkAdjustBalAction(ActionEvent event) {
    if (bnkSelectedTabName.equals("bKash")) {
        TextInputDialog dialog = new TextInputDialog();
        dialog.setTitle("Adjust bKash Balance");
        dialog.setHeaderText("Provide Balance Status at Your bKash Account.");
        dialog.setContentText("Please enter the amount:");
        Stage MakeATransactionStage = (Stage) bkbtnAdjustBalance.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(3), 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(3), new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent event) {
                        alert.hide();
                    }
                }));
                idlestage.setCycleCount(1);
                idlestage.play();
                alert.showAndWait();
            } else {
                bnkAdjustBtnPressed = true;
                long dbbKashBalance = currentbKashBalance();
                long typedBalance = stringToLong(typedAmount);
                bnkAdjustBalAfter = typedAmount;
                if (dbbKashBalance < typedBalance) {
                    bnkAdjustAmount = "added " + longToString(typedBalance - dbbKashBalance) + " to Account";
                } else if (dbbKashBalance > typedBalance) {
                    bnkAdjustAmount = UnitConverter.longToString((dbbKashBalance - typedBalance));
                } else {
                    bnkAdjustAmount = "0.00";
                }
                bnkSaveFunction();
            }
        }
    } else if (bnkSelectedTabName.equals("Rocket")) {
        TextInputDialog dialog = new TextInputDialog();
        dialog.setTitle("Adjust Rocket Balance");
        dialog.setHeaderText("Provide Balance Status at Your Rocket Account.");
        dialog.setContentText("Please enter the amount:");
        Stage MakeATransactionStage = (Stage) rocbtnAdjustBalance.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(3), 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(3), new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent event) {
                        alert.hide();
                    }
                }));
                idlestage.setCycleCount(1);
                idlestage.play();
                alert.showAndWait();
            } else {
                bnkAdjustBtnPressed = true;
                long dbrocketBalance = currentRocketBalance();
                long typedBalance = stringToLong(typedAmount);
                bnkAdjustBalAfter = typedAmount;
                if (dbrocketBalance < typedBalance) {
                    bnkAdjustAmount = "added " + longToString(typedBalance - dbrocketBalance) + " to Account";
                } else if (dbrocketBalance > typedBalance) {
                    bnkAdjustAmount = UnitConverter.longToString((dbrocketBalance - typedBalance));
                } else {
                    bnkAdjustAmount = "0.00";
                }
                bnkSaveFunction();
            }
        }
    }
    bnkAdjustBtnPressed = false;
}
Also used : Optional(java.util.Optional) ActionEvent(javafx.event.ActionEvent) EventHandler(javafx.event.EventHandler) Timeline(javafx.animation.Timeline) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) TextInputDialog(javafx.scene.control.TextInputDialog) FXML(javafx.fxml.FXML)

Example 18 with TextInputDialog

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

the class MakeATransactionController method exAdjustBalance.

// this function will let user to adjust their balance
@FXML
private void exAdjustBalance(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(3), 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(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            adjustBtnPressed = true;
            long dbWalletBalance = currentWalletBalance();
            long typedBalance = stringToLong(typedAmount);
            exAdjustBalAfter = typedAmount;
            if (dbWalletBalance < typedBalance) {
                exAdjustAmount = "added " + longToString(typedBalance - dbWalletBalance) + " to Wallet";
            } else if (dbWalletBalance > typedBalance) {
                exAdjustAmount = exWalletBalanceAfter(typedAmount);
            } else {
                exAdjustAmount = "0.0";
            }
            exSaveFunction();
        }
    }
    adjustBtnPressed = false;
}
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)

Example 19 with TextInputDialog

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

the class SettingsController method changePassword.

@FXML
private void changePassword(ActionEvent event) {
    try {
        if (!passwordChangeClicked) {
            TextInputDialog dialog = new TextInputDialog();
            dialog.setTitle("Password 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())) {
                    systemtxtPassword.setDisable(false);
                    systemtxtPassword.clear();
                    systemlblRePassword.setVisible(true);
                    systemtxtRePassword.setVisible(true);
                    systembtnChangePassword.setText("Save Password");
                    passwordChangeClicked = 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(2), new EventHandler<ActionEvent>() {

                        @Override
                        public void handle(ActionEvent event) {
                            alert.hide();
                        }
                    }));
                    idlestage.setCycleCount(1);
                    idlestage.play();
                    alert.showAndWait();
                }
            }
        } else {
            if (!systemtxtPassword.getText().equals(systemtxtRePassword.getText())) {
                systemlblWarningMsg.setText("Password didn't match");
            } else {
                setPassword(systemtxtPassword.getText());
                passwordChangeClicked = 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();
                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)

Example 20 with TextInputDialog

use of javafx.scene.control.TextInputDialog in project blue by kunstmusik.

the class PresetPane method addPreset.

/**
 * @param currentPresetGroup
 */
private void addPreset(PresetGroup currentPresetGroup) {
    TextInputDialog dlg = new TextInputDialog();
    dlg.setTitle("Enter Preset Name");
    dlg.setHeaderText("Enter Preset Name");
    dlg.setGraphic(null);
    BlueFX.style(dlg.getDialogPane());
    Optional<String> str = dlg.showAndWait();
    if (!str.isPresent() || str.get().length() == 0) {
        return;
    }
    Preset preset = Preset.createPreset(bsbInterface);
    preset.setPresetName(str.get());
    currentPresetGroup.getPresets().add(preset);
    Collections.sort(currentPresetGroup.getPresets());
    getPresetGroup().setCurrentPresetUniqueId(preset.getUniqueId());
    getPresetGroup().setCurrentPresetModified(false);
    updatePresetMenu();
    updateCurrentPresetUI();
}
Also used : Preset(blue.orchestra.blueSynthBuilder.Preset) TextInputDialog(javafx.scene.control.TextInputDialog)

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