^1742734537687
@
sname
GroovyAction
slabel
Code
sdescriptors
xworker.lang.MetaDescriptor3
sextends
xworker.groovy.GroovyAction
smany
true
seditCols
2
sinitialization
false
smodifier
public
sinheritDescription
false
Sdescription
#$@text#$@
<p>在创建SWT窗体时只执行一次的Groovy代码。</p>
<p>可以执行一些目前SWT事物还不能完成的事情，比如使用XWorker还未定义的SWT控件或手工创建和处理SWT控件等。</p>
<p>可以添加Widgets子节点。</p>
#$@text#$@
snotXmlAttribute
false
sjson_isArray
false
  @/@actions
  sname
  actions
  slabel
  actions
  sdescriptors
  xworker.lang.MetaDescriptor3/@actions
  sid
  actions
    @/@actions/@create
    sname
    create
    slabel
    create
    sisSynchronized
    false
    sthrowException
    false
    suseOtherAction
    false
    suseOuterJava
    true
    souterClassName
    xworker.swt.util.CodeCreator
    smethodName
    create
    sdisableGlobalContext
    false
    sdescriptors
    xworker.lang.actions.JavaAction
    sid
    create
    @/@actions/@ai_getPromptSystem
    sname
    ai_getPromptSystem
    stype
    string
    Svalue
#$@text#$@
# 智能助手提示词：Groovy4.0.2 SWT应用开发专家

## 定位
专精于使用Groovy脚本语言快速构建Eclipse SWT桌面应用的开发助手，只负责输出groovy代码。

## 核心能力
1. **代码生成**
   - 自动生成SWT组件初始化代码（Shell/Composite/Button等）
   - 提供事件监听模板（SelectionListener/MouseAdapter等）
   - 生成跨平台UI布局代码（RowLayout/GridLayout等）

2. **调试支持**
   - 识别SWT线程模型问题（UI线程与非UI线程交互）
   - 诊断资源泄漏（Image/Font/Color释放检测）
   - 解析SWTException错误堆栈

3. **性能优化**
   - 推荐SWT组件复用策略
   - 建议异步加载方案
   - 提供UI响应式编程模式

4. **跨平台支持**
   - 处理不同OS的UI渲染差异
   - 生成平台特性适配代码
   - 管理平台相关资源路径

5. **交互式指导**
   - 分步构建SWT应用框架
   - 实时代码问题诊断
   - 可视化模式建议（MVVM/MVP等）

## 知识储备
- **Groovy特性**
  - SwingBuilder式DSL扩展
  - 闭包事件处理
  - AST转换应用

- **SWT核心**
  ```groovy
  // 典型SWT应用框架
  def display = new Display()
  def shell = new Shell(display).with {
    setSize(400, 300)
    addListener(SWT.Close) { event -> display.dispose() }
    it
  }
  
  // 组件构建示例
  new Button(shell, SWT.PUSH).with {
    text = "Click"
    addSelectionListener(new SelectionAdapter() {
      void widgetSelected(SelectionEvent e) {
        println "Button clicked"
      }
    })
  }
  
  // 新增键盘事件处理示例
import org.eclipse.swt.events.KeyAdapter
import org.eclipse.swt.events.KeyEvent

def text = new Text(shell, SWT.BORDER)
text.addKeyListener(new KeyAdapter() {
    void keyPressed(KeyEvent e) {
        switch(Character.toUpperCase(e.character as char)) {
            case 'W': 
                // 处理上方向操作
                println("Up movement")
                break
            case 'A':
                // 处理左方向操作 
                println("Left movement")
                break
            case 'S':
                // 处理下方向操作
                println("Down movement") 
                break
            case 'D':
                // 处理右方向操作
                println("Right movement")
                break
        }
    }
})
  ```

- **跨平台特性**
  - Windows/Linux/macOS原生组件差异表
  - 高DPI适配方案
  - 系统主题同步机制

## 约束条件
1. 优先使用Groovy的简洁语法特性
2. 确保SWT资源管理的正确性（显式dispose或try-with-resources）
3. 遵循Eclipse SWT线程模型规范
4. 提供可直接运行的完整代码片段
5. 避免使用已弃用的API方法
6. 保持UI代码与业务逻辑分离
7. 强调可维护性和可扩展性设计
8. shell已经存在，不需要创建shell和打开shell，只要创建shell内的局部代码
9. 只用SWT基本类库，没有扩展
10. 需要的类要使用import导入
11. 全局变量使用@Field注解，import groovy.transform.Field;
12. 使用java的样式初始化数组
13. 要检查引入的类，不要遗漏，如org.eclipse.swt.SWT要导入
#$@text#$@
    sinterpretationType
    Self
    sattributeTemplate
    false
    schildsAttributeTemplate
    false
    svarScope
    Local
    sisSynchronized
    false
    sthrowException
    true
    suseOtherAction
    false
    screateLocalVarScope
    false
    ssaveReturn
    false
    sswitchResult
    false
    sdisableGlobalContext
    false
    sdebugLog
    false
    sdescriptors
    xworker.lang.actions.Actions/@ValueFactory
    sinheritDescription
    false
    sth_createIndex
    false
    sth_registMyChilds
    false
    sth_registDisabled
    false
    sth_noThingRegistViewer
    false
    sth_fileMonitor
    false
    sth_mark
    false
    sth_registQueryOnlySelf
    false
    snotXmlAttribute
    false
    sjson_isArray
    false
    sgroupDescriptor
    false
    sid
    ai_getPromptSystem
    @/@actions/@ai_getChatService
    sname
    ai_getChatService
    schatServiceType
    coding
    sinterpretationType
    Self
    sattributeTemplate
    false
    schildsAttributeTemplate
    false
    svarScope
    Local
    sisSynchronized
    false
    sthrowException
    true
    suseOtherAction
    false
    screateLocalVarScope
    false
    ssaveReturn
    false
    sswitchResult
    false
    sdisableGlobalContext
    false
    sdebugLog
    false
    sdescriptors
    xworker.ai.AIActions/@GetChatService
    sinheritDescription
    false
    sth_createIndex
    false
    sth_registMyChilds
    false
    sth_registDisabled
    false
    sth_noThingRegistViewer
    false
    sth_fileMonitor
    false
    sth_mark
    false
    sth_registQueryOnlySelf
    false
    snotXmlAttribute
    false
    sjson_isArray
    false
    sgroupDescriptor
    false
    sai_needGenerate
    false
    sai_promptContainsVars
    false
    sid
    ai_getChatService
