Allow backendType to be changed via config file
This commit is contained in:
parent
879fe3955a
commit
755c5165fc
2 changed files with 23 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.bm00.DataAccessor
|
package org.bm00.DataAccessor
|
||||||
|
|
||||||
import dev.dirs.ProjectDirectories
|
import dev.dirs.ProjectDirectories
|
||||||
|
import jexer.TApplication
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
@ -8,6 +9,7 @@ import java.io.OutputStream
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.jvm.Throws
|
||||||
|
|
||||||
val prop = Properties()
|
val prop = Properties()
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ class Config {
|
||||||
FileInputStream(confFile).use {
|
FileInputStream(confFile).use {
|
||||||
prop.load(it)
|
prop.load(it)
|
||||||
prop.setProperty("configVersion", "1")
|
prop.setProperty("configVersion", "1")
|
||||||
|
prop.setProperty("backendType", "SWING")
|
||||||
}
|
}
|
||||||
val out: OutputStream = FileOutputStream(confFile)
|
val out: OutputStream = FileOutputStream(confFile)
|
||||||
prop.store(out, "Org Secure Data Accessor - OSDA Config file")
|
prop.store(out, "Org Secure Data Accessor - OSDA Config file")
|
||||||
|
@ -39,4 +42,19 @@ class Config {
|
||||||
//Convert values from the config file to in-code variables,
|
//Convert values from the config file to in-code variables,
|
||||||
// so we can use them later, also make them public because I said so.
|
// so we can use them later, also make them public because I said so.
|
||||||
val configVersion: Int = (prop.getProperty("configVersion")).toInt()
|
val configVersion: Int = (prop.getProperty("configVersion")).toInt()
|
||||||
|
|
||||||
|
// Possible answers: SWING, XTERM, ECMA48
|
||||||
|
val backendType =
|
||||||
|
if (prop.getProperty("backendType") == "SWING") {
|
||||||
|
TApplication.BackendType.SWING
|
||||||
|
}
|
||||||
|
else if (prop.getProperty("backendType") == "XTERM") {
|
||||||
|
TApplication.BackendType.XTERM
|
||||||
|
}
|
||||||
|
else if (prop.getProperty("backendType") == "ECMA48") {
|
||||||
|
TApplication.BackendType.ECMA48
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw Exception("Improper Backend set! Please use `SWING, XTERM, ECMA48`!")
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,13 +4,15 @@ import jexer.TApplication
|
||||||
import org.bm00.DataAccessor.windows.WelcomeWindow
|
import org.bm00.DataAccessor.windows.WelcomeWindow
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// This creates a Jexer application (and calls the "backend type" which is how its rendered)
|
val backendType = Config().backendType
|
||||||
class Application : TApplication(BackendType.SWING) {
|
|
||||||
|
class Application : TApplication(backendType, 80, 40, 18) {
|
||||||
init {
|
init {
|
||||||
WelcomeWindow(this)
|
WelcomeWindow(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This creates a Jexer application (and calls the "backend type" which is how its rendered)
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
Runtime.getRuntime().exec("echo Hello-World")
|
Runtime.getRuntime().exec("echo Hello-World")
|
||||||
|
@ -18,3 +20,4 @@ fun main(args: Array<String>) {
|
||||||
val app = Application()
|
val app = Application()
|
||||||
app.run()
|
app.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue