Skip to content

Commit

Permalink
fixed some gui things
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigermouthbear committed Apr 28, 2020
1 parent 352a9ca commit da9dcb6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group "me.tigermouthbear"
version "1.0-SNAPSHOT"
version "0.1-SNAPSHOT"

sourceCompatibility = 1.8

Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/me/tigermouthbear/theia/Theia.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ object Theia {
private lateinit var exclusions: List<String>

fun run(file: File, exclusions: List<String>): String {
val startTime = System.currentTimeMillis()

this.exclusions = exclusions

val program = Program(file)
Expand Down Expand Up @@ -55,6 +57,8 @@ object Theia {
out.append("Program all clear!\n")
}

out.append("\nTheia completed in " + (System.currentTimeMillis() - startTime) + " milliseconds")

return out.toString()
}

Expand Down
29 changes: 21 additions & 8 deletions src/main/kotlin/me/tigermouthbear/theia/gui/GUI.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package me.tigermouthbear.theia.gui

import me.tigermouthbear.theia.Theia
import java.awt.*
import java.awt.BorderLayout.*
import java.awt.BorderLayout.CENTER
import java.awt.BorderLayout.NORTH
import java.awt.Component
import java.awt.GridBagConstraints
import java.awt.GridBagLayout
import java.awt.Image
import java.io.File
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import javax.swing.*


/**
* @author Tigermouthbear
* 4/27/20
Expand All @@ -17,11 +24,14 @@ object GUI: JFrame("Theia") {
"javassist/",
"com/sun/jna/",
"org/spongepowered/"
)
)

private val cachedExec: Executor = Executors.newCachedThreadPool()

lateinit var file: File
lateinit var fileLabel: JLabel
lateinit var checkbox: JCheckBox
lateinit var runButton: JButton

fun open() {
// set look and feel
Expand Down Expand Up @@ -78,12 +88,15 @@ object GUI: JFrame("Theia") {

// add run button to botPanel
val botPanel = JPanel()
val runButton = JButton("Run")
runButton = JButton("Run")
runButton.addActionListener {
if(::file.isInitialized) {
ResultsFrame.open(Theia.run(file, if(checkbox.isSelected) defaultExclusions else listOf()))
} else {
JOptionPane.showMessageDialog(null, "Please select a file to run with!", "Error", JOptionPane.ERROR_MESSAGE)
if(runButton.text != "Running...") {
if(::file.isInitialized) {
runButton.text = "Running..."
cachedExec.execute { ResultsFrame.open(Theia.run(file, if(checkbox.isSelected) defaultExclusions else listOf())) }
} else {
JOptionPane.showMessageDialog(null, "Please select a file to run with!", "Error", JOptionPane.ERROR_MESSAGE)
}
}
}
botPanel.add(runButton)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/me/tigermouthbear/theia/gui/ResultsFrame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ object ResultsFrame: JFrame("Theia Results") {
pack() // pack elements
setSize(1200, 800)
isVisible = true // set visible

// reset run button
GUI.runButton.text = "Run"
}
}
Binary file modified src/main/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da9dcb6

Please sign in to comment.