Skip to content

Commit c8516d2

Browse files
BingZi-233claude
andcommitted
refactor(UI): 优化向导界面布局与滚动体验
- 修复步骤二面板的垂直滚动问题,移除固定高度限制 - 简化模块选择区域的滚动设计,消除双重滚动条 - 调整可用模块与已选模块布局比例为75%-25% - 实现两个面板的严格顶部对齐 - 将版本号提升至1.43-SNAPSHOT - 添加Claude Code相关文件到gitignore 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 830165f commit c8516d2

File tree

6 files changed

+66
-135
lines changed

6 files changed

+66
-135
lines changed

.claude/settings.local.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ build
44
.intellijPlatform
55

66
### Mac OS ###
7-
.DS_Store
7+
.DS_Store
8+
9+
### Claude Code ###
10+
.claude
11+
CLAUDE.md

CLAUDE.md

Lines changed: 0 additions & 78 deletions
This file was deleted.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
kotlin.stdlib.default.dependency=false
22
pluginSinceBuild=243
3-
version=1.42-SNAPSHOT
3+
version=1.43-SNAPSHOT
44
kotlin.code.style=official
55

66
# 启用 Kotlin 增量编译以提高构建性能

src/main/kotlin/org/tabooproject/development/component/CheckModulePanel.kt

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import com.intellij.openapi.Disposable
44
import com.intellij.openapi.util.Disposer
55
import com.intellij.ui.JBColor
66
import com.intellij.ui.components.JBPanel
7-
import com.intellij.ui.components.JBScrollPane
7+
import com.intellij.ui.dsl.builder.AlignX
8+
import com.intellij.ui.dsl.builder.AlignY
89
import com.intellij.ui.dsl.builder.panel
910
import com.intellij.util.ui.JBUI
1011
import org.tabooproject.development.step.Module
11-
import java.awt.BorderLayout
12+
import java.awt.GridBagConstraints
13+
import java.awt.GridBagLayout
1214
import java.awt.Dimension
1315

