KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > debugger > panels > DBInputTreePanel


1 package org.antlr.works.debugger.panels;
2
3 import org.antlr.runtime.Token;
4 import org.antlr.works.awtree.AWTreePanel;
5 import org.antlr.works.awtree.AWTreePanelDelegate;
6 import org.antlr.works.debugger.Debugger;
7 import org.antlr.works.debugger.input.DBInputProcessor;
8 import org.antlr.works.debugger.input.DBInputProcessorTree;
9 import org.antlr.works.debugger.input.DBInputTextTokenInfo;
10
11 import javax.swing.*;
12 import javax.swing.tree.DefaultTreeModel JavaDoc;
13 import javax.swing.tree.TreeNode JavaDoc;
14 /*
15
16 [The "BSD licence"]
17 Copyright (c) 2005-2006 Jean Bovet
18 All rights reserved.
19
20 Redistribution and use in source and binary forms, with or without
21 modification, are permitted provided that the following conditions
22 are met:
23
24 1. Redistributions of source code must retain the above copyright
25 notice, this list of conditions and the following disclaimer.
26 2. Redistributions in binary form must reproduce the above copyright
27 notice, this list of conditions and the following disclaimer in the
28 documentation and/or other materials provided with the distribution.
29 3. The name of the author may not be used to endorse or promote products
30 derived from this software without specific prior written permission.
31
32 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 */

44
45 public class DBInputTreePanel implements DBInputConcretePanel, AWTreePanelDelegate {
46
47     public Debugger debugger;
48
49     public AWTreePanel treePanel;
50     public DBInputProcessorTree processorTree;
51
52     public DBInputTreePanel(Debugger debugger) {
53         this.debugger = debugger;
54
55         treePanel = new AWTreePanel(new DefaultTreeModel JavaDoc(null));
56         treePanel.setRootVisible(true);
57         treePanel.setDelegate(this);
58
59         processorTree = new DBInputProcessorTree(treePanel, debugger);
60     }
61
62     public void close() {
63         processorTree.close();
64     }
65
66     public void stop() {
67     }
68
69     public JComponent getComponent() {
70         return treePanel;
71     }
72
73     public DBInputProcessor getInputProcessor() {
74         return processorTree;
75     }
76
77     public void toggleInputTextTokensBox() {
78         /** Not applicable here. Ignore */
79     }
80
81     public boolean isInputTokensBoxVisible() {
82         return false;
83     }
84
85     public boolean isBreakpointAtToken(Token token) {
86         return processorTree.isBreakpointAtToken(token);
87     }
88
89     public void selectToken(Token token) {
90         /** Not applicable here. Ignore */
91     }
92
93     public DBInputTextTokenInfo getTokenInfoForToken(Token token) {
94         return processorTree.getTokenInfoForToken(token);
95     }
96
97     public void updateOnBreakEvent() {
98         processorTree.updateTreePanel();
99     }
100
101     public void awTreeDidSelectTreeNode(TreeNode JavaDoc node, boolean shiftKey) {
102         DBInputProcessorTree.InputTreeNode n = (DBInputProcessorTree.InputTreeNode) node;
103         if(shiftKey)
104             n.toggleBreakpoint();
105
106         debugger.selectToken(n.getToken(), n.getLine(), n.getPosition());
107     }
108
109     public JPopupMenu awTreeGetContextualMenu() {
110         return debugger.treeGetContextualMenu();
111     }
112
113 }
114
Popular Tags