Skip to content

Commit bbf7306

Browse files
committed
Vis-gui: use dataset from CWD by default
1 parent 98f1b02 commit bbf7306

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

visualizer-gui/src/main/kotlin/io/github/ksmirenko/kotlin/visualizerGui/model/Model.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ object Model {
1717

1818
private var anomalyIterator: Iterator<Anomaly>? = null
1919
private var curAnomaly: Anomaly? = null
20-
private var outFileName: String? = null
20+
private var outFile: File? = null
2121
private var outCsv: CSVPrinter? = null
2222

23+
fun openDefaultDataset() {
24+
openDataset(File("anomalies_grouped"))
25+
}
26+
2327
fun openDataset(repoRoot: File) {
24-
val dirs = repoRoot.listFiles() ?: return
28+
val dirs = repoRoot.listFiles()?.sorted() ?: return
2529

2630
val anomalySequence = buildSequence {
2731
for (dir in dirs) {
@@ -30,7 +34,7 @@ object Model {
3034
}
3135

3236
val categoryName = dir.name
33-
for (file in dir.listFiles()) {
37+
for (file in dir.listFiles().sorted()) {
3438
if (file.extension != "kt") {
3539
continue
3640
}
@@ -52,8 +56,8 @@ object Model {
5256

5357
outCsv?.close()
5458
val timestamp = SimpleDateFormat("MM-dd-HH-mm").format(Date())
55-
outFileName = "marked_$timestamp.csv"
56-
outCsv = CSVFormat.EXCEL.print(File(outFileName), Charsets.UTF_8)
59+
outFile = File("marked_$timestamp.csv")
60+
outCsv = CSVFormat.EXCEL.print(outFile, Charsets.UTF_8)
5761
}
5862

5963
fun processUserResponse(response: UserResponse) {
@@ -117,11 +121,12 @@ object Model {
117121
outCsv!!.close()
118122

119123
information("Finished dataset!",
120-
"You are done! Please send $outFileName to the code anomaly researchers.")
124+
"You are done! Please send the file \"${outFile!!.path}\"" +
125+
" (in current working directory) to the code anomaly researchers.")
121126

122127
anomalyIterator = null
123128
curAnomaly = null
124-
outFileName = null
129+
outFile = null
125130
outCsv = null
126131
}
127132

visualizer-gui/src/main/kotlin/io/github/ksmirenko/kotlin/visualizerGui/view/MainWindow.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ class MainWindow : View("Code anomaly visualizer GUI") {
2424
root += buttonRow.root
2525

2626
root.requestFocus()
27+
28+
Model.openDefaultDataset()
2729
}
2830
}
2931

3032
class SelectDatasetButton : View() {
31-
override val root = button("SELECT DATASET") {
33+
override val root = button("CHANGE DATASET") {
3234
vboxConstraints {
3335
marginTopBottom(R.MARGIN_SMALL)
3436
marginLeftRight(R.MARGIN_SMALL)

0 commit comments

Comments
 (0)