-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throws error, no crash when no data on submit.
- Loading branch information
Showing
11 changed files
with
228 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
src/main/kotlin/org/b12x/gfe/core/controller/tabstate/ComparisonState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
package org.b12x.gfe.core.controller.tabstate | ||
|
||
import org.b12x.gfe.core.controller.version.CreateNewHlaVersionObject | ||
import org.b12x.gfe.core.controller.version.Version | ||
import kotlin.properties.Delegates | ||
|
||
class ComparisonState: TabState { | ||
|
||
/* What tab */ | ||
override fun getTab(ctx: TabStateContext) = "COMP" | ||
|
||
/* Version */ | ||
override fun getCurrentVersion(ctx: TabStateContext): String { | ||
return "version" | ||
|
||
override var version: String by Delegates.observable(PrefsTabSearch.currentVersionHla) | ||
{ _, _, newValue -> | ||
PrefsTabSearch.currentVersionHla = newValue | ||
} | ||
|
||
override var versionObject: Version by Delegates.observable( | ||
CreateNewHlaVersionObject.createVersionObject("HLA", version) | ||
) { _, _, _ -> } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/org/b12x/gfe/core/controller/tabstate/OptionState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.b12x.gfe.core.controller.tabstate | ||
|
||
import org.b12x.gfe.core.controller.version.CreateNewHlaVersionObject | ||
import org.b12x.gfe.core.controller.version.Version | ||
import kotlin.properties.Delegates | ||
|
||
class OptionState : TabState { | ||
|
||
/* What tab */ | ||
override fun getTab(ctx: TabStateContext) = "OPT" | ||
|
||
/* Version */ | ||
override var version: String by Delegates.observable(PrefsTabSearch.currentVersionHla) | ||
{ _, _, newValue -> | ||
PrefsTabSearch.currentVersionHla = newValue | ||
} | ||
|
||
override var versionObject: Version by Delegates.observable( | ||
CreateNewHlaVersionObject.createVersionObject("HLA", version) | ||
) { _, _, _ -> } | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/org/b12x/gfe/core/controller/tabstate/PrefsTabSearch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.b12x.gfe.core.controller.tabstate | ||
|
||
import org.b12x.gfe.GSG | ||
import org.b12x.gfe.core.controller.PrefsCore | ||
import org.b12x.gfe.utilities.DirectoryManagement | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.util.prefs.Preferences | ||
import kotlin.io.path.exists | ||
import kotlin.io.path.isDirectory | ||
import kotlin.properties.Delegates | ||
|
||
object PrefsTabSearch { | ||
|
||
var prefs: Preferences = PrefsCore.prefs | ||
|
||
var currentLociGroup: String by Delegates.observable( | ||
prefs.get( | ||
"currentLociGroup", | ||
"HLA" | ||
) | ||
) { _, _, new -> | ||
prefs.put("currentLociGroup", new) | ||
} | ||
|
||
var currentVersionHla: String by Delegates.observable( | ||
prefs.get( | ||
"currentVersionHla", | ||
defaultHlaVersion() | ||
) | ||
) { _, _, new -> | ||
prefs.put("currentVersionHla", new) | ||
} | ||
|
||
// checks for existing HLA directory, creates one if it doesn't exist | ||
// This should allow it to boot on systems without data | ||
private fun defaultHlaVersion() : String { | ||
val directoryManagement = DirectoryManagement() | ||
val gsgDataLocation = directoryManagement.setLociLocation("HLA") | ||
|
||
if (Paths.get(gsgDataLocation).exists() and (File(gsgDataLocation).list()?.isNotEmpty() == true)) { | ||
val fileList = File(gsgDataLocation).listFiles() | ||
val directories = fileList!!.filter { it.isDirectory }.toMutableList() // !! - checked in the if statement above | ||
directories.sort() | ||
return directories.last().toString().split("/").last() | ||
} else { | ||
Files.createDirectories(Paths.get(gsgDataLocation)) | ||
} | ||
|
||
// Files.createDirectories(Paths.get(gsgDataLocation)) | ||
return "" | ||
} | ||
|
||
var currentGfeSearchVersionKir: String by Delegates.observable( | ||
prefs.get( | ||
"currentVersionKir", | ||
"2.7.0" | ||
) | ||
) { _, _, new -> | ||
prefs.put("currentVersionKir", new) | ||
} | ||
} |
15 changes: 13 additions & 2 deletions
15
src/main/kotlin/org/b12x/gfe/core/controller/tabstate/TabState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package org.b12x.gfe.core.controller.tabstate | ||
|
||
import org.b12x.gfe.plugins.gfesearch.controller.locistategfesearch.LociStateContextGfeSearch | ||
import org.b12x.gfe.core.controller.loci.LociEnum | ||
import org.b12x.gfe.core.controller.version.Version | ||
|
||
interface TabState { | ||
|
||
/* What Tab */ | ||
fun getTab(ctx: TabStateContext): String | ||
|
||
/* Loci */ | ||
// var loci: String | ||
|
||
/* Version */ | ||
fun getCurrentVersion(ctx: TabStateContext): String | ||
var version: String | ||
var versionObject: Version | ||
// fun getCurrentVersion(ctx: TabStateContext): String | ||
|
||
/* Locus*/ | ||
// var locus: String | ||
// var locusEnum: LociEnum | ||
// fun updateLocuses(ctx: TabStateContext) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.