Commit 14e8c601 authored by Eric Duminil's avatar Eric Duminil
Browse files

RegionChooserJS: Closure to avoid using too many global variables.

parent e9082330
...@@ -159,7 +159,7 @@ private Path citygmlPath(String project, String citygml) { ...@@ -159,7 +159,7 @@ private Path citygmlPath(String project, String citygml) {
} }
public void importNovaFactoryBoundingBoxes() throws IOException { public void importNovaFactoryBoundingBoxes() throws IOException {
JSObject novafactoryVectors = (JSObject) webEngine.executeScript("novafactory_vectors"); JSObject regionChooserJS = (JSObject) webEngine.executeScript("regionChooser");
BufferedReader nf_csv = new BufferedReader(new InputStreamReader( BufferedReader nf_csv = new BufferedReader(new InputStreamReader(
RegionChooserFX.class.getResourceAsStream("website/data/novafactory_products.csv"))); RegionChooserFX.class.getResourceAsStream("website/data/novafactory_products.csv")));
nf_csv.readLine(); nf_csv.readLine();
...@@ -171,7 +171,7 @@ public void importNovaFactoryBoundingBoxes() throws IOException { ...@@ -171,7 +171,7 @@ public void importNovaFactoryBoundingBoxes() throws IOException {
String[] srs = values[3].split(" "); String[] srs = values[3].split(" ");
String epsgId = srs[srs.length - 1]; String epsgId = srs[srs.length - 1];
// System.out.println(product); // System.out.println(product);
novafactoryVectors.call("addNovaFactoryProduct", values[8], values[9], values[10], values[11], product, regionChooserJS.call("addNovaFactoryProduct", values[8], values[9], values[10], values[11], product,
epsgId); epsgId);
} }
nf_csv.close(); nf_csv.close();
...@@ -192,9 +192,9 @@ public RegionChooserBrowser() { ...@@ -192,9 +192,9 @@ public RegionChooserBrowser() {
webEngine.getLoadWorker().stateProperty().addListener( webEngine.getLoadWorker().stateProperty().addListener(
(ObservableValue<? extends State> ov, State oldState, State newState) -> { (ObservableValue<? extends State> ov, State oldState, State newState) -> {
if (newState == State.SUCCEEDED) { if (newState == State.SUCCEEDED) {
JSObject win = (JSObject) webEngine.executeScript("window"); JSObject regionChooserJS = (JSObject) webEngine.executeScript("regionChooser");
win.setMember("fxapp", fxapp); regionChooserJS.setMember("fxapp", fxapp);
win.call("ready"); regionChooserJS.call("ready");
try { try {
fxapp.importNovaFactoryBoundingBoxes(); fxapp.importNovaFactoryBoundingBoxes();
} catch (Exception ex) { } catch (Exception ex) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment