summaryrefslogtreecommitdiff
path: root/src/main/kotlin/me/kyren223/trident/data
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-05-12 12:52:59 +0300
committerKyren223 <ulmliad223@gmail.com>2024-05-12 12:52:59 +0300
commit256192111877482a2e2ceeda806064920008b59e (patch)
tree54a635b00ad44013263bdcea6413322b622063e7 /src/main/kotlin/me/kyren223/trident/data
parenta1f61bf81106f2d2981686c24398cfbfe7eae17d (diff)
Version 2.1.0
Fixed a bunch of issues with the new changes Trident settings are now under "tools" section Updated README.md Renamed some UI elements
Diffstat (limited to 'src/main/kotlin/me/kyren223/trident/data')
-rw-r--r--src/main/kotlin/me/kyren223/trident/data/Settings.kt5
-rw-r--r--src/main/kotlin/me/kyren223/trident/data/SettingsData.kt56
2 files changed, 50 insertions, 11 deletions
diff --git a/src/main/kotlin/me/kyren223/trident/data/Settings.kt b/src/main/kotlin/me/kyren223/trident/data/Settings.kt
index 27a7d2a..a1a400b 100644
--- a/src/main/kotlin/me/kyren223/trident/data/Settings.kt
+++ b/src/main/kotlin/me/kyren223/trident/data/Settings.kt
@@ -8,7 +8,7 @@ import com.intellij.openapi.components.*
@State(name = "me.kyren223.trident.data.SettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
class Settings : SimplePersistentStateComponent<SettingsState>(SettingsState()) {
companion object {
- val instance: Settings
+ private val instance: Settings
get() = ApplicationManager.getApplication().getService(Settings::class.java)
val state: SettingsState
get() = instance.state
@@ -20,7 +20,8 @@ class SettingsState : BaseState() {
var height = 400
var fontSize = 20
var enterToSelect = true
- var automaticMapping = false
+ var automaticMapping = AutomaticMapping.Disabled
+ var automaticReplacing = AutomaticReplacing.Smart
var recursiveMapping = false
var rememberLine = false
var indexCycling = false
diff --git a/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt b/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
index eed655e..b4c48f7 100644
--- a/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
+++ b/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
@@ -1,5 +1,6 @@
package me.kyren223.trident.data
+import com.intellij.openapi.ui.ComboBox
import com.intellij.ui.JBColor
import com.intellij.ui.JBIntSpinner
import com.intellij.ui.components.JBCheckBox
@@ -9,7 +10,7 @@ import com.intellij.util.ui.JBFont
import javax.swing.JPanel
class SettingsData {
-
+
private val minValue = 1
private val maxValue = 5000
private val step = 10
@@ -22,11 +23,15 @@ class SettingsData {
private val enterToSelect = JBCheckBox(null, Settings.state.enterToSelect)
private val rememberLine = JBCheckBox(null, Settings.state.rememberLine)
- private val automaticMapping = JBCheckBox(null, Settings.state.automaticMapping)
+ private val automaticMapping = ComboBox(AutomaticMapping.entries.toTypedArray())
+ private val automaticReplacing = ComboBox(AutomaticReplacing.entries.toTypedArray())
private val recursiveMapping = JBCheckBox(null, Settings.state.recursiveMapping)
private val indexCycling = JBCheckBox(null, Settings.state.indexCycling)
init {
+ automaticMapping.selectedItem = Settings.state.automaticMapping
+ automaticReplacing.selectedItem = Settings.state.automaticReplacing
+
panel = FormBuilder.createFormBuilder()
.addComponent(JBLabel("Popup settings").withFont(JBFont.h4()))
.addLabeledComponent("Popup width", width)
@@ -41,9 +46,16 @@ class SettingsData {
.addVerticalGap(step)
.addLabeledComponent("Automatic mapping (when possible)", automaticMapping)
- .addComponent(desc("If enabled, when using the Append action, " +
- "the full file path will be added to the Trident Mappings."))
- .addComponent(desc("Mapping Entry: $<file>=<path>/<file>.<extension>"))
+ .addComponent(desc("Disabled - adds the full file path to the Trident Mappings."))
+ .addComponent(desc("Filename - Adds the filename (with extension)."))
+ .addComponent(desc("Filename (no extension) - Adds the filename (without extension)."))
+ .addVerticalGap(step)
+
+ .addLabeledComponent("Automatic replacing (when possible)", automaticReplacing)
+ .addComponent(desc("Disabled - Keeps the full file path."))
+ .addComponent(desc("Exact - Replaces the full path if an exact match is found."))
+ .addComponent(desc("Smart - Like exact but if no exact match found, " +
+ "it will try to make the path shorter."))
.addVerticalGap(step)
.addLabeledComponent("Recursive mapping", recursiveMapping)
@@ -103,12 +115,20 @@ class SettingsData {
this.enterToSelect.isSelected = enter
}
- fun getAutomaticMapping(): Boolean {
- return automaticMapping.isSelected
+ fun getAutomaticMapping(): AutomaticMapping {
+ return automaticMapping.selectedItem as AutomaticMapping
}
- fun setAutomaticMapping(automaticMapping: Boolean) {
- this.automaticMapping.isSelected = automaticMapping
+ fun setAutomaticMapping(automaticMapping: AutomaticMapping) {
+ this.automaticMapping.selectedItem = automaticMapping
+ }
+
+ fun getAutomaticReplacing(): AutomaticReplacing {
+ return automaticReplacing.selectedItem as AutomaticReplacing
+ }
+
+ fun setAutomaticReplacing(automaticReplacing: AutomaticReplacing) {
+ this.automaticReplacing.selectedItem = automaticReplacing
}
fun getRememberLine(): Boolean {
@@ -135,3 +155,21 @@ class SettingsData {
this.indexCycling.isSelected = indexCycling
}
}
+
+enum class AutomaticMapping {
+ Disabled,
+ Filename,
+ FilenameNoExtension,
+ ;
+
+ override fun toString(): String {
+ if (this == FilenameNoExtension) return "Filename (without extension)"
+ return super.toString()
+ }
+}
+
+enum class AutomaticReplacing {
+ Disabled,
+ Exact,
+ Smart,
+}