@@ -17,7 +17,7 @@ namespace FlashDebugger.Controls
17
17
public class WatchUI : DockPanelControl
18
18
{
19
19
private DataTreeControl treeControl ;
20
- private List < String > watches ;
20
+ private List < string > watches ;
21
21
22
22
public WatchUI ( )
23
23
{
@@ -39,23 +39,25 @@ private void TreeControlResize(Object sender, EventArgs e)
39
39
this . treeControl . Tree . Columns [ 1 ] . Width = w - 8 ;
40
40
}
41
41
42
- public bool AddElement ( String item )
42
+ public bool AddElement ( string item )
43
43
{
44
44
if ( watches . Contains ( item ) ) return false ;
45
45
watches . Add ( item ) ;
46
+ treeControl . Nodes . Insert ( watches . Count - 1 , GetExpressionNode ( item ) ) ;
46
47
UpdateElements ( ) ;
47
48
return true ;
48
49
}
49
50
50
51
public void RemoveElement ( string item )
51
52
{
52
- watches . Remove ( item ) ;
53
- UpdateElements ( ) ;
53
+ if ( watches . Remove ( item ) )
54
+ UpdateElements ( ) ;
54
55
}
55
56
56
57
public void RemoveElement ( int itemN )
57
58
{
58
- if ( itemN < watches . Count ) RemoveElement ( watches [ itemN ] ) ;
59
+ if ( itemN < watches . Count ) watches . RemoveAt ( itemN ) ;
60
+ treeControl . Nodes . RemoveAt ( itemN ) ;
59
61
}
60
62
61
63
public bool ReplaceElement ( string oldItem , string newItem )
@@ -67,7 +69,7 @@ public bool ReplaceElement(string oldItem, string newItem)
67
69
else
68
70
{
69
71
watches [ itemN ] = newItem ;
70
- UpdateElements ( ) ;
72
+ treeControl . Nodes [ itemN ] = GetExpressionNode ( newItem ) ;
71
73
}
72
74
73
75
return true ;
@@ -78,36 +80,16 @@ public void Clear()
78
80
watches . Clear ( ) ;
79
81
treeControl . Nodes . Clear ( ) ;
80
82
}
81
-
83
+
82
84
public void UpdateElements ( )
83
85
{
84
86
treeControl . Tree . BeginUpdate ( ) ;
85
87
treeControl . SaveState ( ) ;
86
88
87
89
treeControl . Nodes . Clear ( ) ;
88
- foreach ( String item in watches )
90
+ foreach ( string item in watches )
89
91
{
90
- DataNode node ; // todo, introduce new Node types.
91
- try
92
- {
93
- IASTBuilder builder = new ASTBuilder ( false ) ;
94
- ValueExp exp = builder . parse ( new java . io . StringReader ( item ) ) ;
95
- var ctx = new ExpressionContext ( PluginMain . debugManager . FlashInterface . Session , PluginMain . debugManager . FlashInterface . GetFrames ( ) [ PluginMain . debugManager . CurrentFrame ] ) ;
96
- var obj = exp . evaluate ( ctx ) ;
97
- if ( obj is Variable )
98
- node = new VariableNode ( ( Variable ) obj ) ;
99
- else if ( obj is Value )
100
- node = new ValueNode ( item , ( Value ) obj ) ;
101
- else
102
- node = new ScalarNode ( item , obj . toString ( ) ) ;
103
- node . Tag = item ;
104
- }
105
- catch ( Exception ex )
106
- {
107
- node = new ErrorNode ( item , ex ) ;
108
- }
109
- node . Text = item ;
110
- treeControl . AddNode ( node ) ;
92
+ treeControl . AddNode ( GetExpressionNode ( item ) ) ;
111
93
}
112
94
113
95
treeControl . AddNode ( new ValueNode ( TextHelper . GetString ( "Label.AddExpression" ) ) ) ;
@@ -116,5 +98,31 @@ public void UpdateElements()
116
98
treeControl . Enabled = true ;
117
99
}
118
100
101
+ private DataNode GetExpressionNode ( string item )
102
+ {
103
+ DataNode node ;
104
+ try
105
+ {
106
+ IASTBuilder builder = new ASTBuilder ( false ) ;
107
+ ValueExp exp = builder . parse ( new java . io . StringReader ( item ) ) ;
108
+ var ctx = new ExpressionContext ( PluginMain . debugManager . FlashInterface . Session , PluginMain . debugManager . FlashInterface . GetFrames ( ) [ PluginMain . debugManager . CurrentFrame ] ) ;
109
+ var obj = exp . evaluate ( ctx ) ;
110
+ if ( obj is Variable )
111
+ node = new VariableNode ( ( Variable ) obj ) ;
112
+ else if ( obj is Value )
113
+ node = new ValueNode ( item , ( Value ) obj ) ;
114
+ else
115
+ node = new ScalarNode ( item , obj . toString ( ) ) ;
116
+ node . Tag = item ;
117
+ }
118
+ catch ( Exception ex )
119
+ {
120
+ node = new ErrorNode ( item , ex ) ;
121
+ }
122
+ node . Text = item ;
123
+
124
+ return node ;
125
+ }
126
+
119
127
}
120
128
}
0 commit comments