Add helper class for dialogs

This commit is contained in:
0xboobface 2018-12-09 21:35:45 +01:00
parent 878b25c55c
commit 5b936c779d
2 changed files with 28 additions and 20 deletions

View File

@ -1,5 +1,6 @@
package ctbrec.ui;
import static ctbrec.ui.controls.Dialogs.*;
import java.io.IOException;
import java.net.SocketTimeoutException;
@ -821,24 +822,4 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
selectedThumbCells.get(0).setSelected(false);
}
}
private void showError(String header, String text, Exception e) {
Runnable r = () -> {
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText(header);
String content = text;
if(e != null) {
content += " " + e.getLocalizedMessage();
}
alert.setContentText(content);
alert.showAndWait();
};
if(Platform.isFxApplicationThread()) {
r.run();
} else {
Platform.runLater(r);
}
}
}

View File

@ -0,0 +1,27 @@
package ctbrec.ui.controls;
import ctbrec.ui.AutosizeAlert;
import javafx.application.Platform;
import javafx.scene.control.Alert;
public class Dialogs {
public static void showError(String header, String text, Exception e) {
Runnable r = () -> {
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText(header);
String content = text;
if(e != null) {
content += " " + e.getLocalizedMessage();
}
alert.setContentText(content);
alert.showAndWait();
};
if(Platform.isFxApplicationThread()) {
r.run();
} else {
Platform.runLater(r);
}
}
}