Skip to content

Commit

Permalink
Merge branch 'ms5' into 'alpha'
Browse files Browse the repository at this point in the history
Ms5

See merge request Griefed/ServerPackCreator!527
  • Loading branch information
Griefed committed Sep 24, 2023
2 parents 9474e15 + 0719385 commit 02af29f
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,9 @@ actual class ApiProperties(
val prop = internalProps.getProperty(pHomeDirectory)
field = if (internalProps.containsKey(pHomeDirectory) && File(prop).absoluteFile.isDirectory) {
File(prop).absoluteFile
} else if (jarInformation.jarPath.toFile().isDirectory) {
// Dev environment
File("").absoluteFile
} else {
File(home, "ServerPackCreator").absoluteFile
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class LoggingConfig : ConfigurationFactory() {
val serverPackCreatorHomeDir = File(userHome, "ServerPackCreator").absoluteFile
val homeDirFile = File(serverPackCreatorHomeDir,serverPackCreatorProperties).absoluteFile
val relativeDirFile = File(serverPackCreatorProperties).absoluteFile
val overrideProperties = File(jarInformation.jarFolder.absoluteFile, "overrides.properties")

// Load the properties file from the classpath, providing default values.
try {
Expand All @@ -89,27 +90,25 @@ class LoggingConfig : ConfigurationFactory() {
loadFile(homeDirFile, props)
// If our properties-file in the directory from which the user is executing SPC exists, load it.
loadFile(relativeDirFile, props)
// If an overrides-file exists, load it
loadFile(overrideProperties,props)

val home = if (props.containsKey("de.griefed.serverpackcreator.home")) {
File(props.getProperty("de.griefed.serverpackcreator.home"))
} else {
if (jarInformation.jarPath.toFile().isDirectory) {
// Dev environment
isDevVersion = true
File(File("tests").absolutePath)
File("").absoluteFile
} else {
File(userHome, "ServerPackCreator")
}
}
home.createDirectories(create = true, directory = true)

if (isDevVersion) {
logDirPath = File(home, "tests/logs").absolutePath
log4jXml = File(home, "tests/log4j2.xml")
} else {
logDirPath = File(home, "logs").absolutePath
log4jXml = File(home, "log4j2.xml")
}
logDirPath = File(home, "logs").absolutePath
log4jXml = File(home, "log4j2.xml")

val oldLogs = "<Property name=\"log-path\">logs</Property>"
val newLogs = "<Property name=\"log-path\">$logDirPath</Property>"
if (!log4jXml.isFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,4 +506,29 @@ actual fun File.createDirectories(create: Boolean, directory: Boolean) {
this.createNewFile()
}
}
}

/**
* Test whether files can be written to this file denoting a directory.
* If this file is not a directory, an [IllegalArgumentException] will be thrown.
*
* @author Griefed
*/
@Throws(IllegalArgumentException::class)
fun File.testFileWrite() : Boolean {
if (!this.isDirectory) {
throw(IllegalArgumentException("Destination must be a directory."))
}
return try {
val file = File(this,"poke")
file.writeText("writable")
if (file.exists()) {
file.deleteQuietly()
true
} else {
false
}
} catch (ex: Exception) {
false
}
}
2 changes: 2 additions & 0 deletions serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ settings.global=Global
settings.global.home.tooltip=ServerPackCreator home-directory upon which most operations a build upon.
settings.global.home.label=Home directory
settings.global.home.chooser=Home Directory Chooser
settings.directory.filter=Writable Directory
settings.directory.error=Your chosen directory {0} can not be written to.
settings.global.java.tooltip=Java executable/binary used for server pack server installation
settings.global.java.label=Java
settings.global.java.executable=Select executable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import Gui
import de.comahe.i18n4k.Locale
import de.griefed.serverpackcreator.api.ApiProperties
import de.griefed.serverpackcreator.api.ExclusionFilter
import de.griefed.serverpackcreator.api.utilities.common.deleteQuietly

Check warning on line 26 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import de.griefed.serverpackcreator.api.utilities.common.testFileWrite
import de.griefed.serverpackcreator.gui.GuiProps
import de.griefed.serverpackcreator.gui.components.*
import de.griefed.serverpackcreator.gui.window.MainFrame
Expand All @@ -34,6 +36,7 @@ import java.net.MalformedURLException
import java.net.URL
import javax.swing.DefaultComboBoxModel
import javax.swing.JFileChooser
import javax.swing.JOptionPane

/**
* @author Griefed
Expand All @@ -55,7 +58,14 @@ class GlobalSettings(
val homeChoose = BalloonTipButton(null,guiProps.folderIcon,Gui.settings_select_directory.toString(),guiProps) {

Check notice on line 58 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'homeChoose' could be private
val homeChooser = HomeDirChooser(apiProperties,Gui.settings_global_home_chooser.toString())
if (homeChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) {
homeSetting.file = homeChooser.selectedFile.absoluteFile
if (homeChooser.selectedFile.absoluteFile.testFileWrite()) {
homeSetting.file = homeChooser.selectedFile.absoluteFile
} else {
JOptionPane.showMessageDialog(
mainFrame.frame,
Gui.settings_directory_error(homeChooser.selectedFile.absolutePath)
)
}
}
}

Expand All @@ -79,7 +89,14 @@ class GlobalSettings(
val serverPacksChoose = BalloonTipButton(null,guiProps.folderIcon,Gui.settings_select_directory.toString(),guiProps) {

Check notice on line 89 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'serverPacksChoose' could be private
val serverPackDirChooser = ServerPackDirChooser(apiProperties,Gui.settings_global_serverpacks_chooser.toString())
if (serverPackDirChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) {
serverPacksSetting.file = serverPackDirChooser.selectedFile.absoluteFile
if (serverPackDirChooser.selectedFile.absoluteFile.testFileWrite()) {
serverPacksSetting.file = serverPackDirChooser.selectedFile.absoluteFile
} else {
JOptionPane.showMessageDialog(
mainFrame.frame,
Gui.settings_directory_error(serverPackDirChooser.selectedFile.absoluteFile)
)
}
}
}

Expand Down Expand Up @@ -115,12 +132,7 @@ class GlobalSettings(

val fallbackURLIcon = StatusIcon(guiProps, Gui.settings_global_fallbackurl_tooltip.toString())

Check notice on line 133 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'fallbackURLIcon' could be private
val fallbackURLLabel = ElementLabel(Gui.settings_global_fallbackurl_label.toString())

Check notice on line 134 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'fallbackURLLabel' could be private
val fallbackURLSetting = ScrollTextField(
guiProps,
apiProperties.updateUrl.toString(),
Gui.settings_global_fallbackurl_label.toString(),
changeListener
)
val fallbackURLSetting = ScrollTextField(guiProps,apiProperties.updateUrl.toString(),Gui.settings_global_fallbackurl_label.toString(),changeListener)

Check notice on line 135 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'fallbackURLSetting' could be private
val fallbackURLRevert = BalloonTipButton(null, guiProps.revertIcon, Gui.settings_revert.toString(), guiProps) { fallbackURLSetting.text = apiProperties.updateUrl.toString() }

Check notice on line 136 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'fallbackURLRevert' could be private
val fallbackURLReset = BalloonTipButton(null,guiProps.resetIcon,Gui.settings_reset.toString(),guiProps) { fallbackURLSetting.text = apiProperties.fallbackUpdateURL }

Check notice on line 137 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/GlobalSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'fallbackURLReset' could be private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import com.cronutils.model.CronType
import com.cronutils.model.definition.CronDefinitionBuilder
import com.cronutils.parser.CronParser
import de.griefed.serverpackcreator.api.ApiProperties
import de.griefed.serverpackcreator.api.utilities.common.testFileWrite
import de.griefed.serverpackcreator.gui.GuiProps
import de.griefed.serverpackcreator.gui.components.*
import de.griefed.serverpackcreator.gui.window.MainFrame
import de.griefed.serverpackcreator.gui.window.settings.components.*
import java.io.File
import javax.swing.JFileChooser
import javax.swing.JOptionPane
import javax.swing.event.ChangeListener

/**
Expand All @@ -53,7 +55,14 @@ class WebserviceSettings(
val artemisDataDirectoryChoose = BalloonTipButton(null,guiProps.folderIcon,Gui.settings_select_directory.toString(),guiProps) {

Check notice on line 55 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'artemisDataDirectoryChoose' could be private
val artemisChooser = ArtemisDataDirChooser(apiProperties,Gui.settings_webservice_artemisdata_chooser.toString())
if (artemisChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) {
artemisDataDirectorySetting.file = artemisChooser.selectedFile.absoluteFile
if (artemisChooser.selectedFile.absoluteFile.testFileWrite()) {
artemisDataDirectorySetting.file = artemisChooser.selectedFile.absoluteFile
} else {
JOptionPane.showMessageDialog(
mainFrame.frame,
Gui.settings_directory_error(artemisChooser.selectedFile.absoluteFile)
)
}
}
}

Expand All @@ -71,18 +80,20 @@ class WebserviceSettings(
val databaseFileChoose = BalloonTipButton(null,guiProps.folderIcon,Gui.settings_select_directory.toString(),guiProps) {

Check notice on line 80 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'databaseFileChoose' could be private
val webserviceChooser = WebserviceDBDirChooser(apiProperties,Gui.settings_webservice_database_chooser.toString())
if (webserviceChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) {
databaseFileSetting.file = File(webserviceChooser.selectedFile.absoluteFile,"serverpackcreator.db").absoluteFile
if (webserviceChooser.selectedFile.absoluteFile.testFileWrite()) {
databaseFileSetting.file = File(webserviceChooser.selectedFile.absoluteFile,"serverpackcreator.db").absoluteFile
} else {
JOptionPane.showMessageDialog(
mainFrame.frame,
Gui.settings_directory_error(webserviceChooser.selectedFile.absoluteFile)
)
}
}
}

val cleanupScheduleIcon = StatusIcon(guiProps,Gui.settings_webservice_schedule_cleanup_tooltip.toString())

Check notice on line 94 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'cleanupScheduleIcon' could be private
val cleanupScheduleLabel = ElementLabel(Gui.settings_webservice_schedule_cleanup_label.toString())

Check notice on line 95 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'cleanupScheduleLabel' could be private
val cleanupScheduleSetting = ScrollTextField(
guiProps,
apiProperties.webserviceCleanupSchedule,
Gui.settings_webservice_schedule_cleanup_label.toString(),
documentChangeListener
)
val cleanupScheduleSetting = ScrollTextField(guiProps,apiProperties.webserviceCleanupSchedule,Gui.settings_webservice_schedule_cleanup_label.toString(),documentChangeListener)

Check notice on line 96 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'cleanupScheduleSetting' could be private
val cleanupRevert = BalloonTipButton(null,guiProps.revertIcon,Gui.settings_revert.toString(),guiProps) { cleanupScheduleSetting.text = apiProperties.webserviceCleanupSchedule }

Check notice on line 97 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'cleanupRevert' could be private
val cleanupReset = BalloonTipButton(null,guiProps.resetIcon,Gui.settings_reset.toString(),guiProps) { cleanupScheduleSetting.text = apiProperties.fallbackCleanupSchedule }

Check notice on line 98 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'cleanupReset' could be private

Expand All @@ -94,7 +105,14 @@ class WebserviceSettings(
val logDirectoryChoose = BalloonTipButton(null,guiProps.folderIcon,Gui.settings_select_directory.toString(),guiProps) {

Check notice on line 105 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'logDirectoryChoose' could be private
val logDirectoryChooser = TomcatLogDirChooser(apiProperties,Gui.settings_webservice_tomcat_logs_chooser.toString())
if (logDirectoryChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) {
logDirectorySetting.file = logDirectoryChooser.selectedFile.absoluteFile
if (logDirectoryChooser.selectedFile.absoluteFile.testFileWrite()) {
logDirectorySetting.file = logDirectoryChooser.selectedFile.absoluteFile
} else {
JOptionPane.showMessageDialog(
mainFrame.frame,
Gui.settings_directory_error(logDirectoryChooser.selectedFile.absoluteFile)
)
}
}
}

Expand All @@ -106,29 +124,26 @@ class WebserviceSettings(
val baseDirChoose = BalloonTipButton(null,guiProps.folderIcon,Gui.settings_select_directory.toString(),guiProps) {

Check notice on line 124 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'baseDirChoose' could be private
val baseDirChooser = TomcatBaseDirChooser(apiProperties,Gui.settings_webservice_tomcat_dir_chooser.toString())
if (baseDirChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) {
baseDirSetting.file = baseDirChooser.selectedFile.absoluteFile
if (baseDirChooser.selectedFile.absoluteFile.testFileWrite()) {
baseDirSetting.file = baseDirChooser.selectedFile.absoluteFile
} else {
JOptionPane.showMessageDialog(
mainFrame.frame,
Gui.settings_directory_error(baseDirChooser.selectedFile.absoluteFile)
)
}
}
}

val versionScheduleIcon = StatusIcon(guiProps,Gui.settings_webservice_schedule_versions_tooltip.toString())

Check notice on line 138 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'versionScheduleIcon' could be private
val versionScheduleLabel = ElementLabel(Gui.settings_webservice_schedule_versions_label.toString())

Check notice on line 139 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'versionScheduleLabel' could be private
val versionScheduleSetting = ScrollTextField(
guiProps,
apiProperties.webserviceVersionSchedule,
Gui.settings_webservice_schedule_versions_label.toString(),
documentChangeListener
)
val versionScheduleSetting = ScrollTextField(guiProps,apiProperties.webserviceVersionSchedule,Gui.settings_webservice_schedule_versions_label.toString(),documentChangeListener)

Check notice on line 140 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'versionScheduleSetting' could be private
val versionRevert = BalloonTipButton(null,guiProps.revertIcon,Gui.settings_revert.toString(),guiProps) { versionScheduleSetting.text = apiProperties.webserviceVersionSchedule }

Check notice on line 141 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'versionRevert' could be private
val versionReset = BalloonTipButton(null,guiProps.resetIcon,Gui.settings_reset.toString(),guiProps) { versionScheduleSetting.text = apiProperties.fallbackVersionSchedule }

Check notice on line 142 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'versionReset' could be private

val databaseCleanupScheduleIcon = StatusIcon(guiProps,Gui.settings_webservice_schedule_database_tooltip.toString())

Check notice on line 144 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'databaseCleanupScheduleIcon' could be private
val databaseCleanupScheduleLabel = ElementLabel(Gui.settings_webservice_schedule_database_label.toString())

Check notice on line 145 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'databaseCleanupScheduleLabel' could be private
val databaseCleanupScheduleSetting = ScrollTextField(
guiProps,
apiProperties.webserviceDatabaseCleanupSchedule,
Gui.settings_webservice_schedule_database_label.toString(),
documentChangeListener
)
val databaseCleanupScheduleSetting = ScrollTextField(guiProps,apiProperties.webserviceDatabaseCleanupSchedule,Gui.settings_webservice_schedule_database_label.toString(),documentChangeListener)

Check notice on line 146 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'databaseCleanupScheduleSetting' could be private
val databaseCleanupRevert = BalloonTipButton(null,guiProps.revertIcon,Gui.settings_revert.toString(),guiProps) { databaseCleanupScheduleSetting.text = apiProperties.webserviceDatabaseCleanupSchedule }

Check notice on line 147 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'databaseCleanupRevert' could be private
val databaseCleanupReset = BalloonTipButton(null,guiProps.resetIcon,Gui.settings_reset.toString(),guiProps) { databaseCleanupScheduleSetting.text = apiProperties.fallbackDatabaseCleanupSchedule }

Check notice on line 148 in serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/settings/WebserviceSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'databaseCleanupReset' could be private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class ArtemisDataDirChooser(apiProperties: ApiProperties, title: String) : JFile
isMultiSelectionEnabled = false
dialogType = SAVE_DIALOG
preferredSize = Dimension(750, 450)
fileFilter = WritableDirectoryFilter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class HomeDirChooser(apiProperties: ApiProperties, title: String) : JFileChooser
isMultiSelectionEnabled = false
dialogType = SAVE_DIALOG
preferredSize = Dimension(750, 450)
fileFilter = WritableDirectoryFilter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class ServerPackDirChooser(apiProperties: ApiProperties, title: String) : JFileC
isMultiSelectionEnabled = false
dialogType = SAVE_DIALOG
preferredSize = Dimension(750, 450)
fileFilter = WritableDirectoryFilter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class TomcatBaseDirChooser(apiProperties: ApiProperties, title: String) : JFileC
isMultiSelectionEnabled = false
dialogType = SAVE_DIALOG
preferredSize = Dimension(750, 450)
fileFilter = WritableDirectoryFilter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class TomcatLogDirChooser(apiProperties: ApiProperties, title: String) : JFileCh
isMultiSelectionEnabled = false
dialogType = SAVE_DIALOG
preferredSize = Dimension(750, 450)
fileFilter = WritableDirectoryFilter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class WebserviceDBDirChooser(apiProperties: ApiProperties, title: String) : JFil
isMultiSelectionEnabled = false
dialogType = SAVE_DIALOG
preferredSize = Dimension(750, 450)
fileFilter = WritableDirectoryFilter()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.griefed.serverpackcreator.gui.window.settings.components

import java.io.File

class WritableDirectoryFilter : javax.swing.filechooser.FileFilter() {
override fun accept(file: File): Boolean {
val files = file.walk().filter { it.isDirectory }
return file.isDirectory && (file.canWrite() || files.any { it.canWrite() })
}

override fun getDescription(): String {
return Gui.settings_directory_filter.toString()
}
}

0 comments on commit 02af29f

Please sign in to comment.