Skip to content

Commit 830165f

Browse files
BingZi-233claude
andcommitted
refactor(UI): 重构项目向导界面,提升用户体验
- 🎨 现代化界面设计:添加步骤指示器、emoji图标、优化视觉层次 - 🔧 增强输入验证:实时验证用户输入,提供友好的错误和警告提示 - 📋 改进模块选择:优化左右面板布局,统一高度,增强可读性 - 💬 完整中文本地化:所有界面文本翻译为中文,符合中文语法习惯 - 📏 修复布局问题:解决步骤2/3滚动显示问题,调整组件高度 - 🎯 优化交互体验:改进工具提示、说明文字显示、移除HTML兼容性问题 - ♻️ 代码重构:清理未使用导入,统一代码风格,提升维护性 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 24a61e7 commit 830165f

21 files changed

+488
-164
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(./gradlew:*)",
5+
"Bash(git add:*)"
6+
],
7+
"deny": []
8+
}
9+
}

CLAUDE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is an IntelliJ IDEA plugin for TabooLib development, providing project scaffolding and development tools for TabooLib-based Minecraft plugins. The plugin is built with Kotlin and targets IntelliJ IDEA 2024.3+ with Kotlin K2 compiler support.
8+
9+
## Build System
10+
11+
This project uses Gradle with the Kotlin DSL and requires Java 21:
12+
13+
- **Build**: `./gradlew build`
14+
- **Build plugin**: `./gradlew buildPlugin` (produces distributable plugin in `build/distributions`)
15+
- **Run IDE with plugin**: `./gradlew runIde`
16+
- **Test plugin**: `./gradlew verifyPlugin`
17+
- **Generate shadow JAR**: `./gradlew shadowJar`
18+
19+
The build system uses:
20+
- `org.jetbrains.intellij.platform` plugin for IntelliJ development
21+
- Shadow plugin for dependency bundling
22+
- Kotlin 2.1.0 with K2 compiler support
23+
- Target IntelliJ IDEA Community 2024.3.1
24+
25+
## Architecture
26+
27+
### Core Components
28+
29+
**Project Builder (`ProjectBuilder.kt`)**:
30+
- Main entry point for the new project wizard
31+
- Orchestrates the multi-step project creation process
32+
- Integrates with IntelliJ's new project wizard framework
33+
34+
**Wizard Steps** (`step/` package):
35+
- `BasicConfigurationStep`: Core project settings and module selection
36+
- `ConfigurationPropertiesStep`: TabooLib-specific configuration
37+
- `OptionalPropertiesStep`: Additional project options
38+
39+
**Language Support** (`inlay/` package):
40+
- TabooLib i18n language file folding and navigation
41+
- Color highlighting for Minecraft color codes
42+
- Line markers for language keys
43+
- Editor notifications and gutter providers
44+
- Settings management for folding behavior
45+
46+
**Code Intelligence**:
47+
- `completion/`: Kotlin completion contributors for TabooLib APIs
48+
- `inspection/`: Code inspections for TabooLib patterns
49+
- `suppressor/`: Unused code suppressors for TabooLib annotations
50+
51+
**Utilities**:
52+
- `Template.kt`: Handles project template downloading and extraction
53+
- `Assets.kt`: Plugin icons and resources
54+
- `Utils.kt`: Common utility functions
55+
56+
### Key Features
57+
58+
1. **Project Wizard**: Multi-step wizard for creating TabooLib projects with module selection
59+
2. **i18n Support**: Advanced language file handling with folding, navigation, and color support
60+
3. **Code Completion**: Intelligent completion for TabooLib APIs and patterns
61+
4. **Code Inspections**: Static analysis for TabooLib-specific code patterns
62+
5. **K2 Compatibility**: Full support for Kotlin K2 compiler mode
63+
64+
## Configuration
65+
66+
Key configuration files:
67+
- `gradle.properties`: Version (1.41-SNAPSHOT), build settings, JVM options
68+
- `libs.versions.toml`: Dependency versions (OkHttp 4.12.0, FreeMarker 2.3.32)
69+
- Plugin configuration in `plugin.xml` with since-build: 243 (IntelliJ 2024.3)
70+
71+
## Development Notes
72+
73+
- Uses Kotlin 2.1 with language level 2.1, API level 1.9
74+
- JVM target: Java 21
75+
- Parallel builds and caching enabled for performance
76+
- K2 mode support declared in plugin.xml
77+
- Memory settings: 2GB heap, 512MB metaspace for builds
78+
- Debug mode available via `-Ddebug` system property

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.41-SNAPSHOT
3+
version=1.42-SNAPSHOT
44
kotlin.code.style=official
55

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

