Skip to content

Commit 41f2862

Browse files
author
hgupta9
committed
Copy Tree, Copy Value, Copy ID
1 parent 4ec95f4 commit 41f2862

File tree

3 files changed

+253
-70
lines changed

3 files changed

+253
-70
lines changed

External/Plugins/FlashDebugger/Controls/DataTree/ValueNode.cs

Lines changed: 142 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,15 @@ public int ChildrenShowLimit
1111
get { return m_ChildrenShowLimit; }
1212
set { m_ChildrenShowLimit = value; }
1313
}
14+
public static bool m_ShowFullClasspaths = true;
15+
public static bool m_ShowObjectIDs = true;
1416

1517
protected Value m_Value;
1618
private bool m_bEditing = false;
1719

18-
public string ID
19-
{
20-
get
21-
{
22-
if (m_Value != null)
23-
{
24-
int type = m_Value.getType();
25-
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
26-
{
27-
return m_Value.getTypeName().replaceAll("::", ".").replaceAll("@", " - ").ToString();
28-
}
29-
else if (type == VariableType_.FUNCTION)
30-
{
31-
return "Function - " + m_Value.ToString();
32-
}
33-
}
34-
return "";
35-
}
36-
}
37-
20+
/// <summary>
21+
/// Get the display value based on user's preferences
22+
/// </summary>
3823
public override string Value
3924
{
4025
get
@@ -47,16 +32,41 @@ public override string Value
4732
string temp = null;
4833
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
4934
{
50-
// return class type without classpath
51-
string typeStr = Strings.AfterLast(m_Value.getTypeName().ToString(), "::", true);
52-
string shortStr = Strings.Before(typeStr, "@");
53-
if (shortStr == "[]")
35+
string typeStr = "";
36+
if (m_ShowFullClasspaths)
5437
{
55-
return "Array";
38+
// return class type with classpath
39+
typeStr = m_Value.getTypeName().replaceAll("::", ".").ToString();
40+
41+
}else
42+
{
43+
// return class type without classpath
44+
typeStr = Strings.AfterLast(m_Value.getTypeName().ToString(), "::", true);
45+
}
46+
47+
// show / hide IDs
48+
if (m_ShowObjectIDs)
49+
{
50+
typeStr = typeStr.Replace("@", " @");
51+
}else
52+
{
53+
typeStr = Strings.Before(typeStr, "@");
54+
}
55+
56+
// rename array
57+
if (typeStr.StartsWith("[]"))
58+
{
59+
typeStr = typeStr.Replace("[]", "Array");
60+
}
61+
62+
// rename vector
63+
else if (typeStr.StartsWith("__AS3__.vec.Vector.<"))
64+
{
65+
typeStr = typeStr.Replace("__AS3__.vec.Vector.<", "Vector.<");
5666
}
57-
return typeStr;
5867

59-
//return m_Value.getTypeName();
68+
return typeStr;
69+
6070
}
6171
else if (type == VariableType_.NUMBER)
6272
{
@@ -94,7 +104,7 @@ public override string Value
94104
}
95105
else if (type == VariableType_.FUNCTION)
96106
{
97-
return "Function";
107+
return "Function @" + m_Value.ToString();
98108
}
99109
temp = m_Value.ToString();
100110
if (!m_bEditing)
@@ -109,6 +119,110 @@ public override string Value
109119
}
110120
}
111121

