@@ -21,16 +21,10 @@ public partial class DataTreeControl : UserControl, IToolTipProvider
21
21
private DataTreeModel _model ;
22
22
private static ViewerForm viewerForm ;
23
23
private ContextMenuStrip _contextMenuStrip ;
24
- private ToolStripMenuItem copyMenuItem , viewerMenuItem , watchMenuItem , copyValueMenuItem , copyIdMenuItem , copyTreeMenuItem ;
24
+ private ToolStripMenuItem copyMenuItem , viewerMenuItem , watchMenuItem , copyValueMenuItem , copyIdMenuItem ;
25
25
private DataTreeState state ;
26
26
private bool watchMode ;
27
27
private bool addingNewExpression ;
28
- private int _copyTreeMaxChars ;
29
- private int _copyTreeMaxRecursion ;
30
- private bool _combineInherited ;
31
- private bool _hideStaticInObjects ;
32
- private bool _hideFullClasspaths ;
33
- private bool _hideObjectIds ;
34
28
35
29
public Collection < Node > Nodes
36
30
{
@@ -47,72 +41,6 @@ public ViewerForm Viewer
47
41
get { return viewerForm ; }
48
42
}
49
43
50
- public int CopyTreeMaxChars
51
- {
52
- get { return _copyTreeMaxChars ; }
53
- set
54
- {
55
- if ( _copyTreeMaxChars == value ) return ;
56
- _copyTreeMaxChars = value ;
57
- Tree . FullUpdate ( ) ;
58
- }
59
- }
60
-
61
- public int CopyTreeMaxRecursion
62
- {
63
- get { return _copyTreeMaxRecursion ; }
64
- set
65
- {
66
- if ( _copyTreeMaxRecursion == value ) return ;
67
- _copyTreeMaxRecursion = value ;
68
- Tree . FullUpdate ( ) ;
69
- }
70
- }
71
-
72
- public bool CombineInherited
73
- {
74
- get { return _combineInherited ; }
75
- set
76
- {
77
- if ( _combineInherited == value ) return ;
78
- _combineInherited = value ;
79
- Tree . FullUpdate ( ) ;
80
- }
81
- }
82
-
83
- public bool HideStaticInObjects
84
- {
85
- get { return _hideStaticInObjects ; }
86
- set
87
- {
88
- if ( _hideStaticInObjects == value ) return ;
89
- _hideStaticInObjects = value ;
90
- Tree . FullUpdate ( ) ;
91
- }
92
- }
93
-
94
- public bool HideFullClasspaths
95
- {
96
- get { return _hideFullClasspaths ; }
97
- set
98
- {
99
- if ( _hideFullClasspaths == value ) return ;
100
- _hideFullClasspaths = value ;
101
- Tree . FullUpdate ( ) ;
102
- }
103
- }
104
-
105
- public bool HideObjectIds
106
- {
107
- get { return _hideObjectIds ; }
108
- set
109
- {
110
- if ( _hideObjectIds == value ) return ;
111
- _hideObjectIds = value ;
112
- Tree . FullUpdate ( ) ;
113
- }
114
- }
115
-
116
44
public DataTreeControl ( )
117
45
: this ( false )
118
46
{
@@ -161,14 +89,12 @@ public DataTreeControl(bool watchMode)
161
89
NameTreeColumn . Header = TextHelper . GetString ( "Label.Name" ) ;
162
90
ValueTreeColumn . Header = TextHelper . GetString ( "Label.Value" ) ;
163
91
copyMenuItem = new ToolStripMenuItem ( TextHelper . GetString ( "Label.Copy" ) , null , CopyItemClick ) ;
164
- copyValueMenuItem = new ToolStripMenuItem ( "Copy Value" , null , CopyItemValueClick ) ;
165
- copyIdMenuItem = new ToolStripMenuItem ( "Copy ID" , null , CopyItemIdClick ) ;
166
- copyTreeMenuItem = new ToolStripMenuItem ( "Copy Tree" , null , CopyItemTreeClick ) ;
92
+ copyValueMenuItem = new ToolStripMenuItem ( TextHelper . GetString ( "Label.CopyValue" ) , null , CopyItemValueClick ) ;
93
+ copyIdMenuItem = new ToolStripMenuItem ( TextHelper . GetString ( "Label.CopyID" ) , null , CopyItemIdClick ) ;
167
94
viewerMenuItem = new ToolStripMenuItem ( TextHelper . GetString ( "Label.Viewer" ) , null , ViewerItemClick ) ;
168
95
_contextMenuStrip . Items . AddRange ( new ToolStripItem [ ]
169
96
{
170
- copyMenuItem , copyIdMenuItem , copyValueMenuItem , copyTreeMenuItem ,
171
- viewerMenuItem
97
+ copyMenuItem , copyIdMenuItem , copyValueMenuItem , viewerMenuItem
172
98
} ) ;
173
99
if ( watchMode )
174
100
watchMenuItem = new ToolStripMenuItem ( TextHelper . GetString ( "Label.Unwatch" ) , null , WatchItemClick ) ;
@@ -178,6 +104,10 @@ public DataTreeControl(bool watchMode)
178
104
_contextMenuStrip . Opening += ContextMenuStrip_Opening ;
179
105
viewerForm = new ViewerForm ( ) ;
180
106
viewerForm . StartPosition = FormStartPosition . Manual ;
107
+
108
+ // LiveDataTip is created before the settings object. We don't need for it anyway
109
+ if ( PluginMain . settingObject != null )
110
+ PluginMain . settingObject . DataTreeDisplayChanged += DataTreeDisplayChanged ;
181
111
}
182
112
183
113
void ContextMenuStrip_Opening ( object sender , System . ComponentModel . CancelEventArgs e )
@@ -190,7 +120,51 @@ void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventAr
190
120
if ( watchMode ) watchMenuItem . Enabled = ( enabled && Tree . SelectedNode . Level == 1 && Tree . SelectedNode . NextNode != null ) ;
191
121
192
122
bool isValueNode = enabled && ( Tree . SelectedNode . Tag as ValueNode ) != null ;
193
- copyValueMenuItem . Visible = copyIdMenuItem . Visible = copyTreeMenuItem . Visible = isValueNode ;
123
+ copyValueMenuItem . Visible = copyIdMenuItem . Visible = isValueNode ;
124
+
125
+ while ( _contextMenuStrip . Items [ _contextMenuStrip . Items . Count - 2 ] != copyValueMenuItem )
126
+ _contextMenuStrip . Items . RemoveAt ( _contextMenuStrip . Items . Count - 2 ) ;
127
+
128
+ if ( isValueNode )
129
+ {
130
+ foreach ( var entry in Helpers . DataTreeExporterFactory . Exporters )
131
+ {
132
+ var exporterItem = new ToolStripMenuItem ( TextHelper . GetString ( "Label.CopyTree" ) , null , CopyItemTreeClick ) ;
133
+ if ( entry . Key != "" )
134
+ exporterItem . Text += " - " + entry . Key ;
135
+ exporterItem . Tag = entry . Key ;
136
+ _contextMenuStrip . Items . Insert ( _contextMenuStrip . Items . Count - 1 , exporterItem ) ;
137
+ }
138
+ }
139
+ }
140
+
141
+ void DataTreeDisplayChanged ( object sender , EventArgs e )
142
+ {
143
+ SaveState ( ) ;
144
+
145
+ foreach ( var node in _model . Root . Nodes )
146
+ {
147
+ var valueNode = node as ValueNode ;
148
+ if ( valueNode != null )
149
+ {
150
+ if ( node . Nodes != null && node . Nodes . Count > 0 )
151
+ {
152
+ // Needed because of static and inherited members.
153
+ // If we add a different event or check against a previous value we could avoid removing and reevaluating members.
154
+ // At any rate, performance shouldn't be a concern here.
155
+ node . Nodes . Clear ( ) ;
156
+ ListChildItems ( valueNode ) ;
157
+ }
158
+
159
+ valueNode . HideClassId = PluginMain . settingObject . HideClassIds ;
160
+ valueNode . HideFullClasspath = PluginMain . settingObject . HideFullClasspaths ;
161
+ }
162
+
163
+ }
164
+
165
+ _tree . FullUpdate ( ) ;
166
+
167
+ RestoreState ( ) ;
194
168
}
195
169
196
170
void NameNodeTextBox_DrawText ( object sender , DrawEventArgs e )
@@ -440,8 +414,8 @@ public void ListChildItems(ValueNode node)
440
414
{
441
415
VariableNode memberNode = new VariableNode ( member )
442
416
{
443
- HideClassId = HideObjectIds ,
444
- HideFullClasspath = HideFullClasspaths
417
+ HideClassId = PluginMain . settingObject . HideClassIds ,
418
+ HideFullClasspath = PluginMain . settingObject . HideFullClasspaths
445
419
} ;
446
420
447
421
if ( member . isAttributeSet ( VariableAttribute_ . IS_STATIC ) )
@@ -461,7 +435,7 @@ public void ListChildItems(ValueNode node)
461
435
// inherited vars
462
436
if ( inherited . Count > 0 )
463
437
{
464
- if ( _combineInherited )
438
+ if ( PluginMain . settingObject . CombineInherited )
465
439
{
466
440
// list inherited alongside main class members
467
441
foreach ( DataNode item in inherited )
@@ -485,7 +459,7 @@ public void ListChildItems(ValueNode node)
485
459
}
486
460
487
461
// static vars
488
- if ( ! _hideStaticInObjects && statics . Count > 0 )
462
+ if ( ! PluginMain . settingObject . HideStaticMembers && statics . Count > 0 )
489
463
{
490
464
DataNode staticNode = new ValueNode ( "[static]" ) ;
491
465
statics . Sort ( ) ;
@@ -515,8 +489,8 @@ public void ListChildItems(ValueNode node)
515
489
if ( obj is flash . tools . debugger . concrete . DValue ) obj = new flash . tools . debugger . concrete . DVariable ( "getChildAt(" + i + ")" , ( flash . tools . debugger . concrete . DValue ) obj , ( ( flash . tools . debugger . concrete . DValue ) obj ) . getIsolateId ( ) ) ;
516
490
DataNode childNode = new VariableNode ( ( Variable ) obj )
517
491
{
518
- HideClassId = HideObjectIds ,
519
- HideFullClasspath = HideFullClasspaths
492
+ HideClassId = PluginMain . settingObject . HideClassIds ,
493
+ HideFullClasspath = PluginMain . settingObject . HideFullClasspaths
520
494
} ;
521
495
childNode . Text = "child_" + i ;
522
496
childrenNode . Nodes . Add ( childNode ) ;
@@ -554,7 +528,7 @@ public void ListChildItems(ValueNode node)
554
528
}
555
529
//test children
556
530
nodes . Sort ( ) ;
557
-
531
+
558
532
// add child items
559
533
_tree . BeginUpdate ( ) ;
560
534
foreach ( DataNode item in nodes )
@@ -725,13 +699,17 @@ private void CopyItemIdClick(Object sender, System.EventArgs e)
725
699
726
700
private void CopyItemTreeClick ( Object sender , System . EventArgs e )
727
701
{
728
- CopyTreeInternal ( 0 ) ;
702
+ string exporterKey = ( string ) ( ( ToolStripItem ) sender ) . Tag ;
703
+ CopyTreeInternal ( exporterKey , 0 ) ;
729
704
}
730
705
731
- private void CopyTreeInternal ( int levelLimit )
706
+ private void CopyTreeInternal ( string exporterKey , int levelLimit )
732
707
{
733
- ValueNode node = Tree . SelectedNode . Tag as ValueNode ;
734
- Clipboard . SetText ( new Helpers . DefaultDataTreeExporter ( ) { CopyTreeMaxChars = PluginMain . settingObject . CopyTreeMaxChars , CopyTreeMaxRecursion = PluginMain . settingObject . CopyTreeMaxRecursion } . GetTreeAsText ( node , "\t " , this , levelLimit ) ) ;
708
+ var node = Tree . SelectedNode . Tag as ValueNode ;
709
+ var exporter = Helpers . DataTreeExporterFactory . Exporters [ exporterKey ] ;
710
+ exporter . CopyTreeMaxChars = PluginMain . settingObject . CopyTreeMaxChars ;
711
+ exporter . CopyTreeMaxRecursion = PluginMain . settingObject . CopyTreeMaxRecursion ;
712
+ Clipboard . SetText ( exporter . GetTreeAsText ( node , "\t " , this , levelLimit ) ) ;
735
713
}
736
714
737
715
#endregion
0 commit comments