Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
51841bfb
Commit
51841bfb
authored
Oct 05, 2022
by
Eric Duminil
Browse files
Now possible to choose repository from RegionChooser.
parent
bfd36e93
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionChooserBrowser.java
View file @
51841bfb
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
import
javafx.scene.layout.Region
;
import
javafx.scene.layout.Region
;
import
javafx.scene.web.WebEngine
;
import
javafx.scene.web.WebEngine
;
import
javafx.scene.web.WebView
;
import
javafx.scene.web.WebView
;
import
javafx.stage.DirectoryChooser
;
import
javafx.stage.FileChooser
;
import
javafx.stage.FileChooser
;
import
javafx.stage.Stage
;
import
javafx.stage.Stage
;
import
netscape.javascript.JSObject
;
import
netscape.javascript.JSObject
;
...
@@ -30,6 +31,7 @@
...
@@ -30,6 +31,7 @@
public
class
RegionChooserBrowser
extends
Region
public
class
RegionChooserBrowser
extends
Region
{
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
RegionChooserBrowser
.
class
.
getName
());
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
RegionChooserBrowser
.
class
.
getName
());
private
static
final
String
PREF_RECENT_REPOSITORY
=
"RECENT_REPOSITORY"
;
private
static
final
int
BUFFER
=
1024
;
private
static
final
int
BUFFER
=
1024
;
/**
/**
...
@@ -41,7 +43,7 @@ public class RegionChooserBrowser extends Region
...
@@ -41,7 +43,7 @@ public class RegionChooserBrowser extends Region
public
JavaScriptFXBridge
()
{
public
JavaScriptFXBridge
()
{
Preferences
userPrefs
=
Preferences
.
userRoot
().
node
(
"/eu/simstadt/desktop"
);
Preferences
userPrefs
=
Preferences
.
userRoot
().
node
(
"/eu/simstadt/desktop"
);
String
repoString
=
userPrefs
.
get
(
"
RECENT_REPOSITORY
"
,
"../TestRepository"
);
String
repoString
=
userPrefs
.
get
(
PREF_
RECENT_REPOSITORY
,
"../TestRepository"
);
repo
=
Paths
.
get
(
repoString
);
repo
=
Paths
.
get
(
repoString
);
}
}
...
@@ -63,7 +65,10 @@ public Void call() throws IOException {
...
@@ -63,7 +65,10 @@ public Void call() throws IOException {
}
}
};
};
task
.
setOnRunning
(
e
->
jsApp
.
call
(
"display"
,
"Importing citgyml. Please wait."
));
task
.
setOnRunning
(
e
->
{
jsApp
.
call
(
"display"
,
"Importing citgyml. Please wait."
);
jsApp
.
call
(
"init"
);
});
task
.
setOnSucceeded
(
e
->
jsApp
.
call
(
"ready"
));
task
.
setOnSucceeded
(
e
->
jsApp
.
call
(
"ready"
));
...
@@ -91,6 +96,26 @@ public void downloadRegionFromCityGMLs(String wktPolygon, String project, String
...
@@ -91,6 +96,26 @@ public void downloadRegionFromCityGMLs(String wktPolygon, String project, String
}
}
}
}
public
void
selectRepository
()
{
Preferences
userPrefs
=
Preferences
.
userRoot
().
node
(
"/eu/simstadt/desktop"
);
String
currentRepo
=
userPrefs
.
get
(
PREF_RECENT_REPOSITORY
,
"../TestRepository"
);
DirectoryChooser
fileChooser
=
new
DirectoryChooser
();
Stage
mainStage
=
(
Stage
)
RegionChooserBrowser
.
this
.
getScene
().
getWindow
();
fileChooser
.
setTitle
(
"Select Repository"
);
fileChooser
.
setInitialDirectory
(
new
File
(
currentRepo
));
File
repoLocation
=
fileChooser
.
showDialog
(
mainStage
);
if
(
repoLocation
!=
null
)
{
repo
=
repoLocation
.
toPath
();
userPrefs
.
put
(
PREF_RECENT_REPOSITORY
,
repo
.
toAbsolutePath
().
toString
());
LOGGER
.
info
(
"Repository was set to "
+
repo
);
refreshHulls
();
}
else
{
LOGGER
.
warning
(
"No repository chosen."
);
}
}
private
File
selectSaveFileWithDialog
(
String
project
,
String
citygml
,
String
suffix
)
{
private
File
selectSaveFileWithDialog
(
String
project
,
String
citygml
,
String
suffix
)
{
Stage
mainStage
=
(
Stage
)
RegionChooserBrowser
.
this
.
getScene
().
getWindow
();
Stage
mainStage
=
(
Stage
)
RegionChooserBrowser
.
this
.
getScene
().
getWindow
();
FileChooser
fileChooser
=
new
FileChooser
();
FileChooser
fileChooser
=
new
FileChooser
();
...
...
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
View file @
51841bfb
...
@@ -4,7 +4,13 @@ var regionChooser = (function(){
...
@@ -4,7 +4,13 @@ var regionChooser = (function(){
//NOTE: Could do without jQuery
//NOTE: Could do without jQuery
var
dataPanel
=
$
(
'
#dataPanel
'
);
var
dataPanel
=
$
(
'
#dataPanel
'
);
var
wgs84Sphere
=
new
ol
.
Sphere
(
6378137
);
var
wgs84Sphere
=
new
ol
.
Sphere
(
6378137
);
var
gmlId
=
0
;
var
gmlId
;
publicScope
.
init
=
function
(){
//NOTE: Only called from JavaFX. At startup, or when Repo has been changed.
gmlId
=
0
;
kml_source
.
clear
();
}
if
(
fromJavaFX
){
if
(
fromJavaFX
){
$
(
"
html
"
).
addClass
(
"
wait
"
);
$
(
"
html
"
).
addClass
(
"
wait
"
);
...
@@ -248,7 +254,7 @@ var regionChooser = (function(){
...
@@ -248,7 +254,7 @@ var regionChooser = (function(){
fxapp
.
downloadRegionFromCityGMLs
(
sketchAsWKT
(
srsName
),
project
,
citygmlNames
.
join
(
"
;
"
),
srsName
);
fxapp
.
downloadRegionFromCityGMLs
(
sketchAsWKT
(
srsName
),
project
,
citygmlNames
.
join
(
"
;
"
),
srsName
);
dataPanel
.
append
(
"
<h2 class='ok'>Done!</h2><br/>
\n
"
);
dataPanel
.
append
(
"
<h2 class='ok'>Done!</h2><br/>
\n
"
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
lo
g
(
"
ERROR :
"
+
e
);
console
.
warnin
g
(
"
ERROR :
"
+
e
);
dataPanel
.
append
(
"
<h2 class='error'>Some problem occured!</h2><br/>
\n
"
);
dataPanel
.
append
(
"
<h2 class='error'>Some problem occured!</h2><br/>
\n
"
);
}
}
var
end
=
new
Date
().
getTime
();
var
end
=
new
Date
().
getTime
();
...
@@ -382,7 +388,8 @@ var regionChooser = (function(){
...
@@ -382,7 +388,8 @@ var regionChooser = (function(){
}
}
publicScope
.
selectRepository
=
function
()
{
publicScope
.
selectRepository
=
function
()
{
console
.
log
(
"
Should probably do something
"
);
console
.
log
(
"
Should probably do select repository.
"
);
fxapp
.
selectRepository
();
}
}
focusOnMap
();
focusOnMap
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment