generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runner): add build for ui samples
- Loading branch information
Showing
4 changed files
with
72 additions
and
7 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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/feakin/intellij/runconfig/ui/FkCommandCompletionProvider.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 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) | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/com/feakin/intellij/runconfig/ui/FkCommandLineEditor.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,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 | ||
) | ||
} |