1416
/**
1517
* 模块选择面板,提供复选框树形结构和已选模块列表显示
16-
*
18+
*
1719
* @since 1.31
1820
*/
1921
class CheckModulePanel(
@@ -22,8 +24,7 @@ class CheckModulePanel(
2224

2325
private val checkModuleList = CheckModuleList()
2426

25-
private val checkModuleScrollPane = JBScrollPane(checkModuleList)
26-
private val displayModuleScrollPane = JBScrollPane(displayModuleList)
27+
// CheckModuleList本身就是JScrollPane,DisplayModuleList内部有JBScrollPane
2728

2829
/**
2930
* 模块选择变更回调
@@ -34,25 +35,29 @@ class CheckModulePanel(
3435
// 注册子组件到自身的 disposable
3536
Disposer.register(this, checkModuleList as Disposable)
3637
Disposer.register(this, displayModuleList as Disposable)
38+
39+
layout = GridBagLayout()
3740

38-
layout = BorderLayout()
39-
preferredSize = Dimension(860, 600)
40-
41-
// 创建更现代化的左侧面板
41+
// 创建左侧面板(75%宽度)
4242
val leftPanel = panel {
4343
group("🔍 可用模块", indent = false) {
4444
row {
45-
text("<small>" +
46-
"浏览并选择您项目的 TabooLib 模块" +
47-
"</small>")
45+
text(
46+
"<small>" +
47+
"浏览并选择您项目的 TabooLib 模块" +
48+
"</small>"
49+
)
4850
.apply {
4951
component.border = JBUI.Borders.empty(0, 0, 8, 0)
5052
}
5153
}
5254
row {
53-
scrollCell(checkModuleList)
55+
cell(checkModuleList)
56+
.align(AlignX.FILL)
5457
.apply {
55-
component.preferredSize = Dimension(420, 340)
58+
// CheckModuleList本身就是JScrollPane,无需再包装
59+
component.preferredSize = Dimension(480, 350) // 调整为75%宽度
60+
component.minimumSize = Dimension(480, 100)
5661
component.border = JBUI.Borders.compound(
5762
JBUI.Borders.customLine(JBColor.border()),
5863
JBUI.Borders.empty(5)
@@ -61,25 +66,30 @@ class CheckModulePanel(
6166
}
6267
}
6368
}.apply {
64-
border = JBUI.Borders.empty(15, 15, 10, 10) // 统一边距
69+
border = JBUI.Borders.empty(15, 15, 10, 5) // 右边距减少
6570
background = JBColor.namedColor("Panel.background", JBColor.WHITE)
6671
}
67-
68-
// 创建更优雅的右侧面板
72+
73+
// 创建右侧面板(25%宽度)
6974
val rightPanel = panel {
7075
group("✅ 已选模块", indent = false) {
7176
row {
72-
text("<small>" +
73-
"您选择的模块 - 点击可移除" +
74-
"</small>")
77+
text(
78+
"<small>" +
79+
"您选择的模块 - 点击可移除" +
80+
"</small>"
81+
)
7582
.apply {
7683
component.border = JBUI.Borders.empty(0, 0, 8, 0)
7784
}
7885
}
7986
row {
80-
scrollCell(displayModuleList)
87+
cell(displayModuleList)
88+
.align(AlignX.FILL)
8189
.apply {
82-
component.preferredSize = Dimension(380, 340)
90+
// DisplayModuleList内部已有滚动面板,无需再包装
91+
component.preferredSize = Dimension(240, 350) // 调整为25%宽度
92+
component.minimumSize = Dimension(240, 150)
8393
component.border = JBUI.Borders.compound(
8494
JBUI.Borders.customLine(JBColor.border()),
8595
JBUI.Borders.empty(3)
@@ -93,48 +103,53 @@ class CheckModulePanel(
93103
}
94104
}
95105
}.apply {
96-
border = JBUI.Borders.empty(15, 15, 10, 10) // 统一边距,与左侧保持一致
106+
border = JBUI.Borders.empty(15, 5, 10, 15) // 左边距减少,右边距保持
97107
background = JBColor.namedColor("Panel.background", JBColor.WHITE)
98108
}
109+
110+
// 使用GridBagLayout进行精确布局
111+
val leftConstraints = GridBagConstraints().apply {
112+
gridx = 0
113+
gridy = 0
114+
weightx = 0.75 // 75%宽度
115+
weighty = 1.0
116+
fill = GridBagConstraints.BOTH
117+
anchor = GridBagConstraints.NORTHWEST // 顶部对齐
118+
}
99119

100-
add(leftPanel, BorderLayout.CENTER) // 左侧占据主要空间
101-
add(rightPanel, BorderLayout.EAST) // 右侧固定宽度
120+
val rightConstraints = GridBagConstraints().apply {
121+
gridx = 1
122+
gridy = 0
123+
weightx = 0.25 // 25%宽度
124+
weighty = 1.0
125+
fill = GridBagConstraints.BOTH
126+
anchor = GridBagConstraints.NORTHWEST // 顶部对齐
127+
}
102128

129+
add(leftPanel, leftConstraints)
130+
add(rightPanel, rightConstraints)
131+
103132
// 设置模块选择回调
104133
checkModuleList.onModuleSelectionChanged = { modules ->
105134
displayModuleList.setModules(modules)
106135
onModuleSelectionChanged?.invoke(modules)
107136
}
108-
137+
109138
// 设置右侧列表的点击移除回调
110139
displayModuleList.onModuleRemoved = { module ->
111140
println("DisplayModuleList: 尝试移除模块 ${module.name} (${module.id})")
112141
checkModuleList.unselectModule(module.id)
113142
}
114-
115-
// 优化滚动条样式
116-
checkModuleScrollPane.apply {
117-
verticalScrollBarPolicy = JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
118-
horizontalScrollBarPolicy = JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER // 禁用水平滚动
119-
border = JBUI.Borders.empty()
120-
}
121-
122-
displayModuleScrollPane.apply {
123-
verticalScrollBarPolicy = JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
124-
horizontalScrollBarPolicy = JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER // 禁用水平滚动
125-
border = JBUI.Borders.empty()
126-
}
127143
}
128144

129145
/**
130146
* 设置模块数据
131-
*
147+
*
132148
* @param modules 模块映射,key为分类名称,value为该分类下的模块列表
133149
*/
134150
fun setModules(modules: Map<String, List<Module>>) {
135151
checkModuleList.setModules(modules)
136-
137-
checkModuleScrollPane.size = checkModuleScrollPane.preferredSize
152+
// 移除多余的滚动面板大小设置,让组件自然调整
138153
}
139154

140155
/**

src/main/kotlin/org/tabooproject/development/step/ConfigurationPropertiesStep.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class ConfigurationPropertiesStep(val context: WizardContext) : ModuleWizardStep
201201
"<small>" +
202202
"• 只选择您实际需要的模块以保持插件轻量化<br/>" +
203203
"• 您可以随时通过编辑 build.gradle.kts 添加更多模块<br/>" +
204-
"• 根据常用模式预选了热门模块" +
205204
"</small></div>")
206205
}
207206

@@ -217,9 +216,9 @@ class ConfigurationPropertiesStep(val context: WizardContext) : ModuleWizardStep
217216
}
218217
}
219218

220-
// 设置更合理的尺寸,确保可以滚动
221-
mainPanel.preferredSize = Dimension(900, 450)
222-
mainPanel.maximumSize = Dimension(Int.MAX_VALUE, 450)
219+
// 移除固定尺寸设置,允许内容自然扩展以支持滚动
220+
mainPanel.preferredSize = Dimension(900, mainPanel.preferredSize.height)
221+
mainPanel.maximumSize = Dimension(Int.MAX_VALUE, Int.MAX_VALUE)
223222

224223
// 包装在滚动面板中
225224
val scrollPane = JBScrollPane(mainPanel).apply {

0 commit comments

Comments
 (0)