src/main/kotlin/org/tabooproject/development/FunctionTemplate.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package org.tabooproject.development
22

33
import com.google.gson.JsonParser
44
import org.jetbrains.kotlin.idea.base.util.getString
5-
import org.jetbrains.kotlin.idea.gradleTooling.get
65
import org.tabooproject.development.step.ConfigurationPropertiesStep
76
import org.tabooproject.development.step.OptionalPropertiesStep
87
import java.io.IOException

src/main/kotlin/org/tabooproject/development/completion/ReflectMethodReflectCompletion.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import com.intellij.codeInsight.completion.*
55
import com.intellij.codeInsight.lookup.LookupElementBuilder
66
import com.intellij.lang.jvm.JvmModifier
77
import com.intellij.patterns.PlatformPatterns
8-
import com.intellij.psi.*
8+
import com.intellij.psi.PsiClass
9+
import com.intellij.psi.PsiField
10+
import com.intellij.psi.PsiMethod
11+
import com.intellij.psi.PsiPrimitiveType
912
import com.intellij.psi.search.searches.ClassInheritorsSearch
1013
import com.intellij.psi.util.PsiTreeUtil
1114
import com.intellij.psi.util.PsiTypesUtil

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

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,71 @@
11
package org.tabooproject.development.component
22

33
import com.intellij.openapi.Disposable
4-
import com.intellij.openapi.util.Disposer
4+
import com.intellij.openapi.ui.InputValidator
5+
import com.intellij.openapi.ui.Messages
56
import com.intellij.ui.AddDeleteListPanel
7+
import com.intellij.ui.JBColor
8+
import com.intellij.util.ui.JBUI
9+
import javax.swing.border.CompoundBorder
610

