-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathDialogService.java
133 lines (115 loc) · 5.16 KB
/
DialogService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package org.jabref.gui;
import java.nio.file.Path;
import java.util.Optional;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
/**
* This interface provides methods to create dialogs and show them to the user.
*/
public interface DialogService {
/**
* This will create and display a new information dialog.
* It will include a blue information icon on the left and
* a single OK Button. To create an information dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*/
void showInformationDialogAndWait(String title, String content);
/**
* This will create and display a new information dialog.
* It will include a yellow warning icon on the left and
* a single OK Button. To create a warning dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*/
void showWarningDialogAndWait(String title, String content);
/**
* This will create and display a new error dialog.
* It will include a red error icon on the left and
* a single OK Button. To create a error dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*/
void showErrorDialogAndWait(String title, String content);
/**
* Create and display error dialog displaying the given exception.
* @param message the error message
* @param exception the exception causing the error
*/
void showErrorDialogAndWait(String message, Throwable exception);
/**
* Create and display error dialog displaying the given exception.
* @param exception the exception causing the error
*/
default void showErrorDialogAndWait(Exception exception) {
showErrorDialogAndWait(Localization.lang("Unhandled exception occurred."), exception);
}
/**
* Create and display error dialog displaying the given message.
* @param message the error message
*/
void showErrorDialogAndWait(String message);
/**
* This will create and display a new confirmation dialog.
* It will include a blue question icon on the left and
* a OK and Cancel Button. To create a confirmation dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*
* @return true if the use clicked "OK" otherwise false
*/
boolean showConfirmationDialogAndWait(String title, String content);
/**
* Create and display a new confirmation dialog.
* It will include a blue question icon on the left and
* a OK (with given label) and Cancel Button. To create a confirmation dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*
* @return true if the use clicked "OK" otherwise false
*/
boolean showConfirmationDialogAndWait(String title, String content, String okButtonLabel);
/**
* This will create and display a new dialog of the specified
* {@link Alert.AlertType} but with user defined buttons as optional
* {@link ButtonType}s.
*
* @return Optional with the pressed Button as ButtonType
*/
Optional<ButtonType> showCustomButtonDialogAndWait(Alert.AlertType type, String title, String content,
ButtonType... buttonTypes);
/**
* This will create and display a new dialog showing a custom {@link DialogPane}
* and using custom {@link ButtonType}s.
*
* @return Optional with the pressed Button as ButtonType
*/
Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane contentPane, ButtonType... buttonTypes);
/**
* Shows a custom dialog and returns the result.
*
* @param dialog dialog to show
* @param <R> type of result
*/
<R> Optional<R> showCustomDialogAndWait(Dialog<R> dialog);
/**
* Notify the user in an non-blocking way (i.e., update status message instead of showing a dialog).
* @param message the message to show.
*/
void notify(String message);
/**
* Shows a new file save dialog. The method doesn't return until the
* displayed file save dialog is dismissed. The return value specifies the
* file chosen by the user or an empty {@link Optional} if no selection has been made.
*
* @return the selected file or an empty {@link Optional} if no file has been selected
*/
Optional<Path> showSaveDialog(FileDialogConfiguration fileDialogConfiguration);
/**
* Shows a new file open dialog. The method doesn't return until the
* displayed open dialog is dismissed. The return value specifies
* the file chosen by the user or an empty {@link Optional} if no selection has been
* made.
*
* @return the selected file or an empty {@link Optional} if no file has been selected
*/
Optional<Path> showOpenDialog(FileDialogConfiguration fileDialogConfiguration);
}