error messages that you can read

I discoverd that the error pane automaticly cuts off the last few words of your error message if it can fit *almost* the whole message on one line.  god, javafx is stupid.  I hacked at it until it wraps consistently so that *all* – not just *almost all* – of the words I ask it to show the user are actually shown to the user.
This commit is contained in:
Justin Kunimune 2023-12-14 14:43:15 -08:00
parent 2e5205e379
commit fbfe0f07bc
2 changed files with 14 additions and 4 deletions

View File

@ -32,6 +32,7 @@ import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
@ -56,6 +57,7 @@ import javafx.scene.input.KeyEvent;
import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
@ -686,7 +688,12 @@ public abstract class MapApplication extends Application {
protected static void showError(String header, String message) { //a simple error handling thing protected static void showError(String header, String message) { //a simple error handling thing
final Alert alert = new Alert(Alert.AlertType.ERROR); final Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText(header); alert.setHeaderText(header);
alert.setContentText(message); Text contentText = new Text(message);
contentText.setWrappingWidth(350);
StackPane contentPane = new StackPane(contentText);
contentPane.setPadding(new Insets(10, 10, 10, 10));
contentPane.setAlignment(Pos.CENTER);
alert.getDialogPane().setContent(contentPane);
alert.showAndWait(); alert.showAndWait();
} }

View File

@ -142,13 +142,16 @@ public class MapDesignerVector extends MapApplication {
protected void failed() { protected void failed() {
if (getException() instanceof IOException) if (getException() instanceof IOException)
showError("File not found!", showError("File not found!",
"We couldn't find "+file.getAbsolutePath()+"."); "We couldn't find "+file.getAbsolutePath()+".");
else if (getException() instanceof SAXException) else if (getException() instanceof SAXException)
showError("Unreadable file!", showError("Unreadable file!",
"We couldn't read "+file.getAbsolutePath()+". It may be corrupt or an unreadable format."); "We couldn't read "+file.getAbsolutePath()+". It may be corrupt or an unreadable format. " +
"If you think your SVG file is valid, leave an issue on the GitHub (https://github.com/" +
"jkunimune/Map-Projections/issues) or send me an email (justin.kunimune@gmail.com) and " +
"I'll see if I can find out why this isn't working.");
else if (getException() instanceof ParserConfigurationException) else if (getException() instanceof ParserConfigurationException)
showError("Parser Configuration Error!", showError("Parser Configuration Error!",
"My parser configured incorrectly. I blame you."); "My parser configured incorrectly. I blame you.");
else { else {
getException().printStackTrace(); getException().printStackTrace();
showError("Unexpected error!", getException().getMessage()); showError("Unexpected error!", getException().getMessage());