Skip to content
Snippets Groups Projects
Verified Commit 0e06cdac authored by Griefed's avatar Griefed :joystick:
Browse files

refactor: Don't use deprecated FAO constructor. Use more general call to configHandler.

parent 09381d8a
No related branches found
No related tags found
1 merge request!641Develop
Pipeline #9241 passed
...@@ -37,6 +37,7 @@ import kotlinx.coroutines.swing.Swing ...@@ -37,6 +37,7 @@ import kotlinx.coroutines.swing.Swing
import org.apache.commons.io.monitor.FileAlterationListener import org.apache.commons.io.monitor.FileAlterationListener
import org.apache.commons.io.monitor.FileAlterationMonitor import org.apache.commons.io.monitor.FileAlterationMonitor
import org.apache.commons.io.monitor.FileAlterationObserver import org.apache.commons.io.monitor.FileAlterationObserver
import org.apache.commons.io.monitor.FileEntry
import org.apache.logging.log4j.kotlin.cachedLoggerOf import org.apache.logging.log4j.kotlin.cachedLoggerOf
import java.awt.datatransfer.DataFlavor import java.awt.datatransfer.DataFlavor
import java.awt.dnd.DnDConstants import java.awt.dnd.DnDConstants
...@@ -63,7 +64,7 @@ class TabbedConfigsTab( ...@@ -63,7 +64,7 @@ class TabbedConfigsTab(
private val choose = arrayOf(Translations.createserverpack_gui_quickselect_choose.toString()) private val choose = arrayOf(Translations.createserverpack_gui_quickselect_choose.toString())
private val noVersions = DefaultComboBoxModel(arrayOf(Translations.createserverpack_gui_createserverpack_forge_none.toString())) private val noVersions = DefaultComboBoxModel(arrayOf(Translations.createserverpack_gui_createserverpack_forge_none.toString()))
private val componentResizer = ComponentResizer() private val componentResizer = ComponentResizer()
private val timer = ConfigCheckTimer(500, guiProps, apiWrapper.configurationHandler,this) private val timer = ConfigCheckTimer(500, guiProps, apiWrapper,this)
val selectedEditor: ConfigEditor? val selectedEditor: ConfigEditor?
get() { get() {
return if (activeTab != null) { return if (activeTab != null) {
...@@ -277,7 +278,9 @@ class TabbedConfigsTab( ...@@ -277,7 +278,9 @@ class TabbedConfigsTab(
@Suppress("DuplicatedCode") @Suppress("DuplicatedCode")
private fun iconsDirectoryWatcher() { private fun iconsDirectoryWatcher() {
Executors.newSingleThreadExecutor().execute { Executors.newSingleThreadExecutor().execute {
val observer = FileAlterationObserver(apiWrapper.apiProperties.iconsDirectory) val observer = FileAlterationObserver.builder()
.setRootEntry(FileEntry(apiWrapper.apiProperties.iconsDirectory))
.get()
val alterations = object : FileAlterationListener { val alterations = object : FileAlterationListener {
override fun onStart(observer: FileAlterationObserver?) {} override fun onStart(observer: FileAlterationObserver?) {}
override fun onDirectoryCreate(directory: File?) {} override fun onDirectoryCreate(directory: File?) {}
...@@ -309,6 +312,7 @@ class TabbedConfigsTab( ...@@ -309,6 +312,7 @@ class TabbedConfigsTab(
} }
} }
} }
observer.addListener(alterations) observer.addListener(alterations)
val monitor = FileAlterationMonitor(2000) val monitor = FileAlterationMonitor(2000)
monitor.addObserver(observer) monitor.addObserver(observer)
...@@ -323,7 +327,9 @@ class TabbedConfigsTab( ...@@ -323,7 +327,9 @@ class TabbedConfigsTab(
@Suppress("DuplicatedCode") @Suppress("DuplicatedCode")
private fun propertiesDirectoryWatcher() { private fun propertiesDirectoryWatcher() {
Executors.newSingleThreadExecutor().execute { Executors.newSingleThreadExecutor().execute {
val observer = FileAlterationObserver(apiWrapper.apiProperties.propertiesDirectory) val observer = FileAlterationObserver.builder()
.setRootEntry(FileEntry(apiWrapper.apiProperties.propertiesDirectory))
.get()
val alterations = object : FileAlterationListener { val alterations = object : FileAlterationListener {
override fun onStart(observer: FileAlterationObserver?) {} override fun onStart(observer: FileAlterationObserver?) {}
override fun onDirectoryCreate(directory: File?) {} override fun onDirectoryCreate(directory: File?) {}
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
package de.griefed.serverpackcreator.app.gui.window.configs.components package de.griefed.serverpackcreator.app.gui.window.configs.components
import Translations import Translations
import de.griefed.serverpackcreator.api.config.ConfigurationHandler import de.griefed.serverpackcreator.api.ApiWrapper
import de.griefed.serverpackcreator.app.gui.GuiProps import de.griefed.serverpackcreator.app.gui.GuiProps
import de.griefed.serverpackcreator.app.gui.window.configs.ConfigEditor import de.griefed.serverpackcreator.app.gui.window.configs.ConfigEditor
import de.griefed.serverpackcreator.app.gui.window.configs.TabbedConfigsTab import de.griefed.serverpackcreator.app.gui.window.configs.TabbedConfigsTab
...@@ -35,7 +35,7 @@ import javax.swing.Timer ...@@ -35,7 +35,7 @@ import javax.swing.Timer
* @author Griefed * @author Griefed
*/ */
@OptIn(DelicateCoroutinesApi::class) @OptIn(DelicateCoroutinesApi::class)
class ConfigCheckTimer(delay: Int, guiProps: GuiProps, configHandler: ConfigurationHandler, tabbedConfigsTab: TabbedConfigsTab) : Timer(delay, class ConfigCheckTimer(delay: Int, guiProps: GuiProps, apiWrapper: ApiWrapper, tabbedConfigsTab: TabbedConfigsTab) : Timer(delay,
ActionListener { ActionListener {
GlobalScope.launch(guiProps.configDispatcher, CoroutineStart.UNDISPATCHED) { GlobalScope.launch(guiProps.configDispatcher, CoroutineStart.UNDISPATCHED) {
var errorsEncountered = false var errorsEncountered = false
...@@ -47,7 +47,7 @@ class ConfigCheckTimer(delay: Int, guiProps: GuiProps, configHandler: Configurat ...@@ -47,7 +47,7 @@ class ConfigCheckTimer(delay: Int, guiProps: GuiProps, configHandler: Configurat
runBlocking { runBlocking {
launch { launch {
errors.addAll(editor.validateModpackDir()) errors.addAll(editor.validateModpackDir())
val name = configHandler.checkManifests(editor.getModpackDirectory(), pack) val name = apiWrapper.configurationHandler.checkManifests(editor.getModpackDirectory(), pack)
@Suppress("IfThenToElvis") @Suppress("IfThenToElvis")
editor.title.title = if (pack.name != null) { editor.title.title = if (pack.name != null) {
pack.name!! pack.name!!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment