update alerts

This commit is contained in:
sirjonasxx 2022-02-16 01:32:32 +01:00
parent d5a60f9fb9
commit e6b5507968
14 changed files with 98 additions and 48 deletions

View File

@ -26,9 +26,6 @@ public class ConfirmationDialog {
Alert alert = new Alert(type); Alert alert = new Alert(type);
// Need to force the alert to layout in order to grab the graphic, // Need to force the alert to layout in order to grab the graphic,
// as we are replacing the dialog pane with a custom pane // 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(); alert.getDialogPane().applyCss();
Node graphic = alert.getDialogPane().getGraphic(); Node graphic = alert.getDialogPane().getGraphic();
// Create a new dialog pane that has a checkbox instead of the hide/show details button // Create a new dialog pane that has a checkbox instead of the hide/show details button

View File

@ -1,6 +1,7 @@
package gearth.misc; package gearth.misc;
import gearth.GEarth; import gearth.GEarth;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
@ -37,9 +38,6 @@ public class UpdateChecker {
boolean isForcedUpdate = body.contains("(!)"); boolean isForcedUpdate = body.contains("(!)");
Alert alert = new Alert(isForcedUpdate ? Alert.AlertType.ERROR : Alert.AlertType.INFORMATION, "G-Earth is outdated!", ButtonType.OK); 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(); 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:"); 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) { if (isForcedUpdate) {
alert.setOnCloseRequest(event -> System.exit(0)); alert.setOnCloseRequest(event -> System.exit(0));
} }
alert.show(); try {
TitleBarController.create(alert).showAlert();
} catch (IOException e) {
e.printStackTrace();
}
}); });
} }

View File

@ -9,6 +9,7 @@ import gearth.protocol.connection.HStateSetter;
import gearth.protocol.connection.proxy.flash.NormalFlashProxyProvider; import gearth.protocol.connection.proxy.flash.NormalFlashProxyProvider;
import gearth.protocol.connection.proxy.flash.unix.LinuxRawIpFlashProxyProvider; import gearth.protocol.connection.proxy.flash.unix.LinuxRawIpFlashProxyProvider;
import gearth.protocol.connection.proxy.flash.windows.WindowsRawIpFlashProxyProvider; import gearth.protocol.connection.proxy.flash.windows.WindowsRawIpFlashProxyProvider;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; 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. " + 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" + "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); "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.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(false); alert.setResizable(false);
alert.show(); try {
TitleBarController.create(alert).showAlert();
} catch (IOException e) {
e.printStackTrace();
}
}); });
return null; return null;

View File

@ -11,6 +11,7 @@ import gearth.protocol.memory.Rc4Obtainer;
import gearth.protocol.packethandler.flash.IncomingFlashPacketHandler; import gearth.protocol.packethandler.flash.IncomingFlashPacketHandler;
import gearth.protocol.packethandler.flash.OutgoingFlashPacketHandler; import gearth.protocol.packethandler.flash.OutgoingFlashPacketHandler;
import gearth.protocol.packethandler.flash.FlashPacketHandler; import gearth.protocol.packethandler.flash.FlashPacketHandler;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
@ -124,12 +125,13 @@ public abstract class FlashProxyProvider implements ProxyProvider {
protected void showInvalidConnectionError() { protected void showInvalidConnectionError() {
Platform.runLater(() -> { Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "You entered invalid connection information, G-Earth could not connect", ButtonType.OK); 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.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(false); alert.setResizable(false);
alert.show(); try {
TitleBarController.create(alert).showAlert();
} catch (IOException e) {
e.printStackTrace();
}
}); });
} }

View File

@ -10,6 +10,7 @@ import gearth.protocol.hostreplacer.hostsfile.HostReplacer;
import gearth.protocol.hostreplacer.hostsfile.HostReplacerFactory; import gearth.protocol.hostreplacer.hostsfile.HostReplacerFactory;
import gearth.protocol.portchecker.PortChecker; import gearth.protocol.portchecker.PortChecker;
import gearth.protocol.portchecker.PortCheckerFactory; import gearth.protocol.portchecker.PortCheckerFactory;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
@ -109,10 +110,11 @@ public class NormalFlashProxyProvider extends FlashProxyProvider {
Platform.runLater(() -> { Platform.runLater(() -> {
Alert a = new Alert(Alert.AlertType.ERROR, "The port is in use by " + processName, Alert a = new Alert(Alert.AlertType.ERROR, "The port is in use by " + processName,
ButtonType.OK); ButtonType.OK);
Stage stage = (Stage) a.getDialogPane().getScene().getWindow(); try {
stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", GEarth.theme)))); TitleBarController.create(a).showAlertAndWait();
stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme)).toExternalForm()); } catch (IOException ex) {
a.showAndWait(); ex.printStackTrace();
}
}); });
throw new IOException(e); throw new IOException(e);
} }

View File

