JPDA 架构研究21 - JDI的Debugger的UI部分

本文深入分析了Eclipse JDT Debugger UI插件的工作原理,详细介绍了插件如何通过不同的编辑器贡献来支持各类调试操作,如设置断点、执行代码片段等,并解释了这些操作背后的实现机制。

引入:

前面揭示了JDI的Debugger如何建立连接,发送和处理请求,这里我们专注于人机交互部分,Debugger的UI,它主要负责如何把人发出的操作转为请求,以及把请求操作反映在调试器的界面上。


分析:

这个插件主要都定义在org.eclipse.jdt.debug.ui_<Version>.jar中的plugin.xml中,它提供了各种人机交互的插件功能。打的比方,我们看编辑器功能:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<extension
         point="org.eclipse.ui.editorActions">
      <editorContribution
            targetID="org.eclipse.jdt.ui.CompilationUnitEditor"
            id="org.eclipse.jdt.debug.CompilationUnitEditor.BreakpointRulerActions">
         <action
               label="%AddBreakpoint.label"
               class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
               actionID="RulerDoubleClick"
               id="org.eclipse.jdt.debug.ui.actions.ManageBreakpointRulerAction">
         </action>
      </editorContribution>
      <editorContribution
            targetID="org.eclipse.jdt.ui.ClassFileEditor"
            id="org.eclipse.jdt.debug.ClassFileEditor.BreakpointRulerActions">
         <action
               label="%AddBreakpoint.label"
               class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
               actionID="RulerDoubleClick"
               id="org.eclipse.jdt.debug.ui.actions.ManageBreakpointRulerAction">
         </action>
      </editorContribution>
      <editorContribution
            targetID="org.eclipse.jdt.debug.ui.SnippetEditor"
            id="org.eclipse.jdt.debug.ui.JavaSnippetToolbarActions">
         <action
               toolbarPath="evaluationGroup"
               id="org.eclipse.jdt.debug.ui.SnippetExecute"
               hoverIcon="$nl$/icons/full/etool16/run_sbook.gif"
               class="org.eclipse.jdt.internal.debug.ui.actions.ExecuteAction"
               disabledIcon="$nl$/icons/full/dtool16/run_sbook.gif"
               enablesFor="+"
               icon="$nl$/icons/full/etool16/run_sbook.gif"
               helpContextId="execute_action_context"
               label="%Execute.label"
               tooltip="%Execute.tooltip">
            <selection
                  class="org.eclipse.jface.text.ITextSelection">
            </selection>
         </action>
         <action
               toolbarPath="evaluationGroup"
               id="org.eclipse.jdt.debug.ui.SnippetDisplay"
               hoverIcon="$nl$/icons/full/etool16/disp_sbook.gif"
               class="org.eclipse.jdt.internal.debug.ui.actions.PopupDisplayAction"
               disabledIcon="$nl$/icons/full/dtool16/disp_sbook.gif"
               enablesFor="+"
               icon="$nl$/icons/full/etool16/disp_sbook.gif"
               helpContextId="display_action_context"
               label="%Display.label"
               tooltip="%Display.tooltip">
            <selection
                  class="org.eclipse.jface.text.ITextSelection">
            </selection>
         </action>
         <action
               toolbarPath="evaluationGroup"
               id="org.eclipse.jdt.debug.ui.SnippetInspect"
               hoverIcon="$nl$/icons/full/etool16/insp_sbook.gif"
               class="org.eclipse.jdt.internal.debug.ui.actions.PopupInspectAction"
               disabledIcon="$nl$/icons/full/dtool16/insp_sbook.gif"
               enablesFor="+"
               icon="$nl$/icons/full/etool16/insp_sbook.gif"
               helpContextId="inspect_action_context"
               label="%Inspect.label"
               tooltip="%Inspect.tooltip">
            <selection
                  class="org.eclipse.jface.text.ITextSelection">
            </selection>
         </action>
      </editorContribution>
   </extension>

从这里看出,它支持好几个操作:如CompilationUnitEditor的打断点 ,ClassFileEditor的打断点等。


每个操作都有用到的图标,用到的action响应类等,有兴趣的可以看下。





本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1588681,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值