Skip to content

Commit

Permalink
Fixed AlertStyle.NONE alerts not being closable, which could soft loc…
Browse files Browse the repository at this point in the history
…k the Builder.
  • Loading branch information
denneyl2711 committed Jul 24, 2024
1 parent bc5421e commit 2a24bdd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
15 changes: 13 additions & 2 deletions src/kintsugi3d/builder/core/IBRRequestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import java.util.LinkedList;
import java.util.Queue;

import javafx.scene.control.*;
import kintsugi3d.builder.javafx.controllers.menubar.MenubarController;
import kintsugi3d.gl.interactive.GraphicsRequest;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kintsugi3d.gl.core.Context;
Expand Down Expand Up @@ -125,7 +126,17 @@ public synchronized void addIBRRequest(ObservableIBRRequest request)
log.error("Error occurred while executing request:", e);
Platform.runLater(() ->
{
new Alert(Alert.AlertType.NONE, "An error occurred processing request. Processing has stopped.\nCheck the log for more info.").show();
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);
ButtonType showLog = new ButtonType("Show Log", ButtonBar.ButtonData.YES);
Alert alert = new Alert(Alert.AlertType.NONE,
"An error occurred processing request. Processing has stopped\nSee the log for more info.",
ok, showLog);

((ButtonBase) alert.getDialogPane().lookupButton(showLog)).setOnAction(event -> {
// Use the menubar's console open function to prevent 2 console windows from appearing
MenubarController.getInstance().help_console();
});
alert.show();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/kintsugi3d/builder/javafx/ProjectIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private static void handleException(String message, Throwable e)
log.error("{}:", message, e);
Platform.runLater(() ->
{
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);
ButtonType showLog = new ButtonType("Show Log", ButtonBar.ButtonData.YES);
Alert alert = new Alert(Alert.AlertType.NONE, message + "\nSee the log for more info.", ok, showLog);
((ButtonBase) alert.getDialogPane().lookupButton(showLog)).setOnAction(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ public void submitChunk(){
// If no chunk is chosen somehow, prompt user to select a chunk.
if (metashapeObjectChunk == null) {
// Create a popup telling user to choose a chunk.
Alert alert = new Alert(Alert.AlertType.NONE);
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);

Alert alert = new Alert(Alert.AlertType.NONE, "", ok);
alert.setTitle("Error");
alert.setHeaderText("No chunk selected");
alert.setContentText("Please choose a chunk to continue.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private void showNoModelsAlert() {
alertShown = true;
Platform.runLater(() ->
{
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);
ButtonType openCustomProj = new ButtonType("Create Custom Project", ButtonBar.ButtonData.YES);

Alert alert = new Alert(Alert.AlertType.NONE,"Please select another chunk or create a custom project.", ok, openCustomProj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void button_Apply()
configuration.setEnableMaxMemory(maxMemCheckbox.isSelected());
configuration.setMaxMemoryMb((Integer)maxMemSpinner.getValue());

ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);
try
{
try
Expand All @@ -76,14 +77,14 @@ public void button_Apply()
catch (IOException e)
{
log.error("Failed to write to launch4j configuration file", e);
Alert alert = new Alert(Alert.AlertType.NONE);
Alert alert = new Alert(Alert.AlertType.NONE, "", ok);
alert.setTitle("Kintsugi 3D Builder");
alert.setHeaderText("Writing failed");
alert.setContentText("Kintsugi 3D Builder failed to write to the configuration file. Try restarting Kintsugi 3D Builder as administrator and try again.");
alert.show();
}

Alert alert = new Alert(Alert.AlertType.INFORMATION);
Alert alert = new Alert(Alert.AlertType.INFORMATION, "", ok);
alert.setTitle("Kintsugi 3D Builder");
alert.setHeaderText("Restart Required");
alert.setContentText("A restart of Kintsugi 3D Builder is needed for changes to take effect.");
Expand Down

0 comments on commit 2a24bdd

Please sign in to comment.