711
/**
8-
* 字符串添加删除列表面板
12+
* 现代化的字符串添加删除列表面板
913
*
1014
* @since 1.31
1115
*/
1216
class AddDeleteStringListPanel(
13-
title: String,
17+
private val panelTitle: String,
1418
private val initialData: MutableList<String>,
15-
defaultHeight: Int = 175,
16-
) : AddDeleteListPanel<String>(title, initialData.toList()), Disposable {
19+
defaultHeight: Int = 120, // 进一步减少默认高度
20+
) : AddDeleteListPanel<String>(panelTitle, initialData.toList()), Disposable {
1721

1822
init {
1923
preferredSize = preferredSize.apply {
20-
width += 300
21-
height += defaultHeight
24+
width = 380 // 减少宽度以适应滚动面板
25+
height = defaultHeight
2226
}
2327

28+
// 设置现代化的边框样式
29+
border = CompoundBorder(
30+
JBUI.Borders.customLine(JBColor.border()),
31+
JBUI.Borders.empty(8)
32+
)
33+
34+
// 设置背景色
35+
background = JBColor.namedColor("Panel.background", JBColor.WHITE)
36+
2437
// 初始化时加载已有数据
2538
refreshData()
2639
}
2740

2841
override fun findItemToAdd(): String? {
29-
// 简单实现,可以扩展为输入对话框
30-
return null
42+
val itemType = when (panelTitle) {
43+
"Authors" -> "作者名称"
44+
"Dependencies" -> "插件名称"
45+
"Soft Dependencies" -> "插件名称"
46+
else -> "项目"
47+
}
48+
49+
val inputValue = Messages.showInputDialog(
50+
this,
51+
"输入${itemType}:",
52+
"添加${panelTitle}",
53+
Messages.getQuestionIcon(),
54+
"",
55+
object : InputValidator {
56+
override fun checkInput(inputString: String?): Boolean {
57+
return !inputString.isNullOrBlank() &&
58+
inputString.trim().length >= 2 &&
59+
!myListModel.contains(inputString.trim())
60+
}
61+
62+
override fun canClose(inputString: String?): Boolean {
63+
return checkInput(inputString)
64+
}
65+
}
66+
)
67+
68+
return inputValue?.trim()
3169
}
3270

3371
/**

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

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
package org.tabooproject.development.component
22

33
import com.intellij.openapi.Disposable
4-
import com.intellij.openapi.observable.util.whenSizeChanged
54
import com.intellij.openapi.util.Disposer
6-
import com.intellij.ui.components.JBList
5+
import com.intellij.ui.JBColor
76
import com.intellij.ui.components.JBPanel
87
import com.intellij.ui.components.JBScrollPane
98
import com.intellij.ui.dsl.builder.panel
109
import com.intellij.util.ui.JBUI
1110
import org.tabooproject.development.step.Module
1211
import java.awt.BorderLayout
1312
import java.awt.Dimension
14-
import javax.swing.DefaultListModel
15-
import javax.swing.JPanel
1613

1714
/**
1815
* 模块选择面板,提供复选框树形结构和已选模块列表显示
@@ -39,61 +36,92 @@ class CheckModulePanel(
3936
Disposer.register(this, displayModuleList as Disposable)
4037

4138
layout = BorderLayout()
42-
preferredSize = Dimension(800, 480) // 增加高度,充分利用空间
39+
preferredSize = Dimension(860, 600)
4340

44-
// 创建美观的边框和标题
41+
// 创建更现代化的左侧面板
4542
val leftPanel = panel {
46-
group("Available Modules", indent = false) {
43+
group("🔍 可用模块", indent = false) {
44+
row {
45+
text("<small>" +
46+
"浏览并选择您项目的 TabooLib 模块" +
47+
"</small>")
48+
.apply {
49+
component.border = JBUI.Borders.empty(0, 0, 8, 0)
50+
}
51+
}
4752
row {
4853
scrollCell(checkModuleList)
4954
.apply {
50-
component.preferredSize = Dimension(380, 410) // 增加高度
55+
component.preferredSize = Dimension(420, 340)
56+
component.border = JBUI.Borders.compound(
57+
JBUI.Borders.customLine(JBColor.border()),
58+
JBUI.Borders.empty(5)
59+
)
5160
}
5261
}
5362
}
5463
}.apply {
55-
border = JBUI.Borders.empty(10, 10, 5, 5)
64+
border = JBUI.Borders.empty(15, 15, 10, 10) // 统一边距
65+
background = JBColor.namedColor("Panel.background", JBColor.WHITE)
5666
}
5767

68+
// 创建更优雅的右侧面板
5869
val rightPanel = panel {
59-
group("Selected Modules", indent = false) {
70+
group("✅ 已选模块", indent = false) {
71+
row {
72+
text("<small>" +
73+
"您选择的模块 - 点击可移除" +
74+
"</small>")
75+
.apply {
76+
component.border = JBUI.Borders.empty(0, 0, 8, 0)
77+
}
78+
}
6079
row {
6180
scrollCell(displayModuleList)
6281
.apply {
63-
component.preferredSize = Dimension(350, 410) // 增加高度与左侧对齐
82+
component.preferredSize = Dimension(380, 340)
83+
component.border = JBUI.Borders.compound(
84+
JBUI.Borders.customLine(JBColor.border()),
85+
JBUI.Borders.empty(3)
86+
)
87+
// 设置特殊的背景色表示已选状态
88+
component.background = JBColor.namedColor(
89+
"TextField.selectionBackground",
90+
JBColor(0xf5f5f5, 0x3c3f41)
91+
).brighter()
6492
}
6593
}
6694
}
6795
}.apply {
68-
border = JBUI.Borders.empty(10, 5, 5, 10)
96+
border = JBUI.Borders.empty(15, 15, 10, 10) // 统一边距,与左侧保持一致
97+
background = JBColor.namedColor("Panel.background", JBColor.WHITE)
6998
}
7099

71100
add(leftPanel, BorderLayout.CENTER) // 左侧占据主要空间
72101
add(rightPanel, BorderLayout.EAST) // 右侧固定宽度
73102

74-
// 设置模块选择回调,连接到外部回调
103+
// 设置模块选择回调
75104
checkModuleList.onModuleSelectionChanged = { modules ->
76105
displayModuleList.setModules(modules)
77106
onModuleSelectionChanged?.invoke(modules)
78107
}
79108

80-
// 设置右侧列表的点击取消选中回调
109+
// 设置右侧列表的点击移除回调
81110
displayModuleList.onModuleRemoved = { module ->
82111
println("DisplayModuleList: 尝试移除模块 ${module.name} (${module.id})")
83-
// 在左侧树中取消选中该模块,不重新设置整个列表
84112
checkModuleList.unselectModule(module.id)
85113
}
86114

87-
// 优化滚动条设置
115+
// 优化滚动条样式
88116
checkModuleScrollPane.apply {
89117
verticalScrollBarPolicy = JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
90-
horizontalScrollBarPolicy = JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
118+
horizontalScrollBarPolicy = JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER // 禁用水平滚动
91119
border = JBUI.Borders.empty()
92120
}
93121

94122
displayModuleScrollPane.apply {
95123
verticalScrollBarPolicy = JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
96-
horizontalScrollBarPolicy = JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
124+
horizontalScrollBarPolicy = JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER // 禁用水平滚动
97125
border = JBUI.Borders.empty()
98126
}
99127
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
package org.tabooproject.development.component
22

33
import com.intellij.openapi.Disposable
4-
import com.intellij.openapi.util.Disposer
4+
import com.intellij.ui.JBColor
55
import com.intellij.ui.components.JBList
66
import com.intellij.ui.components.JBScrollPane
7-
import com.intellij.ui.*
87
import com.intellij.util.ui.JBUI
98
import org.tabooproject.development.step.Module
10-
import javax.swing.DefaultListModel
11-
import javax.swing.JPanel
12-
import javax.swing.ListCellRenderer
13-
import javax.swing.JLabel
14-
import java.awt.*
9+
import java.awt.BorderLayout
10+
import java.awt.Cursor
11+
import java.awt.Font
1512
import java.awt.event.MouseAdapter
1613
import java.awt.event.MouseEvent
17-
import javax.swing.SwingConstants
14+
import javax.swing.*
1815

1916
/**
2017
* 显示已选模块的列表组件

src/main/kotlin/org/tabooproject/development/inlay/EditorDocumentListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.tabooproject.development.inlay
22

33
import com.intellij.openapi.Disposable
4+
import com.intellij.openapi.application.ApplicationManager
45
import com.intellij.openapi.components.Service
56
import com.intellij.openapi.components.service
67
import com.intellij.openapi.editor.Document
@@ -11,7 +12,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager
1112
import com.intellij.openapi.project.Project
1213
import com.intellij.openapi.vfs.VirtualFile
1314
import com.intellij.psi.PsiManager
14-
import com.intellij.openapi.application.ApplicationManager
1515

1616
/**
1717
* 编辑器文档监听器

src/main/kotlin/org/tabooproject/development/inlay/LangFileNavigator.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor
55
import com.intellij.openapi.project.Project
66
import com.intellij.openapi.vfs.VirtualFile
77
import com.intellij.psi.PsiManager
8-
import com.intellij.psi.search.PsiElementProcessor
98

109
/**
1110
* 语言文件导航器

0 commit comments

Comments
 (0)