|
26 | 26 | import javafx.scene.control.DialogPane; |
27 | 27 | import javafx.scene.control.Label; |
28 | 28 | import javafx.scene.control.TextInputDialog; |
| 29 | +import javafx.scene.layout.HBox; |
29 | 30 | import javafx.scene.layout.Pane; |
30 | 31 | import javafx.scene.layout.Region; |
31 | 32 | import javafx.scene.layout.VBox; |
|
49 | 50 | import com.tobiasdiez.easybind.EasyBind; |
50 | 51 | import org.controlsfx.control.Notifications; |
51 | 52 | import org.controlsfx.control.TaskProgressView; |
| 53 | +import org.controlsfx.control.textfield.CustomPasswordField; |
52 | 54 | import org.controlsfx.dialog.ExceptionDialog; |
53 | 55 | import org.controlsfx.dialog.ProgressDialog; |
54 | 56 | import org.slf4j.Logger; |
@@ -270,6 +272,30 @@ public <R> Optional<R> showCustomDialogAndWait(javafx.scene.control.Dialog<R> di |
270 | 272 | return dialog.showAndWait(); |
271 | 273 | } |
272 | 274 |
|
| 275 | + @Override |
| 276 | + public Optional<String> showPasswordDialogAndWait(String title, String header, String content) { |
| 277 | + javafx.scene.control.Dialog<String> dialog = new javafx.scene.control.Dialog<>(); |
| 278 | + dialog.setTitle(title); |
| 279 | + dialog.setHeaderText(header); |
| 280 | + |
| 281 | + CustomPasswordField passwordField = new CustomPasswordField(); |
| 282 | + |
| 283 | + HBox box = new HBox(); |
| 284 | + box.setSpacing(10); |
| 285 | + box.getChildren().addAll(new Label(content), passwordField); |
| 286 | + dialog.setTitle(title); |
| 287 | + dialog.getDialogPane().setContent(box); |
| 288 | + |
| 289 | + dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK); |
| 290 | + dialog.setResultConverter(dialogButton -> { |
| 291 | + if (dialogButton == ButtonType.OK) { |
| 292 | + return passwordField.getText(); |
| 293 | + } |
| 294 | + return null; |
| 295 | + }); |
| 296 | + return dialog.showAndWait(); |
| 297 | + } |
| 298 | + |
273 | 299 | @Override |
274 | 300 | public <V> void showProgressDialog(String title, String content, Task<V> task) { |
275 | 301 | ProgressDialog progressDialog = new ProgressDialog(task); |
|
0 commit comments