Skip to content

Commit

Permalink
feat(runner): add build for ui samples
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 28, 2022
1 parent e20d032 commit d90249a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.intellij.openapi.project.Project

class FkCommandConfiguration(project: Project, name: String, fkConfigurationFactory: FkConfigurationFactory) :
LocatableConfigurationBase<RunProfileState>(project, fkConfigurationFactory, name) {
var command: String = "fkl run"

override fun getState(executor: Executor, environment: ExecutionEnvironment): RunProfileState {
return FkRunState(environment, this)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.feakin.intellij.runconfig.ui

import com.intellij.codeInsight.completion.CompletionResultSet
import com.intellij.codeInsight.completion.InsertionContext
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.openapi.editor.EditorModificationUtil
import com.intellij.util.TextFieldCompletionProvider

class FkCommandCompletionProvider : TextFieldCompletionProvider() {
override fun addCompletionVariants(text: String, offset: Int, prefix: String, result: CompletionResultSet) {
val element = LookupElementBuilder.create("test").withInsertHandler { ctx, _ ->
ctx.addSuffix(" ")
}
result.addElement(element)
}

}

fun InsertionContext.addSuffix(suffix: String) {
document.insertString(selectionEndOffset, suffix)
EditorModificationUtil.moveCaretRelatively(editor, suffix.length)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ package com.feakin.intellij.runconfig.ui
import com.feakin.intellij.runconfig.FkCommandConfiguration
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 FkCommandConfigurationEditor(project: Project) : SettingsEditor<FkCommandConfiguration>() {
override fun resetEditorFrom(s: FkCommandConfiguration) {
TODO("Not yet implemented")
}

override fun applyEditorTo(s: FkCommandConfiguration) {
TODO("Not yet implemented")
private val command: FkCommandLineEditor = FkCommandLineEditor(project, FkCommandCompletionProvider());

override fun resetEditorFrom(configuration: FkCommandConfiguration) {
command.text = configuration.command
}

override fun createEditor(): JComponent {
TODO("Not yet implemented")
override fun applyEditorTo(configuration: FkCommandConfiguration) {
configuration.command = command.text
}

override fun createEditor(): JComponent = panel {
row("Command:") {
cell(command).horizontalAlign(HorizontalAlign.FILL)
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.feakin.intellij.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 FkCommandLineEditor(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
)
}

0 comments on commit d90249a

Please sign in to comment.