122+
/// <summary>
123+
/// Get the full classpath of the value, eg: "flash.display.MovieClip"
124+
/// </summary>
125+
public string ClassPath
126+
{
127+
get
128+
{
129+
130+
//return m_Value.getClassHierarchy(false).replaceAll("::", ".");
131+
132+
if (m_Value == null)
133+
{
134+
return null;
135+
}
136+
int type = m_Value.getType();
137+
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
138+
{
139+
string typeStr = Strings.Before(m_Value.getTypeName().replaceAll("::", "."), "@");
140+
141+
if (typeStr == "[]")
142+
{
143+
return "Array";
144+
}
145+
return typeStr;
146+
147+
}
148+
else if (type == VariableType_.NUMBER)
149+
{
150+
return "Number";
151+
}
152+
else if (type == VariableType_.BOOLEAN)
153+
{
154+
return "Boolean";
155+
}
156+
else if (type == VariableType_.STRING)
157+
{
158+
return "String";
159+
}
160+
else if (type == VariableType_.NULL)
161+
{
162+
return "null";
163+
}
164+
else if (type == VariableType_.FUNCTION)
165+
{
166+
return "Function";
167+
}
168+
return null;
169+
}
170+
set
171+
{
172+
throw new NotSupportedException();
173+
}
174+
175+
}
176+
177+
/// <summary>
178+
/// Get the object ID with the class name
179+
/// </summary>
180+
public string ID
181+
{
182+
get
183+
{
184+
if (m_Value != null)
185+
{
186+
int type = m_Value.getType();
187+
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
188+
{
189+
return m_Value.getTypeName().replaceAll("::", ".").replaceAll("@", " - ").ToString();
190+
}
191+
else if (type == VariableType_.FUNCTION)
192+
{
193+
return "Function - " + m_Value.ToString();
194+
}
195+
}
196+
return "";
197+
}
198+
}
199+
200+
/// <summary>
201+
/// Check if the value is a primitive type (int, Number, String, Boolean)
202+
/// </summary>
203+
public bool IsPrimitive
204+
{
205+
get
206+
{
207+
if (m_Value == null)
208+
{
209+
return false;
210+
}
211+
int type = m_Value.getType();
212+
if (type == VariableType_.NUMBER || type == VariableType_.BOOLEAN ||
213+
type == VariableType_.STRING || type == VariableType_.NULL)
214+
{
215+
return true;
216+
}
217+
return false;
218+
}
219+
set
220+
{
221+
throw new NotSupportedException();
222+
}
223+
}
224+
225+
112226
private string escape(string text)
113227
{
114228
text = text.Replace("\\", "\\\\");

External/Plugins/FlashDebugger/Controls/DataTreeControl.cs

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ public partial class DataTreeControl : UserControl, IToolTipProvider
2121
private DataTreeModel _model;
2222
private static ViewerForm viewerForm;
2323
private ContextMenuStrip _contextMenuStrip;
24-
private ToolStripMenuItem copyMenuItem, viewerMenuItem, watchMenuItem, copyIDMenuItem, copyTreeMenuItem;
24+
private ToolStripMenuItem copyMenuItem, viewerMenuItem, watchMenuItem, copyValueMenuItem, copyIDMenuItem, copyTreeMenuItem;
2525
private DataTreeState state;
2626
private bool watchMode;
2727
private bool addingNewExpression;
28-
private static bool combineInherited = false;
28+
private static bool m_combineInherited = false;
29+
private static bool m_showStaticInObjects = true;
2930

3031
public Collection<Node> Nodes
3132
{
@@ -99,10 +100,11 @@ public DataTreeControl(bool watchMode)
99100
this.NameTreeColumn.Header = TextHelper.GetString("Label.Name");
100101
this.ValueTreeColumn.Header = TextHelper.GetString("Label.Value");
101102
copyMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Copy"), null, new EventHandler(this.CopyItemClick));
102-
copyIDMenuItem = new ToolStripMenuItem("Copy ID", null, new EventHandler(this.CopyItemIDClick));
103+
copyValueMenuItem = new ToolStripMenuItem("Copy Value", null, new EventHandler(this.CopyItemValueClick));
104+
copyIDMenuItem = new ToolStripMenuItem("Copy ID", null, new EventHandler(this.CopyItemIDClick));
103105
copyTreeMenuItem = new ToolStripMenuItem("Copy Tree", null, new EventHandler(this.CopyItemTreeClick));
104106
viewerMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Viewer"), null, new EventHandler(this.ViewerItemClick));
105-
_contextMenuStrip.Items.AddRange(new ToolStripMenuItem[] { copyMenuItem, copyIDMenuItem, copyTreeMenuItem, viewerMenuItem});
107+
_contextMenuStrip.Items.AddRange(new ToolStripMenuItem[] { copyMenuItem, copyIDMenuItem, copyValueMenuItem, copyTreeMenuItem, viewerMenuItem });
106108
if (watchMode)
107109
watchMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Unwatch"), null, new EventHandler(this.WatchItemClick));
108110
else
@@ -389,10 +391,11 @@ public void ListChildItems(ValueNode node)
389391
nodes.Add(memberNode);
390392
}
391393
}
394+
392395
// inherited vars
393396
if (inherited.Count > 0)
394397
{
395-
if (combineInherited)
398+
if (m_combineInherited)
396399
{
397400
// list inherited alongside main class members
398401
foreach (DataNode item in inherited)
@@ -416,7 +419,7 @@ public void ListChildItems(ValueNode node)
416419
}
417420

418421
// static vars
419-
if (statics.Count > 0)
422+
if (m_showStaticInObjects && statics.Count > 0)
420423
{
421424
DataNode staticNode = new ValueNode("[static]");
422425
statics.Sort();
@@ -426,6 +429,7 @@ public void ListChildItems(ValueNode node)
426429
}
427430
node.Nodes.Add(staticNode);
428431
}
432+
429433
// test children
430434
foreach (String ch in node.PlayerValue.getClassHierarchy(false))
431435
{
@@ -590,12 +594,6 @@ private void RestoreScrollState()
590594
if (topNode != null) Tree.EnsureVisible(topNode);
591595
}
592596
}
593-
594-
public static bool CombineInherited
595-
{
596-
get { return DataTreeControl.combineInherited; }
597-
set { DataTreeControl.combineInherited = value; }
598-
}
599597

