@@ -2,7 +2,6 @@ package com.phodal.shirecore.ui
2
2
3
3
import com.intellij.ide.IdeTooltip
4
4
import com.intellij.ide.IdeTooltipManager
5
- import com.intellij.ide.ui.laf.darcula.DarculaUIUtil
6
5
import com.intellij.openapi.Disposable
7
6
import com.intellij.openapi.actionSystem.*
8
7
import com.intellij.openapi.actionSystem.ex.AnActionListener
@@ -17,15 +16,12 @@ import com.intellij.openapi.editor.actions.IncrementalFindAction
17
16
import com.intellij.openapi.editor.event.DocumentEvent
18
17
import com.intellij.openapi.editor.event.DocumentListener
19
18
import com.intellij.openapi.editor.ex.EditorEx
20
- import com.intellij.openapi.editor.ex.FocusChangeListener
21
19
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
22
20
import com.intellij.openapi.fileTypes.FileTypes
23
21
import com.intellij.openapi.project.DumbAwareAction
24
22
import com.intellij.openapi.project.Project
25
23
import com.intellij.openapi.ui.ComponentValidator
26
- import com.intellij.openapi.ui.ErrorBorderCapable
27
24
import com.intellij.openapi.ui.popup.Balloon.Position
28
- import com.intellij.openapi.util.NlsContexts
29
25
import com.intellij.openapi.wm.IdeFocusManager
30
26
import com.intellij.openapi.wm.impl.InternalDecorator
31
27
import com.intellij.ui.EditorTextField
@@ -46,7 +42,6 @@ import javax.swing.Box
46
42
import javax.swing.JComponent
47
43
import javax.swing.JPanel
48
44
import javax.swing.KeyStroke
49
- import javax.swing.border.Border
50
45
import kotlin.math.max
51
46
import kotlin.math.min
52
47
@@ -61,7 +56,7 @@ interface ShireInputListener : EventListener {
61
56
fun onStop (component : ShireInputSection ) {}
62
57
}
63
58
64
- class ShireInput (
59
+ class ShireInputTextField (
65
60
project : Project ,
66
61
private val listeners : List <DocumentListener >,
67
62
val disposable : Disposable ? ,
@@ -84,8 +79,6 @@ class ShireInput(
84
79
object : AnAction () {
85
80
override fun actionPerformed (actionEvent : AnActionEvent ) {
86
81
val editor = editor ? : return
87
-
88
- // Insert a new line
89
82
CommandProcessor .getInstance().executeCommand(project, {
90
83
val eol = " \n "
91
84
val caretOffset = editor.caretModel.offset
@@ -155,7 +148,7 @@ class ShireInput(
155
148
fun recreateDocument () {
156
149
val id = UUID .randomUUID()
157
150
val language = CodeFenceLanguage .findLanguage(" Shire" )
158
- val file = LightVirtualFile (" AutoDevInput -$id " , language, " " )
151
+ val file = LightVirtualFile (" ShireInput -$id " , language, " " )
159
152
160
153
val document = file.findDocument() ? : throw IllegalStateException (" Can't create in-memory document" )
161
154
@@ -172,7 +165,7 @@ class ShireInput(
172
165
}
173
166
174
167
class ShireInputSection (private val project : Project , val disposable : Disposable ? ) : BorderLayoutPanel() {
175
- private val input: ShireInput
168
+ private val input: ShireInputTextField
176
169
private val documentListener: DocumentListener
177
170
private val sendButtonPresentation: Presentation
178
171
private val stopButtonPresentation: Presentation
@@ -224,7 +217,7 @@ class ShireInputSection(private val project: Project, val disposable: Disposable
224
217
Dimension (20 , 20 )
225
218
)
226
219
227
- input = ShireInput (project, listOf (), disposable, this )
220
+ input = ShireInputTextField (project, listOf (), disposable, this )
228
221
229
222
documentListener = object : DocumentListener {
230
223
override fun documentChanged (event : DocumentEvent ) {
@@ -272,11 +265,11 @@ class ShireInputSection(private val project: Project, val disposable: Disposable
272
265
stopButton.isEnabled = true
273
266
}
274
267
275
- fun showTooltip (text : @NlsContexts. Tooltip String ) {
268
+ fun showTooltip (text : String ) {
276
269
showTooltip(input, Position .above, text)
277
270
}
278
271
279
- fun showTooltip (component : JComponent , position : Position , text : @NlsContexts. Tooltip String ) {
272
+ fun showTooltip (component : JComponent , position : Position , text : String ) {
280
273
val point = Point (component.x, component.y)
281
274
val tipComponent = IdeTooltipManager .initPane(
282
275
text, HintHint (component, point).setAwtTooltip(true ).setPreferredPosition(position), null
@@ -292,7 +285,7 @@ class ShireInputSection(private val project: Project, val disposable: Disposable
292
285
293
286
fun initEditor () {
294
287
val editorEx = this .input.editor as ? EditorEx ? : return
295
- setBorder(AutoDevCoolBorder (editorEx, this ))
288
+ setBorder(ShireCoolBorder (editorEx, this ))
296
289
UIUtil .setOpaqueRecursively(this , false )
297
290
this .revalidate()
298
291
}
@@ -338,29 +331,3 @@ class ShireInputSection(private val project: Project, val disposable: Disposable
338
331
val focusableComponent: JComponent get() = input
339
332
}
340
333
341
- class AutoDevCoolBorder (private val editor : EditorEx , parent : JComponent ) : Border, ErrorBorderCapable {
342
- init {
343
- editor.addFocusListener(object : FocusChangeListener {
344
- override fun focusGained (editor2 : Editor ) {
345
- parent.repaint()
346
- }
347
-
348
- override fun focusLost (editor2 : Editor ) {
349
- parent.repaint()
350
- }
351
- })
352
- }
353
-
354
- override fun paintBorder (c : Component , g : Graphics , x : Int , y : Int , width : Int , height : Int ) {
355
- val r = Rectangle (x, y, width, height)
356
- JBInsets .removeFrom(r, JBInsets .create(1 , 1 ))
357
-
358
- DarculaNewUIUtil .fillInsideComponentBorder(g, r, c.background)
359
- val enabled = c.isEnabled
360
- val hasFocus = UIUtil .isFocusAncestor(c)
361
- DarculaNewUIUtil .paintComponentBorder(g, r, DarculaUIUtil .getOutline(c as JComponent ), hasFocus, enabled)
362
- }
363
-
364
- override fun getBorderInsets (c : Component ): Insets = JBInsets .create(Insets (3 , 8 , 3 , 3 )).asUIResource()
365
- override fun isBorderOpaque (): Boolean = true
366
- }
0 commit comments