show all textures at startup

This commit is contained in:
Hendrik Schutter 2019-06-08 21:59:09 +02:00
parent f4db466b37
commit 29354199cc
2 changed files with 23 additions and 8 deletions

View File

@ -104,6 +104,7 @@ class RootController : Controller() {
con.ping() con.ping()
println("auto Connection to Server successful") println("auto Connection to Server successful")
switchStartupToMain() switchStartupToMain()
showAll()
} else { } else {
println("[auto] no server found") println("[auto] no server found")
} }
@ -119,6 +120,7 @@ class RootController : Controller() {
con.ping() con.ping()
println("[file] Connection to Server successful") println("[file] Connection to Server successful")
switchStartupToMain() switchStartupToMain()
showAll()
} catch (e: Exception) { } catch (e: Exception) {
println(e) println(e)
println("[file] Connection to Server NOT successful") println("[file] Connection to Server NOT successful")
@ -135,6 +137,7 @@ class RootController : Controller() {
println("Connection to Server successful") println("Connection to Server successful")
SettingsController.setServerAddress(name) //store address in settings file SettingsController.setServerAddress(name) //store address in settings file
switchStartupToMain() switchStartupToMain()
showAll()
println("swithing to MainView @ initCon") println("swithing to MainView @ initCon")
} catch (e: Exception) { } catch (e: Exception) {
println(e) println(e)
@ -230,7 +233,12 @@ class RootController : Controller() {
mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash)) mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash))
val sdf = SimpleDateFormat("dd.MM.yyyy") val sdf = SimpleDateFormat("dd.MM.yyyy")
mvc.setMeta(data.name, "${data.resolution.first}px x ${data.resolution.second}px", data.format.toString(), sdf.format(data.addedOn.time)) mvc.setMeta(
data.name,
"${data.resolution.first}px x ${data.resolution.second}px",
data.format.toString(),
sdf.format(data.addedOn.time)
)
mvc.setTags(data.tags.toList().observable()) mvc.setTags(data.tags.toList().observable())
selectedTexture = data selectedTexture = data
} }
@ -255,7 +263,10 @@ class RootController : Controller() {
dialogDelete.showAndWait() dialogDelete.showAndWait()
} }
/**
* send a changed texture to the server
* @param chips the new tag list
*/
fun updateTexture(chips: ObservableList<String>) { fun updateTexture(chips: ObservableList<String>) {
val uuid = UUID.randomUUID() val uuid = UUID.randomUUID()
val newTexture = Texture( val newTexture = Texture(
@ -270,4 +281,10 @@ class RootController : Controller() {
con.updateTexture(selectedTexture, newTexture, con.getTextureFile(selectedTexture.textureHash)) con.updateTexture(selectedTexture, newTexture, con.getTextureFile(selectedTexture.textureHash))
} }
/**
* show all available textures at start
*/
fun showAll() {
queryElements(mvc.getTags())
}
} }

View File

@ -26,11 +26,6 @@ class MainViewController : Controller() {
folderView.children.add(element) folderView.children.add(element)
} }
fun addAllElements(elementList: ArrayList<GUIModel>) {
folderView.children.addAll(elementList)
}
// DetailView functions // DetailView functions
fun setPreview3DTexture(img: Image) { fun setPreview3DTexture(img: Image) {
preview.setTexture(img) preview.setTexture(img)
@ -47,6 +42,10 @@ class MainViewController : Controller() {
lockUpdate = true //allow update with onChange lockUpdate = true //allow update with onChange
} }
fun getTags(): ObservableList<String>{
return cvTags.chips
}
fun updateTags() { fun updateTags() {
if (lockUpdate) { //the chipView was changed by the user if (lockUpdate) { //the chipView was changed by the user
println("Tags changed") println("Tags changed")
@ -74,7 +73,6 @@ class MainViewController : Controller() {
rootc.switchMainToImport() rootc.switchMainToImport()
} }
fun removeTextureFromView(data: Texture) { fun removeTextureFromView(data: Texture) {
// stream all children nodes, filter them as GUIModel with data.id == data.id, for any found object if it's still present remove it from the folderView // stream all children nodes, filter them as GUIModel with data.id == data.id, for any found object if it's still present remove it from the folderView
folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny() folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny()