Skip to content

Commit

Permalink
Improving plugin output GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Oct 27, 2024
1 parent e972891 commit 4bb17a0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public void init() {
logger.info("Creating config file...");
configLoader.saveToFile(config);
}

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
logger.info("SHUTDOWN - Saving config to file...");
saveToFile();
}));
}

public void saveToFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class PluginOutput(
}

private val output = JDialog()
private val tabbedPane: JTabbedPane

private val mavenBottomButtonsPanel: MavenOutputBottomButtonsPanel = MavenOutputBottomButtonsPanel(::close) {
mavenOutputPanel.outputArea.text
Expand All @@ -108,9 +109,16 @@ class PluginOutput(
init {
output.isModal = true
output.isAlwaysOnTop = true
output.title = "Plugin Output"
output.title = "Plugin Manager"

output.add(JTabbedPane().apply {
tabbedPane = JTabbedPane()

output.add(tabbedPane.apply {
addTab("Plugins", JPanel().apply {
layout = BoxLayout(this, BoxLayout.PAGE_AXIS)

add(JLabel("Plugins output will be shown here"))
})
addTab("Output", mavenOutputPanel)
})

Expand Down Expand Up @@ -156,6 +164,9 @@ class PluginOutput(

if(!text.startsWith(SPECIAL_SILENT) && text != SPECIAL_CLOSE && text != SPECIAL_FREE) {
SwingUtilities.invokeLater {
SwingUtilities.invokeLater {
tabbedPane.selectedIndex = tabbedPane.indexOfTab("Output") // focus on output tab
}
output.isVisible = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class PluginLoader(
fun enable() {
if(enabled || !loaded) return

logger.info("Enabling plugin $pluginName v$pluginVersion")
appender.appendln("${PluginOutput.SPECIAL_SILENT}Enabling plugin $pluginName v$pluginVersion")

plugin.enabled = true
plugin.onEnable()
Expand All @@ -212,7 +212,7 @@ class PluginLoader(
fun disable() {
if(!enabled || !loaded) return

logger.info("Disabling plugin $pluginName v$pluginVersion")
appender.appendln("${PluginOutput.SPECIAL_SILENT}Disabling plugin $pluginName v$pluginVersion")

plugin.enabled = false
plugin.onDisable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class PluginManager(val eocvSim: EOCVSim) {
loader.load()
_loadedPluginHashes.add(hash)
} catch (e: Throwable) {
appender.appendln("Failure loading ${loader.pluginName} v${loader.pluginVersion}: ${e.message}")
appender.appendln("Failure loading ${loader.pluginName} v${loader.pluginVersion}:")
appender.appendln(e.message ?: "Unknown error")
logger.error("Failure loading ${loader.pluginName} v${loader.pluginVersion}", e)

loaders.remove(file)
Expand Down

0 comments on commit 4bb17a0

Please sign in to comment.