600598
#region IToolTipProvider Members
601599

@@ -633,8 +631,18 @@ private class DataTreeState
633631

634632
#endregion
635633

636-
637-
#region Copy ID & Tree
634+
#region Copy Value, ID, Tree
635+
636+
private void CopyItemValueClick(Object sender, System.EventArgs e)
637+
{
638+
if (Tree.SelectedNode != null)
639+
{
640+
641+
ValueNode node = Tree.SelectedNode.Tag as ValueNode;
642+
Clipboard.SetText(node.Value);
643+
644+
}
645+
}
638646

639647
private void CopyItemIDClick(Object sender, System.EventArgs e)
640648
{
@@ -662,9 +670,47 @@ private void CopyTreeInternal(int levelLimit)
662670

663671
}
664672
}
673+
674+
#endregion
665675

676+
#region Settings
666677

667-
#endregion
678+
public int CopyTreeMaxChars
679+
{
680+
get { return CopyTreeHelper._CopyTreeMaxChars; }
681+
set { CopyTreeHelper._CopyTreeMaxChars = value; }
682+
}
683+
public int CopyTreeMaxRecursion
684+
{
685+
get { return CopyTreeHelper._CopyTreeMaxRecursion; }
686+
set { CopyTreeHelper._CopyTreeMaxRecursion = value; }
687+
}
688+
689+
public static bool CombineInherited
690+
{
691+
get { return DataTreeControl.m_combineInherited; }
692+
set { DataTreeControl.m_combineInherited = value; }
693+
}
694+
695+
public static bool ShowStaticInObjects
696+
{
697+
get { return DataTreeControl.m_showStaticInObjects; }
698+
set { DataTreeControl.m_showStaticInObjects = value; }
699+
}
700+
701+
public static bool ShowFullClasspaths
702+
{
703+
get { return ValueNode.m_ShowFullClasspaths; }
704+
set { ValueNode.m_ShowFullClasspaths = value; }
705+
}
706+
707+
public static bool ShowObjectIDs
708+
{
709+
get { return ValueNode.m_ShowObjectIDs; }
710+
set { ValueNode.m_ShowObjectIDs = value; }
711+
}
712+
713+
#endregion
668714

669715
}
670716

0 commit comments

Comments
 (0)