alwaysontop g-earth window

This commit is contained in:
sirjonasxx 2019-01-29 23:44:46 +01:00
parent c8cb62d61f
commit a7308c2a38
4 changed files with 31 additions and 10 deletions

View File

@ -35,9 +35,9 @@ public class Main extends Application {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml"));
Parent root = loader.load(); Parent root = loader.load();
GEarthController companion = loader.getController(); GEarthController companion = loader.getController();
companion.setStage(primaryStage); companion.setStage(primaryStage);
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/gearth/G-EarthLogoSmaller.png"))); primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/gearth/G-EarthLogoSmaller.png")));
primaryStage.setResizable(false); primaryStage.setResizable(false);

View File

@ -22,6 +22,8 @@ public class GEarthController {
private Stage stage = null; private Stage stage = null;
private volatile HConnection hConnection; private volatile HConnection hConnection;
private volatile int initcount = 0;
public Connection connectionController; public Connection connectionController;
public Injection injectionController; public Injection injectionController;
public Logger loggerController; public Logger loggerController;
@ -38,20 +40,14 @@ public class GEarthController {
} }
public void initialize() { public void initialize() {
connectionController.setParentController(this); synchronized (this) {
injectionController.setParentController(this); trySetController();
loggerController.setParentController(this); }
toolsController.setParentController(this);
schedulerController.setParentController(this);
extraController.setParentController(this);
infoController.setParentController(this);
extensionsController.setParentController(this);
if (PacketLoggerFactory.usesUIlogger()) { if (PacketLoggerFactory.usesUIlogger()) {
tabBar.getTabs().remove(tab_Logger); tabBar.getTabs().remove(tab_Logger);
} }
//custom header bar //custom header bar
// final Point[] startpos = {null}; // final Point[] startpos = {null};
// final Double[] xx = {0.0}; // final Double[] xx = {0.0};
@ -85,7 +81,24 @@ public class GEarthController {
public void setStage(Stage stage) { public void setStage(Stage stage) {
this.stage = stage; this.stage = stage;
synchronized (this) {
trySetController();
}
} }
private void trySetController() {
if (++initcount == 2) {
connectionController.setParentController(this);
injectionController.setParentController(this);
loggerController.setParentController(this);
toolsController.setParentController(this);
schedulerController.setParentController(this);
extraController.setParentController(this);
infoController.setParentController(this);
extensionsController.setParentController(this);
}
}
public Stage getStage() { public Stage getStage() {
return stage; return stage;
} }

View File

@ -7,6 +7,7 @@ public class SubForm {
protected GEarthController parentController; protected GEarthController parentController;
//gets called when all UI elements are initialized, set parentController available & stage field is initialized
public void setParentController(GEarthController controller) { public void setParentController(GEarthController controller) {
parentController = controller; parentController = controller;
onParentSet(); onParentSet();

View File

@ -3,6 +3,8 @@ package gearth.ui.extra;
import gearth.Main; import gearth.Main;
import gearth.ui.SubForm; import gearth.ui.SubForm;
import gearth.ui.info.Info; import gearth.ui.info.Info;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.*; import javafx.scene.control.*;
@ -32,4 +34,9 @@ public class Extra extends SubForm {
Info.activateHyperlink(url_troubleshooting); Info.activateHyperlink(url_troubleshooting);
} }
@Override
protected void onParentSet() {
parentController.getStage().setAlwaysOnTop(cbx_alwaysOnTop.isSelected());
cbx_alwaysOnTop.selectedProperty().addListener(observable -> parentController.getStage().setAlwaysOnTop(cbx_alwaysOnTop.isSelected()));
}
} }