generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coder): init for setting config
- Loading branch information
Showing
10 changed files
with
102 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderConfigurable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cc.unitmesh.devti.settings.coder | ||
|
||
import cc.unitmesh.devti.AutoDevBundle | ||
import cc.unitmesh.devti.fullWidthCell | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.options.BoundConfigurable | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.ui.DialogPanel | ||
import com.intellij.ui.dsl.builder.* | ||
import javax.swing.JCheckBox | ||
|
||
class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBundle.message("settings.autodev.coder")) { | ||
private val recordingInLocalField = JCheckBox() | ||
private val disableAdvanceContextField = JCheckBox() | ||
|
||
val settings = project.service<AutoDevCoderSettingService>() | ||
val state = settings.state.copy() | ||
|
||
override fun createPanel(): DialogPanel = panel { | ||
row(AutoDevBundle.message("settings.external.team.prompts.recordingInLocal")) { | ||
fullWidthCell(recordingInLocalField) | ||
.bind( | ||
componentGet = { it.isSelected }, | ||
componentSet = { component, value -> component.isSelected = value }, | ||
prop = state::recordingInLocal.toMutableProperty() | ||
) | ||
} | ||
|
||
row(AutoDevBundle.message("settings.external.team.prompts.disableAdvanceContext")) { | ||
fullWidthCell(disableAdvanceContextField) | ||
.bind( | ||
componentGet = { it.isSelected }, | ||
componentSet = { component, value -> component.isSelected = value }, | ||
prop = state::disableAdvanceContext.toMutableProperty() | ||
) | ||
} | ||
|
||
onApply { | ||
settings.modify { | ||
it.recordingInLocal = state.recordingInLocal | ||
it.disableAdvanceContext | ||
} | ||
} | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderConfigurableProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cc.unitmesh.devti.settings.coder | ||
|
||
import com.intellij.openapi.options.Configurable | ||
import com.intellij.openapi.options.ConfigurableProvider | ||
import com.intellij.openapi.project.Project | ||
|
||
class AutoDevCoderConfigurableProvider (private val project: Project) : ConfigurableProvider() { | ||
override fun createConfigurable(): Configurable { | ||
return AutoDevCoderConfigurable(project) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderSettingService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cc.unitmesh.devti.settings.coder | ||
|
||
import com.intellij.openapi.components.* | ||
import com.intellij.openapi.project.Project | ||
|
||
val Project.coderSetting: AutoDevCoderSettingService | ||
get() = service<AutoDevCoderSettingService>() | ||
|
||
@State(name = "AutoDevCoderSettings", storages = [Storage("autodev-coder.xml")]) | ||
class AutoDevCoderSettingService( | ||
val project: Project, | ||
) : SimplePersistentStateComponent<AutoDevCoderSettingService.AutoDevCoderSettings>(AutoDevCoderSettings()) { | ||
fun modify(action: (AutoDevCoderSettings) -> Unit) { | ||
action(state) | ||
} | ||
|
||
abstract class AdProjectSettingsBase<T : AdProjectSettingsBase<T>> : BaseState() { | ||
abstract fun copy(): T | ||
} | ||
|
||
class AutoDevCoderSettings : AdProjectSettingsBase<AutoDevCoderSettings>() { | ||
var recordingInLocal by property(false) | ||
var disableAdvanceContext by property(false) | ||
|
||
override fun copy(): AutoDevCoderSettings { | ||
val state = AutoDevCoderSettings() | ||
state.copyFrom(this) | ||
return state | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters