From e093297ed2866c1209de630580cbec428e95c998 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 30 Jan 2019 00:03:09 +0100 Subject: [PATCH] change gearthcontroller --- .../main/java/gearth/ui/GEarthController.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/G-Earth/src/main/java/gearth/ui/GEarthController.java b/G-Earth/src/main/java/gearth/ui/GEarthController.java index cc9cf6d..431c3ea 100644 --- a/G-Earth/src/main/java/gearth/ui/GEarthController.java +++ b/G-Earth/src/main/java/gearth/ui/GEarthController.java @@ -15,13 +15,16 @@ import gearth.ui.scheduler.Scheduler; import gearth.ui.extra.Extra; import gearth.ui.tools.Tools; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + public class GEarthController { public Tab tab_Logger; public TabPane tabBar; private Stage stage = null; private volatile HConnection hConnection; - private volatile int initcount = 0; public Connection connectionController; @@ -33,13 +36,24 @@ public class GEarthController { public Info infoController; public Extensions extensionsController; - public Pane mover; + private List tabs = null; + public Pane mover; public GEarthController() { hConnection = new HConnection(); } public void initialize() { + tabs = new ArrayList<>(); + tabs.add(connectionController); + tabs.add(injectionController); + tabs.add(loggerController); + tabs.add(toolsController); + tabs.add(schedulerController); + tabs.add(extraController); + tabs.add(infoController); + tabs.add(extensionsController); + synchronized (this) { trySetController(); } @@ -88,14 +102,8 @@ public class GEarthController { 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); + GEarthController self = this; + tabs.forEach(subForm -> subForm.setParentController(self)); } } @@ -112,15 +120,7 @@ public class GEarthController { public void exit() { - connectionController.exit(); - injectionController.exit(); - loggerController.exit(); - toolsController.exit(); - schedulerController.exit(); - extraController.exit(); - infoController.exit(); - extensionsController.exit(); - + tabs.forEach(SubForm::exit); hConnection.abort(); }