-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add crash report window on a separate process
- Loading branch information
1 parent
7f84006
commit 47fbfb2
Showing
9 changed files
with
125 additions
and
7 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
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
65 changes: 65 additions & 0 deletions
65
EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/gui/dialog/CrashReportOutput.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,65 @@ | ||
package com.github.serivesmejia.eocvsim.gui.dialog | ||
|
||
import com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme | ||
import com.github.serivesmejia.eocvsim.gui.EOCVSimIconLibrary | ||
import com.github.serivesmejia.eocvsim.gui.dialog.component.BottomButtonsPanel | ||
import com.github.serivesmejia.eocvsim.gui.dialog.component.OutputPanel | ||
import com.github.serivesmejia.eocvsim.gui.dialog.component.OutputPanel.DefaultBottomButtonsPanel | ||
import java.awt.Dimension | ||
import java.awt.FlowLayout | ||
import java.awt.Font | ||
import javax.swing.Box | ||
import javax.swing.BoxLayout | ||
import javax.swing.JDialog | ||
import javax.swing.JFrame | ||
import javax.swing.JLabel | ||
import javax.swing.SwingUtilities | ||
import javax.swing.WindowConstants | ||
import kotlin.system.exitProcess | ||
|
||
class CrashReportOutput( | ||
parent: JFrame?, | ||
crashReport: String | ||
){ | ||
val output by lazy { | ||
JDialog(parent) | ||
} | ||
|
||
private val reportPanel by lazy { | ||
OutputPanel(DefaultBottomButtonsPanel { exitProcess(0) }) | ||
} | ||
|
||
init { | ||
FlatArcDarkIJTheme.setup() | ||
|
||
output.isModal = true | ||
output.title = "Crash Report" | ||
output.layout = BoxLayout(output.contentPane, BoxLayout.Y_AXIS) | ||
output.isAlwaysOnTop = true | ||
|
||
reportPanel.outputArea.text = crashReport | ||
SwingUtilities.invokeLater { | ||
reportPanel.resetScroll() | ||
} | ||
|
||
output.add(JLabel("An unexpected fatal error occurred, please report this to the developers.").apply { | ||
font = font.deriveFont(Font.BOLD, 18f) | ||
alignmentX = JLabel.CENTER_ALIGNMENT | ||
}) | ||
output.add(reportPanel) | ||
|
||
output.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE | ||
|
||
output.size = Dimension(800, 400) | ||
|
||
output.iconImages = listOf( | ||
EOCVSimIconLibrary.icoEOCVSim128.image, | ||
EOCVSimIconLibrary.icoEOCVSim64.image, | ||
EOCVSimIconLibrary.icoEOCVSim32.image, | ||
EOCVSimIconLibrary.icoEOCVSim16.image | ||
) | ||
|
||
output.setLocationRelativeTo(null) | ||
output.isVisible = true | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
...ain/java/com/github/serivesmejia/eocvsim/util/exception/handling/CrashReportOutputMain.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,26 @@ | ||
package com.github.serivesmejia.eocvsim.util.exception.handling | ||
|
||
import com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme | ||
import com.github.serivesmejia.eocvsim.Build | ||
import com.github.serivesmejia.eocvsim.gui.DialogFactory | ||
import com.github.serivesmejia.eocvsim.util.SysUtil | ||
import kotlinx.coroutines.Runnable | ||
import picocli.CommandLine | ||
import java.io.File | ||
|
||
object CrashReportOutputMain { | ||
@CommandLine.Command(name = "report", mixinStandardHelpOptions = true, version = [Build.versionString]) | ||
private class CrashReportOutputCommandInterface : Runnable { | ||
@CommandLine.Option(names = ["-p", "--path"], description = ["Specifies the path where the crash report was saved"]) | ||
@JvmField var crashReportPath: String? = null | ||
|
||
override fun run() { | ||
DialogFactory.createCrashReport(null, SysUtil.loadFileStr(File(crashReportPath ?: ""))) | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
CommandLine(CrashReportOutputCommandInterface()).execute(*args) | ||
} | ||
} |
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
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