Compare commits
No commits in common. "8d387250e71c8436b1cb62a059ac850a28e63569" and "53dcebecde417eb9eb66feda1ba0f32ee735381d" have entirely different histories.
8d387250e7
...
53dcebecde
@ -1,31 +1,18 @@
|
|||||||
package org.hso.texturesyncclient.app
|
package org.hso.texturesyncclient.app
|
||||||
|
|
||||||
import org.hso.texturesyncclient.controller.RootController
|
import org.hso.texturesyncclient.controller.RootController
|
||||||
import org.hso.texturesyncclient.controller.SettingsController
|
|
||||||
import org.hso.texturesyncclient.view.importView.ImportView
|
import org.hso.texturesyncclient.view.importView.ImportView
|
||||||
import org.hso.texturesyncclient.view.mainView.MainView
|
import org.hso.texturesyncclient.view.mainView.MainView
|
||||||
import org.hso.texturesyncclient.view.mainView.MainViewController
|
import org.hso.texturesyncclient.view.mainView.MainViewController
|
||||||
import org.hso.texturesyncclient.view.startupView.StartupView
|
import org.hso.texturesyncclient.view.startupView.StartupView
|
||||||
import org.hso.texturesyncclient.view.startupView.StartupViewController
|
|
||||||
import tornadofx.App
|
import tornadofx.App
|
||||||
|
|
||||||
class Main: App(StartupView::class){
|
class Main: App(StartupView::class){
|
||||||
|
|
||||||
val controller = RootController()
|
val controller = RootController()
|
||||||
|
|
||||||
private val svc: StartupViewController by inject()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
SettingsController.init()
|
// TODO get saved IP address, if found try to connect, else show StartupView
|
||||||
|
|
||||||
if (SettingsController.serverAddressIsSet()) {
|
|
||||||
//load settings in ui and try to connect
|
|
||||||
println("serverAddress is set")
|
|
||||||
svc.setServerAddress(SettingsController.getServerAddress())
|
|
||||||
svc.btnConnectAction(SettingsController.getServerAddress())
|
|
||||||
} else {
|
|
||||||
println("serverAddress is not set")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package org.hso.texturesyncclient.controller
|
package org.hso.texturesyncclient.controller
|
||||||
|
|
||||||
import com.sun.scenario.Settings
|
|
||||||
import javafx.application.Platform
|
|
||||||
import javafx.collections.ObservableList
|
import javafx.collections.ObservableList
|
||||||
import javafx.stage.DirectoryChooser
|
import javafx.stage.DirectoryChooser
|
||||||
import org.hso.texturesyncclient.controller.net.Connection
|
import org.hso.texturesyncclient.controller.net.Connection
|
||||||
@ -32,7 +30,6 @@ class RootController : Controller() {
|
|||||||
|
|
||||||
private lateinit var con: Connection
|
private lateinit var con: Connection
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
/*var data = Texture()
|
/*var data = Texture()
|
||||||
var img = con.getTexturePreview(data.textureHash)
|
var img = con.getTexturePreview(data.textureHash)
|
||||||
@ -49,8 +46,8 @@ class RootController : Controller() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
mvc.addElement(test)*/
|
mvc.addElement(test)*/
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calculate the resolution, get today's date -> upload to server
|
* calculate the resolution, get today's date -> upload to server
|
||||||
@ -82,20 +79,18 @@ class RootController : Controller() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize connection to server and switch to MainView if connected
|
* Initialize connection to server
|
||||||
* @param name server name as IP or domain
|
* @param name server name as IP or domain
|
||||||
*/
|
*/
|
||||||
fun initConnection(name: String) {
|
fun initConnection(name: String) {
|
||||||
try {
|
try {
|
||||||
con = Connection(InetAddress.getByName(name))
|
con = Connection(InetAddress.getByName(name))
|
||||||
con.ping()
|
con.ping()
|
||||||
println("Connection to Server successful")
|
println("Connection successful")
|
||||||
SettingsController.setServerAddress(name)
|
|
||||||
switchToMainView()
|
// TODO store server ip for next start
|
||||||
println("swithing to MainView @ initCon")
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println(e)
|
println(e)
|
||||||
println("Connection to Server NOT successful")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -118,10 +113,8 @@ class RootController : Controller() {
|
|||||||
|
|
||||||
|
|
||||||
fun switchToMainView(){
|
fun switchToMainView(){
|
||||||
Platform.runLater { //avoid the exception that occurs then this is called from an not tornadoFx thread
|
|
||||||
find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
|
find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save the texture file to a local directory
|
* save the texture file to a local directory
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
package org.hso.texturesyncclient.controller
|
|
||||||
|
|
||||||
import java.io.*
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
|
||||||
class SettingsController {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
private lateinit var serverAddress: String
|
|
||||||
|
|
||||||
private lateinit var props: Properties
|
|
||||||
|
|
||||||
private val userHome = System.getProperty("user.home")
|
|
||||||
private val osName = System.getProperty("os.name")
|
|
||||||
|
|
||||||
private lateinit var dirPath: String //path to settings file
|
|
||||||
private lateinit var settingsFile: File //settings file
|
|
||||||
|
|
||||||
private val defautAddressValue: String = " "
|
|
||||||
|
|
||||||
fun init() {
|
|
||||||
props = Properties()
|
|
||||||
|
|
||||||
if (osName.contains("Windows")) {
|
|
||||||
dirPath = userHome + "/Documents/TextureSync";
|
|
||||||
} else {
|
|
||||||
dirPath = userHome + "/.TextureSync";
|
|
||||||
}
|
|
||||||
|
|
||||||
settingsFile = File(dirPath + "/config.xml"); //open Settings file
|
|
||||||
|
|
||||||
if (!settingsFile.exists()) {
|
|
||||||
println("settings not found! Will create new one")
|
|
||||||
File(dirPath).mkdir()
|
|
||||||
settingsFile.createNewFile()
|
|
||||||
serverAddress = defautAddressValue //load default value
|
|
||||||
saveSettings()
|
|
||||||
} else {
|
|
||||||
println("settings found")
|
|
||||||
loadSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun serverAddressIsSet(): Boolean {
|
|
||||||
if (serverAddress == defautAddressValue) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadSettings() {
|
|
||||||
val inputStream: InputStream
|
|
||||||
inputStream = FileInputStream(settingsFile);
|
|
||||||
props.loadFromXML(inputStream);
|
|
||||||
serverAddress = props.getProperty("serverAddress")
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun saveSettings() {
|
|
||||||
val outputStream: OutputStream
|
|
||||||
props.setProperty("serverAddress", serverAddress);
|
|
||||||
outputStream = FileOutputStream(settingsFile);
|
|
||||||
props.storeToXML(outputStream, "TextureSync settings");
|
|
||||||
outputStream.close();
|
|
||||||
println("settings saved")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getServerAddress(): String {
|
|
||||||
return serverAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setServerAddress(serverAddress: String) {
|
|
||||||
this.serverAddress = serverAddress
|
|
||||||
saveSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,11 +10,6 @@ class StartupViewController : Controller() {
|
|||||||
private val sv = find(StartupView::class)
|
private val sv = find(StartupView::class)
|
||||||
private val rootc = find(RootController::class)
|
private val rootc = find(RootController::class)
|
||||||
|
|
||||||
fun setServerAddress(address: String){
|
|
||||||
sv.tfServerIP.text = address
|
|
||||||
sv.tfServerIP.isFocusTraversable = false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun btnConnectAction(name: String) {
|
fun btnConnectAction(name: String) {
|
||||||
sv.labelStatus.text = "Verbinden ..."
|
sv.labelStatus.text = "Verbinden ..."
|
||||||
sv.tfServerIP.isEditable = false
|
sv.tfServerIP.isEditable = false
|
||||||
@ -30,6 +25,7 @@ class StartupViewController : Controller() {
|
|||||||
sv.tfServerIP.isEditable = true
|
sv.tfServerIP.isEditable = true
|
||||||
sv.btnConnect.isDisable = false
|
sv.btnConnect.isDisable = false
|
||||||
sv.tfServerIP.clear()
|
sv.tfServerIP.clear()
|
||||||
|
rootc.switchToMainView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user