2
//using System.Collections;
3
//using System.ComponentModel;
4
//using System.Drawing;
6
using System.Windows.Forms;
8
using AST = antlr.collections.AST;
10
namespace antlr.debug.misc
13
/// Summary description for myJTreeASTPanel.
15
public class JTreeASTPanel : System.Windows.Forms.UserControl
17
private System.Windows.Forms.TreeView tree;
19
/// Required designer variable.
21
private System.ComponentModel.Container components = null;
23
private JTreeASTPanel()
25
// This call is required by the Windows.Forms Form Designer.
26
InitializeComponent();
28
// TODO: Add any initialization after the InitForm call
32
public JTreeASTPanel(TreeViewEventHandler afterSelectHandler, AST rootAST) : this()
34
tree.AfterSelect += afterSelectHandler;
35
tree.BeforeExpand += new TreeViewCancelEventHandler(ASTTreeNode.tree_BeforeExpand);
36
tree.Nodes.Add(new ASTTreeNode(rootAST));
40
/// Clean up any resources being used.
42
protected override void Dispose( bool disposing )
46
if(components != null)
51
base.Dispose( disposing );
54
#region Component Designer generated code
56
/// Required method for Designer support - do not modify
57
/// the contents of this method with the code editor.
59
private void InitializeComponent()
61
this.tree = new System.Windows.Forms.TreeView();
66
this.tree.Dock = System.Windows.Forms.DockStyle.Fill;
67
this.tree.ImageIndex = -1;
68
this.tree.ImeMode = System.Windows.Forms.ImeMode.NoControl;
69
this.tree.Location = new System.Drawing.Point(5, 5);
70
this.tree.Name = "tree";
71
this.tree.SelectedImageIndex = -1;
72
this.tree.Size = new System.Drawing.Size(140, 140);
73
this.tree.TabIndex = 0;
77
this.Controls.AddRange(new System.Windows.Forms.Control[] {
79
this.DockPadding.All = 5;
80
this.Name = "JTreeASTPanel";
81
this.ResumeLayout(false);
88
internal class ASTTreeNode : TreeNode
91
internal bool IsAlreadyExpanded = false;
95
get { return ASTNode_; }
96
set { ASTNode_ = value; }
99
public ASTTreeNode(AST a)
102
this.Text = a.ToString();
103
this.Nodes.Add("Loading.....");
106
internal static void tree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
108
ASTTreeNode thisNode = (ASTTreeNode)e.Node;
109
AST parentAST = thisNode.ASTNode;
112
if (!thisNode.IsAlreadyExpanded)
114
thisNode.Nodes.Clear();
115
childAST = parentAST.getFirstChild();
116
while (null != childAST)
118
thisNode.Nodes.Add(new ASTTreeNode(childAST));
119
childAST = childAST.getNextSibling();
121
thisNode.IsAlreadyExpanded = true;