KickJava   Java API By Example, From Geeks To Geeks.

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


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

41
42 public class DBInputPanel extends DetachablePanel {
43
44     protected Debugger debugger;
45
46     protected DBInputTokenPanel inputTokenPanel;
47     protected DBInputTreePanel inputTreePanel;
48
49     protected DBInputConcretePanel currentPanel;
50
51     public DBInputPanel(Debugger debugger) {
52         super("Input", debugger);
53
54         this.debugger = debugger;
55
56         inputTokenPanel = new DBInputTokenPanel(debugger);
57         inputTreePanel = new DBInputTreePanel(debugger);
58
59         /** Set the input token panel by default */
60         setCurrentPanel(inputTokenPanel);
61     }
62
63     public void setCurrentPanel(DBInputConcretePanel panel) {
64         this.currentPanel = panel;
65         if(mainPanel.getComponentCount() > 0)
66             mainPanel.remove(0);
67
68         mainPanel.add(currentPanel.getComponent(), BorderLayout.CENTER);
69     }
70
71     public void prepareForGrammar(EngineGrammar grammar) {
72         if(grammar.isTreeParserGrammar())
73             setCurrentPanel(inputTreePanel);
74         else
75             setCurrentPanel(inputTokenPanel);
76     }
77
78     public void close() {
79         currentPanel.close();
80     }
81
82     public DBInputProcessor getInputBuffer() {
83         return currentPanel.getInputProcessor();
84     }
85
86     public void toggleInputTokensBox() {
87         currentPanel.toggleInputTextTokensBox();
88     }
89
90     public boolean isInputTokensBoxVisible() {
91         return currentPanel.isInputTokensBoxVisible();
92     }
93
94     public void updateOnBreakEvent() {
95         currentPanel.updateOnBreakEvent();
96     }
97
98     public boolean isBreakpointAtToken(Token token) {
99         return currentPanel.isBreakpointAtToken(token);
100     }
101
102     public void stop() {
103         currentPanel.stop();
104     }
105
106     public void selectToken(Token token) {
107         currentPanel.selectToken(token);
108     }
109
110     public DBInputTextTokenInfo getTokenInfoForToken(Token token) {
111         return currentPanel.getTokenInfoForToken(token);
112     }
113
114 }
115
Popular Tags