add notepad

This commit is contained in:
sirjonasxx 2019-01-29 23:57:38 +01:00
parent a7308c2a38
commit 2e323c30f9
5 changed files with 36 additions and 8 deletions

View File

@ -3,8 +3,6 @@ package gearth;
import gearth.misc.AdminValidator; import gearth.misc.AdminValidator;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
@ -17,7 +15,6 @@ import javafx.stage.Stage;
import gearth.ui.GEarthController; import gearth.ui.GEarthController;
import org.json.JSONObject; import org.json.JSONObject;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.omg.CORBA.Environment;
import java.io.IOException; import java.io.IOException;
@ -48,7 +45,7 @@ public class Main extends Application {
primaryStage.getScene().getStylesheets().add(getClass().getResource("/gearth/ui/bootstrap3.css").toExternalForm()); primaryStage.getScene().getStylesheets().add(getClass().getResource("/gearth/ui/bootstrap3.css").toExternalForm());
primaryStage.setOnCloseRequest( event -> { primaryStage.setOnCloseRequest( event -> {
companion.abort(); companion.exit();
Platform.exit(); Platform.exit();
// Platform.exit doesn't seem to be enough on Windows? // Platform.exit doesn't seem to be enough on Windows?

View File

@ -55,7 +55,7 @@ public class Cacher {
} }
return new JSONObject(); return new JSONObject();
} }
public static void updateCache(JSONObject contents, String cache_filename) { private static void updateCache(JSONObject contents, String cache_filename) {
updateCache(contents.toString(), cache_filename); updateCache(contents.toString(), cache_filename);
} }
public static void updateCache(String content, String cache_filename){ public static void updateCache(String content, String cache_filename){
@ -100,7 +100,7 @@ public class Cacher {
public static JSONObject getCacheContents() { public static JSONObject getCacheContents() {
return getCacheContents(DEFAULT_CACHE_FILENAME); return getCacheContents(DEFAULT_CACHE_FILENAME);
} }
public static void updateCache(JSONObject contents) { private static void updateCache(JSONObject contents) {
updateCache(contents, DEFAULT_CACHE_FILENAME); updateCache(contents, DEFAULT_CACHE_FILENAME);
} }
public static void put(String key, Object val) { public static void put(String key, Object val) {

View File

@ -111,7 +111,16 @@ public class GEarthController {
} }
public void abort() { public void exit() {
connectionController.exit();
injectionController.exit();
loggerController.exit();
toolsController.exit();
schedulerController.exit();
extraController.exit();
infoController.exit();
extensionsController.exit();
hConnection.abort(); hConnection.abort();
} }

View File

@ -14,11 +14,20 @@ public class SubForm {
} }
//abstract //abstract but non required
protected void onParentSet() { protected void onParentSet() {
} }
public void exit() {
onExit();
}
//abstract but non required
protected void onExit() {
}
protected HConnection getHConnection() { protected HConnection getHConnection() {
return parentController.getHConnection(); return parentController.getHConnection();
} }

View File

@ -1,6 +1,7 @@
package gearth.ui.extra; package gearth.ui.extra;
import gearth.Main; import gearth.Main;
import gearth.misc.Cacher;
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.InvalidationListener;
@ -13,6 +14,8 @@ import javafx.scene.control.*;
*/ */
public class Extra extends SubForm { public class Extra extends SubForm {
public static final String NOTEPAD_CACHE_KEY = "notepad_text";
public TextArea txtarea_notepad; public TextArea txtarea_notepad;
public CheckBox cbx_alwaysOnTop; public CheckBox cbx_alwaysOnTop;
@ -32,6 +35,11 @@ public class Extra extends SubForm {
public void initialize() { public void initialize() {
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting")); url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
Info.activateHyperlink(url_troubleshooting); Info.activateHyperlink(url_troubleshooting);
String notepadInitValue = (String)Cacher.get(NOTEPAD_CACHE_KEY);
if (notepadInitValue != null) {
txtarea_notepad.setText(notepadInitValue);
}
} }
@Override @Override
@ -39,4 +47,9 @@ public class Extra extends SubForm {
parentController.getStage().setAlwaysOnTop(cbx_alwaysOnTop.isSelected()); parentController.getStage().setAlwaysOnTop(cbx_alwaysOnTop.isSelected());
cbx_alwaysOnTop.selectedProperty().addListener(observable -> parentController.getStage().setAlwaysOnTop(cbx_alwaysOnTop.isSelected())); cbx_alwaysOnTop.selectedProperty().addListener(observable -> parentController.getStage().setAlwaysOnTop(cbx_alwaysOnTop.isSelected()));
} }
@Override
protected void onExit() {
Cacher.put(NOTEPAD_CACHE_KEY, txtarea_notepad.getText());
}
} }