diff --git a/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java b/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java
index 4c10bc8..81ede90 100644
--- a/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java
+++ b/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java
@@ -26,9 +26,6 @@ public class ConfirmationDialog {
Alert alert = new Alert(type);
// Need to force the alert to layout in order to grab the graphic,
// as we are replacing the dialog pane with a custom pane
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
alert.getDialogPane().applyCss();
Node graphic = alert.getDialogPane().getGraphic();
// Create a new dialog pane that has a checkbox instead of the hide/show details button
diff --git a/G-Earth/src/main/java/gearth/misc/UpdateChecker.java b/G-Earth/src/main/java/gearth/misc/UpdateChecker.java
index b43f49e..93a0827 100644
--- a/G-Earth/src/main/java/gearth/misc/UpdateChecker.java
+++ b/G-Earth/src/main/java/gearth/misc/UpdateChecker.java
@@ -1,6 +1,7 @@
package gearth.misc;
import gearth.GEarth;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -37,9 +38,6 @@ public class UpdateChecker {
boolean isForcedUpdate = body.contains("(!)");
Alert alert = new Alert(isForcedUpdate ? Alert.AlertType.ERROR : Alert.AlertType.INFORMATION, "G-Earth is outdated!", ButtonType.OK);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
FlowPane fp = new FlowPane();
Label lbl = new Label("A new version of G-Earth has been found ("+gitv+")" + System.lineSeparator()+ System.lineSeparator() + "Update to the latest version:");
@@ -62,7 +60,11 @@ public class UpdateChecker {
if (isForcedUpdate) {
alert.setOnCloseRequest(event -> System.exit(0));
}
- alert.show();
+ try {
+ TitleBarController.create(alert).showAlert();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
});
}
diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java
index 92796f5..e437c83 100644
--- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java
+++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java
@@ -9,6 +9,7 @@ import gearth.protocol.connection.HStateSetter;
import gearth.protocol.connection.proxy.flash.NormalFlashProxyProvider;
import gearth.protocol.connection.proxy.flash.unix.LinuxRawIpFlashProxyProvider;
import gearth.protocol.connection.proxy.flash.windows.WindowsRawIpFlashProxyProvider;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -108,12 +109,13 @@ public class ProxyProviderFactory {
Alert alert = new Alert(Alert.AlertType.ERROR, "G-Earth is already connected to this hotel. " +
"Due to current limitations you can only connect one session per hotel to G-Earth in Raw IP mode on Windows.\n\n" +
"You can bypass this by using a SOCKS proxy [Extra -> Advanced -> SOCKS]", ButtonType.OK);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(false);
- alert.show();
+ try {
+ TitleBarController.create(alert).showAlert();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
});
return null;
diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java
index 55d3a06..c27ff8f 100644
--- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java
+++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java
@@ -11,6 +11,7 @@ import gearth.protocol.memory.Rc4Obtainer;
import gearth.protocol.packethandler.flash.IncomingFlashPacketHandler;
import gearth.protocol.packethandler.flash.OutgoingFlashPacketHandler;
import gearth.protocol.packethandler.flash.FlashPacketHandler;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -124,12 +125,13 @@ public abstract class FlashProxyProvider implements ProxyProvider {
protected void showInvalidConnectionError() {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "You entered invalid connection information, G-Earth could not connect", ButtonType.OK);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(false);
- alert.show();
+ try {
+ TitleBarController.create(alert).showAlert();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
});
}
diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java
index 21d9730..49b4c6e 100644
--- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java
+++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java
@@ -10,6 +10,7 @@ import gearth.protocol.hostreplacer.hostsfile.HostReplacer;
import gearth.protocol.hostreplacer.hostsfile.HostReplacerFactory;
import gearth.protocol.portchecker.PortChecker;
import gearth.protocol.portchecker.PortCheckerFactory;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -109,10 +110,11 @@ public class NormalFlashProxyProvider extends FlashProxyProvider {
Platform.runLater(() -> {
Alert a = new Alert(Alert.AlertType.ERROR, "The port is in use by " + processName,
ButtonType.OK);
- Stage stage = (Stage) a.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
- a.showAndWait();
+ try {
+ TitleBarController.create(a).showAlertAndWait();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
});
throw new IOException(e);
}
diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java
index dbe319e..e9ac358 100644
--- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java
+++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java
@@ -5,6 +5,7 @@ import gearth.misc.ConfirmationDialog;
import gearth.protocol.connection.proxy.nitro.NitroConstants;
import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctions;
import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctionsFactory;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -16,6 +17,7 @@ import org.littleshoot.proxy.mitm.Authority;
import org.littleshoot.proxy.mitm.RootCertificateException;
import java.io.File;
+import java.io.IOException;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -56,11 +58,13 @@ public class NitroHttpProxy {
"G-Earth will ask you for Administrator permission if you do so.", "Remember my choice",
ButtonType.YES, ButtonType.NO
);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
- shouldInstall.set(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent());
+ try {
+ shouldInstall.set(TitleBarController.create(alert).showAlertAndWait()
+ .filter(t -> t == ButtonType.YES).isPresent());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
waitForDialog.release();
});
diff --git a/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java b/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java
index f342683..40ff481 100644
--- a/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java
+++ b/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java
@@ -10,6 +10,7 @@ import gearth.protocol.memory.habboclient.HabboClientFactory;
import gearth.protocol.packethandler.flash.BufferChangeListener;
import gearth.protocol.packethandler.flash.FlashPacketHandler;
import gearth.protocol.packethandler.PayloadBuffer;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -18,9 +19,11 @@ import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Region;
+import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@@ -82,9 +85,6 @@ public class Rc4Obtainer {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.WARNING, "Something went wrong!", ButtonType.OK);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
FlowPane fp = new FlowPane();
Label lbl = new Label("G-Earth has experienced an issue" + System.lineSeparator()+ System.lineSeparator() + "Head over to our Troubleshooting page to solve the problem:");
@@ -95,15 +95,16 @@ public class Rc4Obtainer {
event.consume();
});
- WebView webView = new WebView();
- webView.getEngine().loadContent("G-Earth has experienced an issue
Head over to our Troubleshooting page to solve the problem:
https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting");
- webView.setPrefSize(500, 200);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setContent(fp);
alert.setOnCloseRequest(event -> {
GEarth.main.getHostServices().showDocument(link.getText());
});
- alert.show();
+ try {
+ TitleBarController.create(alert).showAlert();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
});
diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java
index ebea488..7047364 100644
--- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java
+++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java
@@ -2,10 +2,12 @@ package gearth.services.extension_handler.extensions.implementations.network.aut
import gearth.misc.ConfirmationDialog;
import gearth.services.extension_handler.extensions.implementations.network.NetworkExtension;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
+import java.io.IOException;
import java.util.*;
/**
@@ -70,8 +72,13 @@ public class Authenticator {
ButtonType.YES, ButtonType.NO
);
- if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) {
- allowConnection[0] = false;
+ try {
+ if (!(TitleBarController.create(alert).showAlertAndWait()
+ .filter(t -> t == ButtonType.YES).isPresent())) {
+ allowConnection[0] = false;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
}
done[0] = true;
if (!ConfirmationDialog.showDialog(connectExtensionKey)) {
diff --git a/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java b/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java
index 76bfd66..da92ac6 100644
--- a/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java
+++ b/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java
@@ -2,6 +2,7 @@ package gearth.services.g_python;
import gearth.GEarth;
import gearth.ui.subforms.extra.ExtraController;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
@@ -170,9 +171,6 @@ public class GPythonShell {
private void showError() {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "G-Python error", ButtonType.OK);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
alert.setTitle("G-Python error");
FlowPane fp = new FlowPane();
@@ -188,7 +186,11 @@ public class GPythonShell {
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setContent(fp);
- alert.show();
+ try {
+ TitleBarController.create(alert).showAlert();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
});
}
diff --git a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/extensiondetails/StoreExtensionDetailsOverview.java b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/extensiondetails/StoreExtensionDetailsOverview.java
index aa594c1..7c06d56 100644
--- a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/extensiondetails/StoreExtensionDetailsOverview.java
+++ b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/application/entities/extensiondetails/StoreExtensionDetailsOverview.java
@@ -11,12 +11,14 @@ import gearth.services.internal_extensions.extensionstore.repository.StoreReposi
import gearth.services.internal_extensions.extensionstore.repository.models.StoreExtension;
import gearth.services.internal_extensions.extensionstore.tools.InstalledExtension;
import gearth.services.internal_extensions.extensionstore.tools.StoreExtensionTools;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.w3c.dom.Element;
+import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -114,7 +116,11 @@ public class StoreExtensionDetailsOverview extends HOverview {
alert.setHeaderText(header);
alert.setContentText(context);
- alert.showAndWait();
+ try {
+ TitleBarController.create(alert).showAlertAndWait();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
@Override
diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java b/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java
index ba8b4e6..8058604 100644
--- a/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java
+++ b/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java
@@ -2,6 +2,7 @@ package gearth.services.unity_tools;
import gearth.GEarth;
import gearth.misc.Cacher;
+import gearth.ui.themes.ThemeFactory;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
@@ -135,7 +136,7 @@ public class GUnityFileServer extends HttpServlet
private void getLogo(HttpServletResponse response) throws IOException {
OutputStream out = response.getOutputStream();
- InputStream in = GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logo.png", GEarth.theme));
+ InputStream in = GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logo.png", ThemeFactory.getDefaultTheme().internalName()));
byte[] bytes = new byte[4096];
int bytesRead;
diff --git a/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java
index de1a9fa..b1623fe 100644
--- a/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java
+++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java
@@ -2,6 +2,7 @@ package gearth.ui.subforms.extensions;
import gearth.services.extension_handler.extensions.ExtensionType;
import gearth.services.extension_handler.extensions.GEarthExtension;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
@@ -17,6 +18,7 @@ import gearth.services.extension_handler.extensions.implementations.network.exec
import gearth.services.extension_handler.extensions.implementations.network.executer.ExtensionRunnerFactory;
import gearth.services.extension_handler.extensions.implementations.network.executer.NormalExtensionRunner;
+import java.io.IOException;
import java.nio.file.Paths;
/**
@@ -113,8 +115,13 @@ public class ExtensionItemContainer extends GridPane {
ButtonType.YES, ButtonType.NO
);
- if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) {
- delet_dis = false;
+ try {
+ if (!(TitleBarController.create(alert).showAlertAndWait()
+ .filter(t -> t == ButtonType.YES).isPresent())) {
+ delet_dis = false;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
diff --git a/G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java b/G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java
index d502d8d..ce02079 100644
--- a/G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java
+++ b/G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java
@@ -10,6 +10,7 @@ import gearth.services.always_admin.AdminService;
import gearth.services.g_python.GPythonVersionUtils;
import gearth.ui.SubForm;
import gearth.ui.subforms.info.InfoController;
+import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.scene.control.*;
@@ -20,6 +21,8 @@ import javafx.scene.layout.Region;
import javafx.stage.Stage;
import org.json.JSONObject;
+import java.io.IOException;
+
/**
* Created by Jonas on 06/04/18.
*/
@@ -175,9 +178,6 @@ public class ExtraController extends SubForm implements SocksConfiguration {
if (!GPythonVersionUtils.validInstallation()) {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "G-Python installation", ButtonType.OK);
- Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
- stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme))));
- stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm());
alert.setTitle("G-Python installation");
FlowPane fp = new FlowPane();
@@ -192,7 +192,11 @@ public class ExtraController extends SubForm implements SocksConfiguration {
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setContent(fp);
- alert.show();
+ try {
+ TitleBarController.create(alert).showAlert();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
cbx_gpython.setDisable(false);
});
diff --git a/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java b/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java
index 9553f58..6b7630d 100644
--- a/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java
+++ b/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java
@@ -4,12 +4,11 @@ import gearth.GEarth;
import gearth.ui.themes.ThemeFactory;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
-import javafx.beans.Observable;
import javafx.fxml.FXMLLoader;
-import javafx.scene.Cursor;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
+import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
@@ -22,6 +21,7 @@ import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.io.IOException;
+import java.util.Optional;
public class TitleBarController {
@@ -34,6 +34,8 @@ public class TitleBarController {
private Stage stage;
private TitleBarConfig config;
+ private Alert alert = null;
+
public static TitleBarController create(Stage stage, TitleBarConfig config) throws IOException {
FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml"));
Parent titleBar = loader.load();
@@ -60,6 +62,7 @@ public class TitleBarController {
};
TitleBarController controller = initNewController(loader, stage, config);
+ controller.alert = alert;
Parent parent = alert.getDialogPane().getScene().getRoot();
VBox newParent = new VBox(titleBar, parent);
newParent.setId("titlebar-main-container");
@@ -137,8 +140,18 @@ public class TitleBarController {
}
public void showAlert() {
- stage.show();
- Platform.runLater(() -> stage.sizeToScene());
+ if (alert != null) {
+ alert.show();
+ Platform.runLater(() -> stage.sizeToScene());
+ }
+ }
+
+ public Optional showAlertAndWait() {
+ if (alert != null) {
+ Platform.runLater(() -> stage.sizeToScene());
+ return alert.showAndWait();
+ }
+ return Optional.empty();
}
}