diff --git a/src/kintsugi3d/builder/core/IBRRequestManager.java b/src/kintsugi3d/builder/core/IBRRequestManager.java index 0974d089..8c7fa0b6 100644 --- a/src/kintsugi3d/builder/core/IBRRequestManager.java +++ b/src/kintsugi3d/builder/core/IBRRequestManager.java @@ -11,20 +11,19 @@ package kintsugi3d.builder.core; -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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; +import kintsugi3d.builder.javafx.ProjectIO; import kintsugi3d.builder.rendering.IBRInstanceManager; import kintsugi3d.gl.core.Context; +import kintsugi3d.gl.interactive.GraphicsRequest; import kintsugi3d.gl.interactive.ObservableGraphicsRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.LinkedList; +import java.util.Queue; public class IBRRequestManager> implements IBRRequestQueue { @@ -149,21 +148,7 @@ public synchronized void addIBRRequest(ObservableIBRRequest request) } catch (Exception | AssertionError e) { - log.error("Error occurred while executing request:", e); - Platform.runLater(() -> - { - 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(); - }); + ProjectIO.handleException("Error occured while excecuting request", e); } } diff --git a/src/kintsugi3d/builder/export/specular/SpecularFitRequest.java b/src/kintsugi3d/builder/export/specular/SpecularFitRequest.java index c7eac140..b8b47e06 100644 --- a/src/kintsugi3d/builder/export/specular/SpecularFitRequest.java +++ b/src/kintsugi3d/builder/export/specular/SpecularFitRequest.java @@ -24,6 +24,7 @@ import kintsugi3d.builder.fit.SpecularFitProcess; import kintsugi3d.builder.fit.SpecularFitProgramFactory; import kintsugi3d.builder.fit.settings.SpecularFitRequestParams; +import kintsugi3d.builder.javafx.ProjectIO; import kintsugi3d.builder.javafx.controllers.menubar.MenubarController; import kintsugi3d.builder.metrics.ColorAppearanceRMSE; import kintsugi3d.builder.resources.ibr.ReadonlyIBRResources; @@ -105,7 +106,7 @@ public > void executeRequest(IBRInstanc } catch(IOException e) // thrown by createReflectanceProgram { - log.error("Error executing specular fit request:", e); + ProjectIO.handleException("Error executing specular fit request:", e); } } diff --git a/src/kintsugi3d/builder/javafx/ProjectIO.java b/src/kintsugi3d/builder/javafx/ProjectIO.java index 0ab81dda..6648707b 100644 --- a/src/kintsugi3d/builder/javafx/ProjectIO.java +++ b/src/kintsugi3d/builder/javafx/ProjectIO.java @@ -117,8 +117,7 @@ public void fail(Throwable e) projectLoaded = false; if (e instanceof MeshImportException) { - //TODO: change to (e.getMessage(), e)? - handleException("Imported object is missing texture coordinates", e); + handleException(e.getMessage(), e); } else { @@ -149,7 +148,7 @@ public boolean isProjectLoaded() return projectLoaded; } - private static void handleException(String message, Throwable e) + public static void handleException(String message, Throwable e) { log.error("{}:", message, e); Platform.runLater(() -> diff --git a/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java b/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java index ae58f3fa..3873e4ec 100644 --- a/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java +++ b/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java @@ -68,6 +68,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; +import static kintsugi3d.builder.javafx.ProjectIO.handleException; + public class MenubarController { private static final Logger log = LoggerFactory.getLogger(MenubarController.class); @@ -405,8 +407,6 @@ public void complete() { this.maximum = 0.0; ProgressBarsController.getInstance().endStopwatches(); - //TODO: desaturate progress bars instead of hiding stage -// ProgressBarsController.getInstance().hideStage(); setReadyToDismissMiniProgBar(); if(overallProgressBar.getProgress() == ProgressIndicator.INDETERMINATE_PROGRESS){ @@ -1052,21 +1052,6 @@ public void launchViewerApp() } } - private void handleException(String message, Exception e) - { - log.error("{}:", message, e); - Platform.runLater(() -> - { - ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE); - ButtonType showLog = new ButtonType("Show Log", ButtonBar.ButtonData.YES); - Alert alert = new Alert(AlertType.ERROR, message + "\nSee the log for more info.", ok, showLog); - ((Button) alert.getDialogPane().lookupButton(showLog)).setOnAction(event -> { - help_console(); - }); - alert.show(); - }); - } - public void file_removeInvalidReferences() { RecentProjects.removeInvalidReferences(); }