From 09381d8a5107c577ad172b9bb84e7d5afb369fd9 Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Sun, 2 Mar 2025 11:05:53 +0100 Subject: [PATCH 1/6] fix: Ensure tip-box updates after editing the inclusion or exclusion filters --- .../components/inclusions/InclusionsEditor.kt | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/inclusions/InclusionsEditor.kt b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/inclusions/InclusionsEditor.kt index 8e85c27b..f4577f30 100644 --- a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/inclusions/InclusionsEditor.kt +++ b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/inclusions/InclusionsEditor.kt @@ -33,6 +33,7 @@ import org.apache.logging.log4j.kotlin.cachedLoggerOf import java.awt.BorderLayout import java.awt.Dimension import java.awt.datatransfer.DataFlavor +import java.awt.event.ActionListener import java.awt.event.MouseAdapter import java.awt.event.MouseEvent import java.io.File @@ -110,8 +111,7 @@ class InclusionsEditor( private val inclusionsReset = BalloonTipButton(null, guiProps.resetIcon, Translations.createserverpack_gui_buttoncopydirs_reset_tip.toString(), guiProps) { setInclusionsFromStringList(apiWrapper.apiProperties.directoriesToInclude.toMutableList()) } private var selectedInclusion: InclusionSpecification? = null - private val delay = 250 - private val tipUpdateTimer: Timer = Timer(delay) { updateTip() } + private val tipUpdateTimer: TipUpdateTimer = TipUpdateTimer(500) private val sourceListener = object : DocumentChangeListener { override fun update(e: DocumentEvent) { @@ -154,7 +154,7 @@ class InclusionsEditor( val index = inclusionList.locationToIndex(e.point) val bounds = inclusionList.getCellBounds(index, index) if (bounds == null || !bounds.contains(e.point) || inclusionList.model.size <= 0) { - emtpySelection() + emptySelection() } else { enableInputs() } @@ -177,16 +177,13 @@ class InclusionsEditor( fun checkSize() { if (inclusionList.model.size <= 0 || inclusionList.isSelectionEmpty) { - emtpySelection() + emptySelection() } } } init { source.isEditable = guiProps.allowManualEditing - tipUpdateTimer.stop() - tipUpdateTimer.delay = delay - tipUpdateTimer.isRepeats = false dividerLocation = 150 setLeftComponent(leftPanel) setRightComponent(rightPanel) @@ -234,11 +231,11 @@ class InclusionsEditor( inclusionList.addMouseListener(listMouseAdapter) inclusionList.model.addListDataListener(listModelDataAdapter) if (inclusionList.model.size <= 0) { - emtpySelection() + emptySelection() } } - private fun emtpySelection() { + private fun emptySelection() { if (inclusionList.model.size > 0 || inclusionList.valueIsAdjusting) { return } @@ -324,7 +321,7 @@ class InclusionsEditor( selectedInclusionDetailsScrollPanel.isEnabled = true inclusionList.isEnabled = true } else { - updateTip() + tipUpdateTimer.restart() } } } @@ -438,7 +435,7 @@ class InclusionsEditor( inclusionList.valueIsAdjusting -> return event.valueIsAdjusting -> return inclusionList.selectedIndex == -1 || inclusionList.model.size <= 0 -> { - emtpySelection() + emptySelection() return } } @@ -535,7 +532,7 @@ class InclusionsEditor( inclusionList.selectedIndex = 0 } if (inclusionList.model.size <= 0) { - emtpySelection() + emptySelection() } validate() return removed @@ -682,4 +679,19 @@ class InclusionsEditor( return true } } + + /** + * Timer responsible for updating the tip in the inclusions-editor. + * + * @author Griefed + */ + inner class TipUpdateTimer(delay: Int) : + Timer(delay, ActionListener { + updateTip() + }) { + init { + stop() + isRepeats = false + } + } } \ No newline at end of file -- GitLab From 0e06cdacb5ae2d4943092d1b299ba2f45b1b8eec Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Sun, 2 Mar 2025 11:07:40 +0100 Subject: [PATCH 2/6] refactor: Don't use deprecated FAO constructor. Use more general call to configHandler. --- .../app/gui/window/configs/TabbedConfigsTab.kt | 12 +++++++++--- .../window/configs/components/ConfigCheckTimer.kt | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt index 0b17a90e..c2f98169 100644 --- a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt +++ b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt @@ -37,6 +37,7 @@ import kotlinx.coroutines.swing.Swing import org.apache.commons.io.monitor.FileAlterationListener import org.apache.commons.io.monitor.FileAlterationMonitor import org.apache.commons.io.monitor.FileAlterationObserver +import org.apache.commons.io.monitor.FileEntry import org.apache.logging.log4j.kotlin.cachedLoggerOf import java.awt.datatransfer.DataFlavor import java.awt.dnd.DnDConstants @@ -63,7 +64,7 @@ class TabbedConfigsTab( private val choose = arrayOf(Translations.createserverpack_gui_quickselect_choose.toString()) private val noVersions = DefaultComboBoxModel(arrayOf(Translations.createserverpack_gui_createserverpack_forge_none.toString())) private val componentResizer = ComponentResizer() - private val timer = ConfigCheckTimer(500, guiProps, apiWrapper.configurationHandler,this) + private val timer = ConfigCheckTimer(500, guiProps, apiWrapper,this) val selectedEditor: ConfigEditor? get() { return if (activeTab != null) { @@ -277,7 +278,9 @@ class TabbedConfigsTab( @Suppress("DuplicatedCode") private fun iconsDirectoryWatcher() { Executors.newSingleThreadExecutor().execute { - val observer = FileAlterationObserver(apiWrapper.apiProperties.iconsDirectory) + val observer = FileAlterationObserver.builder() + .setRootEntry(FileEntry(apiWrapper.apiProperties.iconsDirectory)) + .get() val alterations = object : FileAlterationListener { override fun onStart(observer: FileAlterationObserver?) {} override fun onDirectoryCreate(directory: File?) {} @@ -309,6 +312,7 @@ class TabbedConfigsTab( } } } + observer.addListener(alterations) val monitor = FileAlterationMonitor(2000) monitor.addObserver(observer) @@ -323,7 +327,9 @@ class TabbedConfigsTab( @Suppress("DuplicatedCode") private fun propertiesDirectoryWatcher() { Executors.newSingleThreadExecutor().execute { - val observer = FileAlterationObserver(apiWrapper.apiProperties.propertiesDirectory) + val observer = FileAlterationObserver.builder() + .setRootEntry(FileEntry(apiWrapper.apiProperties.propertiesDirectory)) + .get() val alterations = object : FileAlterationListener { override fun onStart(observer: FileAlterationObserver?) {} override fun onDirectoryCreate(directory: File?) {} diff --git a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/ConfigCheckTimer.kt b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/ConfigCheckTimer.kt index b1ed4ac9..d8782e5f 100644 --- a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/ConfigCheckTimer.kt +++ b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/components/ConfigCheckTimer.kt @@ -20,7 +20,7 @@ package de.griefed.serverpackcreator.app.gui.window.configs.components 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.window.configs.ConfigEditor import de.griefed.serverpackcreator.app.gui.window.configs.TabbedConfigsTab @@ -35,7 +35,7 @@ import javax.swing.Timer * @author Griefed */ @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 { GlobalScope.launch(guiProps.configDispatcher, CoroutineStart.UNDISPATCHED) { var errorsEncountered = false @@ -47,7 +47,7 @@ class ConfigCheckTimer(delay: Int, guiProps: GuiProps, configHandler: Configurat runBlocking { launch { errors.addAll(editor.validateModpackDir()) - val name = configHandler.checkManifests(editor.getModpackDirectory(), pack) + val name = apiWrapper.configurationHandler.checkManifests(editor.getModpackDirectory(), pack) @Suppress("IfThenToElvis") editor.title.title = if (pack.name != null) { pack.name!! -- GitLab From 01edad17de3d56a358bea95a56ae4981b557a0d2 Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Sun, 2 Mar 2025 11:39:32 +0100 Subject: [PATCH 3/6] ci: Switch to ncipollo/release-action for continuous dev-release --- .github/workflows/devbuild.yml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/devbuild.yml b/.github/workflows/devbuild.yml index 9778b28d..dcb9de96 100644 --- a/.github/workflows/devbuild.yml +++ b/.github/workflows/devbuild.yml @@ -67,14 +67,26 @@ jobs: run: | cp checksum.txt continuous/ - - name: Upload to GitHub Releases - uses: "slord399/action-automatic-releases@v1.0.1" +# - name: Upload to GitHub Releases +# uses: "slord399/action-automatic-releases@v1.0.1" +# with: +# repo_token: "${{ secrets.GITHUB_TOKEN }}" +# automatic_release_tag: "continuous" +# prerelease: true +# files: | +# continuous/* + + - uses: ncipollo/release-action@v1 with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "continuous" - prerelease: true - files: | - continuous/* + allowUpdates: 'true' + artifacts: "continuous/*" + body: "Continuous dev-build release.<br>Updated every time changes are pushed to develop.<br>Do not use unless you have been told to, or are curious about the contents of the dev build.<br>Do not link to this release." + commit: 'develop' + name: "continuous" + prerelease: 'true' + removeArtifacts: 'true' + replacesArtifacts: 'true' + tag: 'continuous' # - name: Delete drafts # uses: hugo19941994/delete-draft-releases@v1.0.1 -- GitLab From 902bc5db503e593a971888e27a8d7d8645301ccd Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Sun, 2 Mar 2025 12:15:48 +0100 Subject: [PATCH 4/6] ci: Use GITHUB_SHA instead of 'develop' --- .github/workflows/devbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/devbuild.yml b/.github/workflows/devbuild.yml index dcb9de96..27c5963e 100644 --- a/.github/workflows/devbuild.yml +++ b/.github/workflows/devbuild.yml @@ -81,7 +81,7 @@ jobs: allowUpdates: 'true' artifacts: "continuous/*" body: "Continuous dev-build release.<br>Updated every time changes are pushed to develop.<br>Do not use unless you have been told to, or are curious about the contents of the dev build.<br>Do not link to this release." - commit: 'develop' + commit: "${{ github.sha }}" name: "continuous" prerelease: 'true' removeArtifacts: 'true' -- GitLab From fdb5cd98ea80afa575441412452c9d6e8fa3da2e Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Sun, 2 Mar 2025 12:35:56 +0100 Subject: [PATCH 5/6] ci: Update develop tag before updating develop release --- .github/workflows/devbuild.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/devbuild.yml b/.github/workflows/devbuild.yml index 27c5963e..7a7a805a 100644 --- a/.github/workflows/devbuild.yml +++ b/.github/workflows/devbuild.yml @@ -76,6 +76,13 @@ jobs: # files: | # continuous/* + - name: Update develop + uses: richardsimko/update-tag@v1 + with: + tag_name: develop + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: ncipollo/release-action@v1 with: allowUpdates: 'true' -- GitLab From 715c01ff139c1fc7cffcb235438002c8cf4ec0f0 Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Sun, 2 Mar 2025 12:52:54 +0100 Subject: [PATCH 6/6] ci: Doh. Tag name wasn't develop, but continuous. Duh. --- .github/workflows/devbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/devbuild.yml b/.github/workflows/devbuild.yml index 7a7a805a..512fa592 100644 --- a/.github/workflows/devbuild.yml +++ b/.github/workflows/devbuild.yml @@ -79,7 +79,7 @@ jobs: - name: Update develop uses: richardsimko/update-tag@v1 with: - tag_name: develop + tag_name: continuous env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -- GitLab