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