Skip to content

Commit 9039e9d

Browse files
committed
refactor(gui): improve text input component and remove unnecessary imports #352
- Replace EditorTextField with MarkdownLanguageField in IssueInputPanel - Remove unused imports in AutoDevPlannerToolWindow - Adjust toolbarPanel placement in AutoDevPlannerToolWindow - Modify MarkdownLanguageField to hide scrollbars and line numbers - Update IssueInputPanel to use MarkdownLanguageField with custom border
1 parent e70f265 commit 9039e9d

File tree

3 files changed

+13
-39
lines changed

3 files changed

+13
-39
lines changed

core/src/main/kotlin/cc/unitmesh/devti/gui/planner/AutoDevPlannerToolWindow.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel
1818
import com.intellij.openapi.vcs.changes.Change
1919
import com.intellij.openapi.wm.ToolWindowManager
2020
import com.intellij.ui.dsl.builder.panel
21-
import com.intellij.util.ui.JBUI
22-
import com.intellij.util.ui.UIUtil
2321
import java.awt.*
2422
import javax.swing.*
2523

@@ -32,6 +30,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
3230

3331
private var markdownEditor: MarkdownLanguageField? = null
3432
private val contentPanel = JPanel(BorderLayout())
33+
3534
private var isEditorMode = false
3635
private var isIssueInputMode = false
3736
private var currentCallback: ((String) -> Unit)? = null
@@ -50,7 +49,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
5049
val toolbarPanel = JPanel(FlowLayout(FlowLayout.RIGHT))
5150
toolbarPanel.add(toolbar.component)
5251

53-
contentPanel.add(toolbarPanel, BorderLayout.NORTH)
52+
add(toolbarPanel, BorderLayout.NORTH)
5453

5554
if (content.isBlank()) {
5655
isIssueInputMode = true
@@ -99,12 +98,6 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
9998
.fullWidth()
10099
.resizableColumn()
101100
}
102-
}.apply {
103-
border = JBUI.Borders.compound(
104-
JBUI.Borders.customLine(UIUtil.getBoundsColor(), 0, 0, 1, 0),
105-
JBUI.Borders.empty(8)
106-
)
107-
background = JBUI.CurrentTheme.ToolWindow.background()
108101
}
109102
}
110103

core/src/main/kotlin/cc/unitmesh/devti/gui/planner/MarkdownLanguageField.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class MarkdownLanguageField(
3030
override fun createEditor(): EditorEx {
3131
return super.createEditor().apply {
3232
setShowPlaceholderWhenFocused(true)
33-
setHorizontalScrollbarVisible(true)
34-
setVerticalScrollbarVisible(true)
33+
setHorizontalScrollbarVisible(false)
34+
setVerticalScrollbarVisible(false)
3535
setPlaceholder(placeholder)
3636

3737
val scheme = EditorColorsUtil.getColorSchemeForBackground(this.colorsScheme.defaultBackground)
3838
this.colorsScheme = this.createBoundColorSchemeDelegate(scheme)
3939

40-
settings.isLineNumbersShown = true
40+
settings.isLineNumbersShown = false
4141
settings.isLineMarkerAreaShown = false
4242
settings.isFoldingOutlineShown = false
4343
settings.isUseSoftWraps = true

core/src/main/kotlin/cc/unitmesh/devti/shadow/IssueInputPanel.kt

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package cc.unitmesh.devti.shadow
33
import cc.unitmesh.devti.AutoDevNotifications
44
import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
55
import cc.unitmesh.devti.gui.chat.message.ChatActionType
6+
import cc.unitmesh.devti.gui.planner.MarkdownLanguageField
7+
import cc.unitmesh.devti.inline.AutoDevLineBorder
68
import cc.unitmesh.devti.sketch.AutoSketchMode
7-
import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider
8-
import com.intellij.openapi.fileTypes.FileTypes
99
import com.intellij.openapi.project.Project
10-
import com.intellij.ui.*
11-
import com.intellij.util.containers.ContainerUtil
10+
import com.intellij.ui.JBColor
11+
import com.intellij.util.ui.JBUI.Borders.emptyLeft
1212
import java.awt.BorderLayout
1313
import java.awt.FlowLayout
1414
import javax.swing.BorderFactory
@@ -22,11 +22,10 @@ class IssueInputPanel(
2222
private val onSubmit: (String) -> Unit,
2323
private val onCancel: () -> Unit
2424
) : JPanel(BorderLayout()) {
25-
private val textArea: EditorTextField = createEditor(project).apply {
26-
setPlaceholder(placeholder)
27-
setShowPlaceholderWhenFocused(true)
28-
setBorder(BorderFactory.createEmptyBorder())
29-
}
25+
private val textArea: MarkdownLanguageField = MarkdownLanguageField(project, "", placeholder, "issue.md")
26+
.apply {
27+
border = AutoDevLineBorder(JBColor.namedColor("Focus.borderColor", JBColor.BLUE), 1, true, 4)
28+
}
3029

3130
init {
3231
val buttonsPanel = createActionButtons()
@@ -89,21 +88,3 @@ class IssueInputPanel(
8988
textArea.requestFocus()
9089
}
9190
}
92-
93-
private fun createEditor(project: Project): EditorTextField {
94-
val features: MutableSet<EditorCustomization?> = HashSet<EditorCustomization?>()
95-
96-
features.add(SoftWrapsEditorCustomization.ENABLED)
97-
features.add(AdditionalPageAtBottomEditorCustomization.DISABLED)
98-
ContainerUtil.addIfNotNull<EditorCustomization?>(
99-
features,
100-
SpellCheckingEditorCustomizationProvider.getInstance().enabledCustomization
101-
)
102-
103-
val editorField =
104-
EditorTextFieldProvider.getInstance().getEditorField(FileTypes.PLAIN_TEXT.language, project, features)
105-
106-
editorField.setFontInheritedFromLAF(false)
107-
return editorField
108-
}
109-

0 commit comments

Comments
 (0)