@ -5,6 +5,7 @@ import gearth.misc.ConfirmationDialog;
import gearth.protocol.connection.proxy.nitro.NitroConstants; import gearth.protocol.connection.proxy.nitro.NitroConstants;
import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctions; import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctions;
import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctionsFactory; import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctionsFactory;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
@ -16,6 +17,7 @@ import org.littleshoot.proxy.mitm.Authority;
import org.littleshoot.proxy.mitm.RootCertificateException; import org.littleshoot.proxy.mitm.RootCertificateException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean; 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", "G-Earth will ask you for Administrator permission if you do so.", "Remember my choice",
ButtonType.YES, ButtonType.NO 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(); waitForDialog.release();
}); });

View File

@ -10,6 +10,7 @@ import gearth.protocol.memory.habboclient.HabboClientFactory;
import gearth.protocol.packethandler.flash.BufferChangeListener; import gearth.protocol.packethandler.flash.BufferChangeListener;
import gearth.protocol.packethandler.flash.FlashPacketHandler; import gearth.protocol.packethandler.flash.FlashPacketHandler;
import gearth.protocol.packethandler.PayloadBuffer; import gearth.protocol.packethandler.PayloadBuffer;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
@ -18,9 +19,11 @@ import javafx.scene.control.Label;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.layout.FlowPane; import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView; import javafx.scene.web.WebView;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -82,9 +85,6 @@ public class Rc4Obtainer {
Platform.runLater(() -> { Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.WARNING, "Something went wrong!", ButtonType.OK); 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(); 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:"); 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(); event.consume();
}); });
WebView webView = new WebView();
webView.getEngine().loadContent("<html>G-Earth has experienced an issue<br><br>Head over to our Troubleshooting page to solve the problem:<br><a href=\"https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting\">https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting</a></html>");
webView.setPrefSize(500, 200);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setContent(fp); alert.getDialogPane().setContent(fp);
alert.setOnCloseRequest(event -> { alert.setOnCloseRequest(event -> {
GEarth.main.getHostServices().showDocument(link.getText()); GEarth.main.getHostServices().showDocument(link.getText());
}); });
alert.show(); try {
TitleBarController.create(alert).showAlert();
} catch (IOException e) {
e.printStackTrace();
}
}); });

View File

