Skip to content

Commit

Permalink
feat: init config for button
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 15, 2023
1 parent 462f6a8 commit 9005114
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
@@ -1,6 +1,6 @@
package cc.unitmesh.devti.runconfig

class DtAiConfigure(
class DevtiConfigure(
val githubToken: String,

Check warning on line 4 in src/main/kotlin/cc/unitmesh/devti/runconfig/DevtiConfigure.kt

View workflow job for this annotation

GitHub Actions / Build

Unused symbol

Property "githubToken" is never used
val openAiApiKey: String,

Check warning on line 5 in src/main/kotlin/cc/unitmesh/devti/runconfig/DevtiConfigure.kt

View workflow job for this annotation

GitHub Actions / Build

Unused symbol

Property "openAiApiKey" is never used
val openAiEngine: String,

Check warning on line 6 in src/main/kotlin/cc/unitmesh/devti/runconfig/DevtiConfigure.kt

View workflow job for this annotation

GitHub Actions / Build

Unused symbol

Property "openAiEngine" is never used
Expand All @@ -15,8 +15,8 @@ class DtAiConfigure(
val DEFAULT_OPEN_AI_MAX_TOKENS = 4096

Check notice on line 15 in src/main/kotlin/cc/unitmesh/devti/runconfig/DevtiConfigure.kt

View workflow job for this annotation

GitHub Actions / Build

Class member can have 'private' visibility

Property 'DEFAULT_OPEN_AI_MAX_TOKENS' could be private
val DEFAULT_OPEN_AI_TEMPERATURE = 0.5f

Check notice on line 16 in src/main/kotlin/cc/unitmesh/devti/runconfig/DevtiConfigure.kt

View workflow job for this annotation

GitHub Actions / Build

Class member can have 'private' visibility

Property 'DEFAULT_OPEN_AI_TEMPERATURE' could be private

fun getDefault(): DtAiConfigure {
return DtAiConfigure(
fun getDefault(): DevtiConfigure {
return DevtiConfigure(
DEFAULT_GITHUB_TOKEN,
DEFAULT_OPEN_AI_API_KEY,
DEFAULT_OPEN_AI_ENGINE,
Expand Down
Expand Up @@ -14,7 +14,7 @@ import org.jdom.Element
class DtCommandConfiguration(project: Project, name: String, factory: ConfigurationFactory) :
LocatableConfigurationBase<RunProfileState>(project, factory, name) {

private var runConfigure: DtAiConfigure = DtAiConfigure.getDefault()
private var runConfigure: DevtiConfigure = DevtiConfigure.getDefault()

override fun getState(executor: Executor, environment: ExecutionEnvironment): RunProfileState {
return DtRunState(environment, this, runConfigure)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cc/unitmesh/devti/runconfig/DtRunState.kt
Expand Up @@ -12,7 +12,7 @@ import com.intellij.openapi.diagnostic.logger
class DtRunState(
val environment: ExecutionEnvironment,
val configuration: DtCommandConfiguration,
val aiConfig: DtAiConfigure
val aiConfig: DevtiConfigure
) : RemoteState {
override fun execute(executor: Executor?, runner: ProgramRunner<*>): ExecutionResult? {
log.debug("execute")
Expand Down
@@ -1,14 +1,14 @@
package cc.unitmesh.devti.runconfig.command

import cc.unitmesh.devti.runconfig.DtAiConfigure
import cc.unitmesh.devti.runconfig.DevtiConfigure
import cc.unitmesh.devti.runconfig.DtCommandConfiguration
import cc.unitmesh.devti.runconfig.DtCommandConfigurationType
import com.intellij.execution.actions.ConfigurationContext
import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.openapi.util.Ref
import com.intellij.psi.PsiElement

class CreateStoryConfigurationProducer : BaseLazyRunConfigurationProducer<DtAiConfigure>() {
class CreateStoryConfigurationProducer : BaseLazyRunConfigurationProducer<DevtiConfigure>() {
val configurationName: String = "DevTi Create Story"
override fun getConfigurationFactory(): ConfigurationFactory {
return DtCommandConfigurationType.getInstance().factory
Expand Down
20 changes: 10 additions & 10 deletions src/main/kotlin/cc/unitmesh/devti/runconfig/ui/DtSettingsEditor.kt
@@ -1,38 +1,38 @@
package cc.unitmesh.devti.runconfig.ui

import cc.unitmesh.devti.runconfig.DtAiConfigure
import cc.unitmesh.devti.runconfig.DtCommandConfiguration
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
import javax.swing.JComponent
import com.intellij.ui.dsl.builder.*
import com.intellij.ui.dsl.builder.*

class DtSettingsEditor(project: Project) : SettingsEditor<DtCommandConfiguration>() {
val configure = DtAiConfigure.getDefault()

override fun resetEditorFrom(configuration: DtCommandConfiguration) {
// command.text = configuration

}

override fun applyEditorTo(configuration: DtCommandConfiguration) {
// configuration.command = command.text

}

@Suppress("UnstableApiUsage")
override fun createEditor(): JComponent = panel {
row("Github Token") {
row("Github Token:") {
textField()
.horizontalAlign(HorizontalAlign.FILL).resizableColumn()
}

row("OpenAI API Key") {
row("OpenAI API Key:") {
textField().horizontalAlign(HorizontalAlign.FILL).resizableColumn()
}

row("API Engine") {
row("API Engine:") {
comboBox(listOf("gpt-3.5-turbo"))
}

row("Max Token") {
intTextField(0..32768)
}
}
}

0 comments on commit 9005114

Please sign in to comment.