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.
- Loading branch information
Showing
9 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
src/main/kotlin/cc/unitmesh/devti/command/DtSettingsEditor.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...c/unitmesh/devti/command/DtAiConfigure.kt → ...unitmesh/devti/runconfig/DtAiConfigure.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
3 changes: 2 additions & 1 deletion
3
...h/devti/command/DtCommandConfiguration.kt → ...devti/runconfig/DtCommandConfiguration.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
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/cc/unitmesh/devti/runconfig/DtCommandConfigurationType.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,34 @@ | ||
package cc.unitmesh.devti.runconfig | ||
|
||
import cc.unitmesh.devti.DevtiIcons | ||
import com.intellij.execution.configurations.ConfigurationFactory | ||
import com.intellij.execution.configurations.ConfigurationTypeBase | ||
import com.intellij.execution.configurations.ConfigurationTypeUtil | ||
import com.intellij.execution.configurations.RunConfiguration | ||
import com.intellij.openapi.project.Project | ||
|
||
class DtCommandConfigurationType : | ||
ConfigurationTypeBase("DtCommandConfigurationType", "DevTi", "DevTi generator", DevtiIcons.STORY) { | ||
val factory: ConfigurationFactory get() = configurationFactories.single() | ||
|
||
init { | ||
addFactory(DtConfigurationFactory(this)) | ||
} | ||
|
||
companion object { | ||
fun getInstance(): DtCommandConfigurationType = | ||
ConfigurationTypeUtil.findConfigurationType(DtCommandConfigurationType::class.java) | ||
} | ||
} | ||
|
||
class DtConfigurationFactory(type: DtCommandConfigurationType) : ConfigurationFactory(type) { | ||
override fun getId(): String = ID | ||
|
||
override fun createTemplateConfiguration(project: Project): RunConfiguration { | ||
return DtCommandConfiguration(project, "DevTi", this) | ||
} | ||
|
||
companion object { | ||
const val ID: String = "DevTi Gen" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...n/cc/unitmesh/devti/command/DtRunState.kt → ...cc/unitmesh/devti/runconfig/DtRunState.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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/cc/unitmesh/devti/runconfig/ui/DtCommandCompletionProvider.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,22 @@ | ||
package cc.unitmesh.devti.runconfig.ui | ||
|
||
import com.intellij.codeInsight.completion.CompletionResultSet | ||
import com.intellij.codeInsight.completion.InsertionContext | ||
import com.intellij.util.TextFieldCompletionProvider | ||
import com.intellij.codeInsight.lookup.LookupElementBuilder | ||
import com.intellij.openapi.editor.EditorModificationUtil | ||
|
||
class DtCommandCompletionProvider : TextFieldCompletionProvider() { | ||
override fun addCompletionVariants(text: String, offset: Int, prefix: String, result: CompletionResultSet) { | ||
val element = LookupElementBuilder.create("devti auto").withInsertHandler { ctx, _ -> | ||
ctx.addSuffix(" ") | ||
} | ||
|
||
result.addElement(element) | ||
} | ||
} | ||
|
||
fun InsertionContext.addSuffix(suffix: String) { | ||
document.insertString(selectionEndOffset, suffix) | ||
EditorModificationUtil.moveCaretRelatively(editor, suffix.length) | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/cc/unitmesh/devti/runconfig/ui/DtCommandLineEditor.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,32 @@ | ||
package cc.unitmesh.devti.runconfig.ui | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.ui.TextAccessor | ||
import com.intellij.util.TextFieldCompletionProvider | ||
import com.intellij.util.textCompletion.TextFieldWithCompletion | ||
import java.awt.BorderLayout | ||
import javax.swing.JPanel | ||
class DtCommandLineEditor(private val project: Project, private val completionProvider: TextFieldCompletionProvider) : | ||
JPanel(BorderLayout()), TextAccessor { | ||
private val textField = createTextField("") | ||
|
||
init { | ||
add(textField, BorderLayout.CENTER) | ||
} | ||
|
||
override fun setText(text: String?) { | ||
textField.setText(text) | ||
} | ||
|
||
override fun getText(): String = textField.text | ||
|
||
private fun createTextField(value: String): TextFieldWithCompletion = | ||
TextFieldWithCompletion( | ||
project, | ||
completionProvider, | ||
value, | ||
true, | ||
false, | ||
false | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/cc/unitmesh/devti/runconfig/ui/DtSettingsEditor.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,29 @@ | ||
package cc.unitmesh.devti.runconfig.ui | ||
|
||
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 | ||
|
||
class DtSettingsEditor(project: Project) : SettingsEditor<DtCommandConfiguration>() { | ||
private val command: DtCommandLineEditor = DtCommandLineEditor(project, DtCommandCompletionProvider()); | ||
|
||
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("DevTi:") { | ||
cell(command) | ||
.horizontalAlign(HorizontalAlign.FILL) | ||
.resizableColumn() | ||
} | ||
} | ||
} |
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