Cleanup
This commit is contained in:
parent
6b5076eea5
commit
8cc0dc57b6
4 changed files with 46 additions and 50 deletions
|
@ -1,8 +1,7 @@
|
||||||
package org.bm00.DataAccessor
|
package org.bm00.dataAccessor
|
||||||
|
|
||||||
import jexer.TApplication
|
import jexer.TApplication
|
||||||
import jexer.demos.DemoApplication
|
import org.bm00.dataAccessor.windows.WelcomeWindow
|
||||||
import org.bm00.DataAccessor.windows.WelcomeWindow
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
//// OS CHECKER ////
|
//// OS CHECKER ////
|
||||||
|
@ -11,7 +10,7 @@ enum class OS {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getOS(): OS? {
|
fun getOS(): OS? {
|
||||||
val isJexer = System.getProperty("jexer.Swing")
|
//val isJexer = System.getProperty("jexer.Swing")
|
||||||
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
|
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
|
||||||
return when {
|
return when {
|
||||||
os.contains("win") -> {
|
os.contains("win") -> {
|
|
@ -1,6 +1,5 @@
|
||||||
package org.bm00.DataAccessor
|
package org.bm00.dataAccessor
|
||||||
|
|
||||||
import jexer.TApplication.BackendType
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
|
@ -1,10 +1,10 @@
|
||||||
package org.bm00.DataAccessor.windows
|
package org.bm00.dataAccessor.windows
|
||||||
|
|
||||||
import jexer.TAction
|
import jexer.TAction
|
||||||
import jexer.TApplication
|
import jexer.TApplication
|
||||||
import jexer.TWindow
|
import jexer.TWindow
|
||||||
import jexer.layout.StretchLayoutManager
|
import jexer.layout.StretchLayoutManager
|
||||||
import org.bm00.DataAccessor.osName
|
import org.bm00.dataAccessor.osName
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
//// OS CHECKER ////
|
//// OS CHECKER ////
|
||||||
|
@ -13,7 +13,7 @@ enum class OS {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getOS(): OS? {
|
fun getOS(): OS? {
|
||||||
val isJexer = System.getProperty("jexer.Swing")
|
System.getProperty("jexer.Swing")
|
||||||
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
|
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
|
||||||
return when {
|
return when {
|
||||||
os.contains("win") -> {
|
os.contains("win") -> {
|
||||||
|
@ -39,11 +39,38 @@ val osName =
|
||||||
}
|
}
|
||||||
//// OS CHECKER ////
|
//// OS CHECKER ////
|
||||||
|
|
||||||
|
const val windowWidth = 36
|
||||||
|
const val windowHeight = 19
|
||||||
|
const val textFieldWidth = 16
|
||||||
|
|
||||||
class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
||||||
TWindow(parent, "Login", 0, 0, 36, 19, flags) {
|
TWindow(parent, "Login", 0, 0, windowWidth, windowHeight, flags) {
|
||||||
constructor(parent: TApplication) : this(parent, CENTERED)
|
constructor(parent: TApplication) : this(parent, CENTERED)
|
||||||
|
|
||||||
var loginField = addPasswordField(CENTERED + 5, CENTERED - 1, 16, false, "",
|
var loginField = addPasswordField(CENTERED + 5, CENTERED - 1, textFieldWidth, false, "",
|
||||||
|
// enterAction - function to call a when an enter key is pressed
|
||||||
|
object : TAction() {
|
||||||
|
override fun DO() {
|
||||||
|
if (osName == "LINUX") {
|
||||||
|
loginActivityLinux()
|
||||||
|
}
|
||||||
|
else if (osName == "WINDOWS") {
|
||||||
|
loginActivityWindows()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// updateAction - function to call when the text is updated
|
||||||
|
object : TAction() {
|
||||||
|
override fun DO() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
var serverField = addPasswordField(CENTERED + 5, CENTERED + 3, textFieldWidth, false, "",
|
||||||
// enterAction - function to call when enter key is pressed
|
// enterAction - function to call when enter key is pressed
|
||||||
object : TAction() {
|
object : TAction() {
|
||||||
override fun DO() {
|
override fun DO() {
|
||||||
|
@ -64,31 +91,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
var serverField = addPasswordField(CENTERED + 5, CENTERED + 3, 16, false, "",
|
|
||||||
// enterAction - function to call when enter key is pressed
|
|
||||||
object : TAction() {
|
|
||||||
override fun DO() {
|
|
||||||
if (osName == "LINUX") {
|
|
||||||
loginActivityLinux()
|
|
||||||
}
|
|
||||||
else if (osName == "WINDOWS") {
|
|
||||||
loginActivityWindows()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// updateAction - function to call when the text is updated
|
|
||||||
object : TAction() {
|
|
||||||
override fun DO() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//Called if on Linux and the login has been initiated
|
//Called if on Linux and the login has been initiated
|
||||||
fun loginActivityLinux() {
|
fun loginActivityLinux() {
|
||||||
|
@ -134,12 +137,10 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setLayoutManager(
|
layoutManager = StretchLayoutManager(
|
||||||
StretchLayoutManager(
|
|
||||||
width - 2,
|
width - 2,
|
||||||
height - 2
|
height - 2
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
var sharedCheck = addCheckBox( CENTERED + 4, CENTERED + 5, "Shared Folder?",false)
|
var sharedCheck = addCheckBox( CENTERED + 4, CENTERED + 5, "Shared Folder?",false)
|
||||||
//TODO: Login to shared folder?... hmmm
|
//TODO: Login to shared folder?... hmmm
|
|
@ -1,21 +1,18 @@
|
||||||
package org.bm00.DataAccessor.windows
|
package org.bm00.dataAccessor.windows
|
||||||
|
|
||||||
import jexer.TAction
|
import jexer.TAction
|
||||||
import jexer.TApplication
|
import jexer.TApplication
|
||||||
import jexer.TWindow
|
import jexer.TWindow
|
||||||
import jexer.layout.StretchLayoutManager
|
import jexer.layout.StretchLayoutManager
|
||||||
import org.bm00.DataAccessor.main
|
|
||||||
|
|
||||||
class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
|
class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
|
||||||
TWindow(parent, "O.S.D.A.", 0, 0, 46, 10, flags) {
|
TWindow(parent, "O.S.D.A.", 0, 0, 46, 10, flags) {
|
||||||
constructor(parent: TApplication) : this(parent, CENTERED)
|
constructor(parent: TApplication) : this(parent, CENTERED)
|
||||||
init {
|
init {
|
||||||
setLayoutManager(
|
layoutManager = StretchLayoutManager(
|
||||||
StretchLayoutManager(
|
|
||||||
width - 2,
|
width - 2,
|
||||||
height - 2
|
height - 2
|
||||||
)
|
)
|
||||||
)
|
|
||||||
addLabel("Welcome to", CENTERED + 13, CENTERED - 4)
|
addLabel("Welcome to", CENTERED + 13, CENTERED - 4)
|
||||||
addLabel("The ORG-NAME-WIP Secure Data Accessor", CENTERED, CENTERED - 3)
|
addLabel("The ORG-NAME-WIP Secure Data Accessor", CENTERED, CENTERED - 3)
|
||||||
addButton("Options", CENTERED + 13, CENTERED,
|
addButton("Options", CENTERED + 13, CENTERED,
|
||||||
|
@ -30,7 +27,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
|
||||||
addButton("Exit...", CENTERED + 28, CENTERED,
|
addButton("Exit...", CENTERED + 28, CENTERED,
|
||||||
object : TAction() {
|
object : TAction() {
|
||||||
override fun DO() {
|
override fun DO() {
|
||||||
if (org.bm00.DataAccessor.osName == "LINUX") {
|
if (org.bm00.dataAccessor.osName == "LINUX") {
|
||||||
ProcessBuilder("umount", "/tmp/osda_mount")
|
ProcessBuilder("umount", "/tmp/osda_mount")
|
||||||
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
||||||
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
||||||
|
@ -38,7 +35,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
|
||||||
.waitFor()
|
.waitFor()
|
||||||
System.exit(0)
|
System.exit(0)
|
||||||
}
|
}
|
||||||
else if (org.bm00.DataAccessor.osName == "WINDOWS") {
|
else if (org.bm00.dataAccessor.osName == "WINDOWS") {
|
||||||
ProcessBuilder("net", "use", "O:", "/delete")
|
ProcessBuilder("net", "use", "O:", "/delete")
|
||||||
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
||||||
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
Loading…
Reference in a new issue