@ -2,10 +2,12 @@ package gearth.services.extension_handler.extensions.implementations.network.aut
import gearth.misc.ConfirmationDialog; import gearth.misc.ConfirmationDialog;
import gearth.services.extension_handler.extensions.implementations.network.NetworkExtension; import gearth.services.extension_handler.extensions.implementations.network.NetworkExtension;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import java.io.IOException;
import java.util.*; import java.util.*;
/** /**
@ -70,9 +72,14 @@ public class Authenticator {
ButtonType.YES, ButtonType.NO ButtonType.YES, ButtonType.NO
); );
if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) { try {
if (!(TitleBarController.create(alert).showAlertAndWait()
.filter(t -> t == ButtonType.YES).isPresent())) {
allowConnection[0] = false; allowConnection[0] = false;
} }
} catch (IOException e) {
e.printStackTrace();
}
done[0] = true; done[0] = true;
if (!ConfirmationDialog.showDialog(connectExtensionKey)) { if (!ConfirmationDialog.showDialog(connectExtensionKey)) {
rememberOption = allowConnection[0]; rememberOption = allowConnection[0];

View File

@ -2,6 +2,7 @@ package gearth.services.g_python;
import gearth.GEarth; import gearth.GEarth;
import gearth.ui.subforms.extra.ExtraController; import gearth.ui.subforms.extra.ExtraController;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
@ -170,9 +171,6 @@ public class GPythonShell {
private void showError() { private void showError() {
Platform.runLater(() -> { Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "G-Python error", ButtonType.OK); 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"); alert.setTitle("G-Python error");
FlowPane fp = new FlowPane(); FlowPane fp = new FlowPane();
@ -188,7 +186,11 @@ public class GPythonShell {
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setContent(fp); alert.getDialogPane().setContent(fp);
alert.show(); try {
TitleBarController.create(alert).showAlert();
} catch (IOException e) {
e.printStackTrace();
}
}); });
} }

View File

@ -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.repository.models.StoreExtension;
import gearth.services.internal_extensions.extensionstore.tools.InstalledExtension; import gearth.services.internal_extensions.extensionstore.tools.InstalledExtension;
import gearth.services.internal_extensions.extensionstore.tools.StoreExtensionTools; import gearth.services.internal_extensions.extensionstore.tools.StoreExtensionTools;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import org.apache.maven.artifact.versioning.ComparableVersion; import org.apache.maven.artifact.versioning.ComparableVersion;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -114,7 +116,11 @@ public class StoreExtensionDetailsOverview extends HOverview {
alert.setHeaderText(header); alert.setHeaderText(header);
alert.setContentText(context); alert.setContentText(context);
alert.showAndWait(); try {
TitleBarController.create(alert).showAlertAndWait();
} catch (IOException e) {
e.printStackTrace();
}
} }
@Override @Override

View File

@ -2,6 +2,7 @@ package gearth.services.unity_tools;
import gearth.GEarth; import gearth.GEarth;
import gearth.misc.Cacher; import gearth.misc.Cacher;
import gearth.ui.themes.ThemeFactory;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -135,7 +136,7 @@ public class GUnityFileServer extends HttpServlet
private void getLogo(HttpServletResponse response) throws IOException { private void getLogo(HttpServletResponse response) throws IOException {
OutputStream out = response.getOutputStream(); 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]; byte[] bytes = new byte[4096];
int bytesRead; int bytesRead;

View File

@ -2,6 +2,7 @@ package gearth.ui.subforms.extensions;
import gearth.services.extension_handler.extensions.ExtensionType; import gearth.services.extension_handler.extensions.ExtensionType;
import gearth.services.extension_handler.extensions.GEarthExtension; import gearth.services.extension_handler.extensions.GEarthExtension;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.geometry.Insets; 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.ExtensionRunnerFactory;
import gearth.services.extension_handler.extensions.implementations.network.executer.NormalExtensionRunner; import gearth.services.extension_handler.extensions.implementations.network.executer.NormalExtensionRunner;
import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
/** /**
@ -113,9 +115,14 @@ public class ExtensionItemContainer extends GridPane {
ButtonType.YES, ButtonType.NO ButtonType.YES, ButtonType.NO
); );
if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) { try {
if (!(TitleBarController.create(alert).showAlertAndWait()
.filter(t -> t == ButtonType.YES).isPresent())) {
delet_dis = false; delet_dis = false;
} }
} catch (IOException e) {
e.printStackTrace();
}
} }
if (delet_dis) { if (delet_dis) {

View File

@ -10,6 +10,7 @@ import gearth.services.always_admin.AdminService;
import gearth.services.g_python.GPythonVersionUtils; import gearth.services.g_python.GPythonVersionUtils;
import gearth.ui.SubForm; import gearth.ui.SubForm;
import gearth.ui.subforms.info.InfoController; import gearth.ui.subforms.info.InfoController;
import gearth.ui.titlebar.TitleBarController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.*; import javafx.scene.control.*;
@ -20,6 +21,8 @@ import javafx.scene.layout.Region;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException;
/** /**
* Created by Jonas on 06/04/18. * Created by Jonas on 06/04/18.
*/ */
@ -175,9 +178,6 @@ public class ExtraController extends SubForm implements SocksConfiguration {
if (!GPythonVersionUtils.validInstallation()) { if (!GPythonVersionUtils.validInstallation()) {
Platform.runLater(() -> { Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "G-Python installation", ButtonType.OK); 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"); alert.setTitle("G-Python installation");
FlowPane fp = new FlowPane(); FlowPane fp = new FlowPane();
@ -192,7 +192,11 @@ public class ExtraController extends SubForm implements SocksConfiguration {
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setContent(fp); alert.getDialogPane().setContent(fp);
alert.show(); try {
TitleBarController.create(alert).showAlert();
} catch (IOException e) {
e.printStackTrace();
}
cbx_gpython.setDisable(false); cbx_gpython.setDisable(false);
}); });

View File

@ -4,12 +4,11 @@ import gearth.GEarth;
import gearth.ui.themes.ThemeFactory; import gearth.ui.themes.ThemeFactory;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.InvalidationListener; import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Cursor;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
@ -22,6 +21,7 @@ import javafx.stage.Stage;
import javafx.stage.StageStyle; import javafx.stage.StageStyle;
import java.io.IOException; import java.io.IOException;
import java.util.Optional;
public class TitleBarController { public class TitleBarController {
@ -34,6 +34,8 @@ public class TitleBarController {
private Stage stage; private Stage stage;
private TitleBarConfig config; private TitleBarConfig config;
private Alert alert = null;
public static TitleBarController create(Stage stage, TitleBarConfig config) throws IOException { public static TitleBarController create(Stage stage, TitleBarConfig config) throws IOException {
FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml")); FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml"));
Parent titleBar = loader.load(); Parent titleBar = loader.load();
@ -60,6 +62,7 @@ public class TitleBarController {
}; };
TitleBarController controller = initNewController(loader, stage, config); TitleBarController controller = initNewController(loader, stage, config);
controller.alert = alert;
Parent parent = alert.getDialogPane().getScene().getRoot(); Parent parent = alert.getDialogPane().getScene().getRoot();
VBox newParent = new VBox(titleBar, parent); VBox newParent = new VBox(titleBar, parent);
newParent.setId("titlebar-main-container"); newParent.setId("titlebar-main-container");
@ -137,8 +140,18 @@ public class TitleBarController {
} }
public void showAlert() { public void showAlert() {
stage.show(); if (alert != null) {
alert.show();
Platform.runLater(() -> stage.sizeToScene()); Platform.runLater(() -> stage.sizeToScene());
} }
}
public Optional<ButtonType> showAlertAndWait() {
if (alert != null) {
Platform.runLater(() -> stage.sizeToScene());
return alert.showAndWait();
}
return Optional.empty();
}
} }