Skip to content

Commit 606ae5e

Browse files
committed
Fixed copy tree char limit.
Added settings and localized text. Still missing the code to live update the tree. Refactored CopyAsTree helper and extracted an interface. The idea is that other developers could inject some custom implementations, to for example, export to XML, JSON, or other formats. Other coding style changes.
1 parent d9824f8 commit 606ae5e

File tree

15 files changed

+468
-134
lines changed

15 files changed

+468
-134
lines changed

External/Plugins/FlashDebugger/Controls/DataTipForm.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public void SetVariable(Variable variable, String path)
4545
public void SetVariable(Variable variable)
4646
{
4747
DataTree.Nodes.Clear();
48-
DataTree.AddNode(new VariableNode(variable));
48+
DataTree.AddNode(new VariableNode(variable)
49+
{
50+
HideClassId = DataTree.HideObjectIds,
51+
HideFullClasspath = DataTree.HideFullClasspaths
52+
});
4953
DoResize();
5054
}
5155

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ 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;
14+
15+
public bool HideFullClasspath { get; set; }
16+
public bool HideClassId { get; set; }
1617

1718
protected Value m_Value;
1819
private bool m_bEditing = false;
@@ -33,26 +34,19 @@ public override string Value
3334
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
3435
{
3536
string typeStr = "";
36-
if (m_ShowFullClasspaths)
37+
if (HideFullClasspath)
3738
{
38-
// return class type with classpath
39-
typeStr = m_Value.getTypeName().replaceAll("::", ".").ToString();
39+
// return class type without classpath
40+
typeStr = m_Value.getTypeName().ToString().AfterLast("::", true);
4041
}
4142
else
4243
{
43-
// return class type without classpath
44-
typeStr = Strings.AfterLast(m_Value.getTypeName().ToString(), "::", true);
44+
// return class type with classpath
45+
typeStr = m_Value.getTypeName().replaceAll("::", ".").ToString();
4546
}
4647

4748
// show / hide IDs
48-
if (m_ShowObjectIDs)
49-
{
50-
typeStr = typeStr.Replace("@", " @");
51-
}
52-
else
53-
{
54-
typeStr = Strings.Before(typeStr, "@");
55-
}
49+
typeStr = HideClassId ? typeStr.Before("@") : typeStr.Replace("@", " @");
5650

5751
// rename array
5852
if (typeStr.StartsWith("[]"))
@@ -127,16 +121,14 @@ public string ClassPath
127121
get
128122
{
129123

130-
//return m_Value.getClassHierarchy(false).replaceAll("::", ".");
131-
132124
if (m_Value == null)
133125
{
134126
return null;
135127
}
136128
int type = m_Value.getType();
137129
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
138130
{
139-
string typeStr = Strings.Before(m_Value.getTypeName().replaceAll("::", "."), "@");
131+
string typeStr = m_Value.getTypeName().replaceAll("::", ".").ToString().Before("@");
140132

141133
if (typeStr == "[]")
142134
{

External/Plugins/FlashDebugger/Controls/DataTreeControl.cs

Lines changed: 86 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,96 @@ public partial class DataTreeControl : UserControl, IToolTipProvider
2525
private DataTreeState state;
2626
private bool watchMode;
2727
private bool addingNewExpression;
28-
private static bool m_combineInherited = false;
29-
private static bool m_showStaticInObjects = true;
28+
private int _copyTreeMaxChars;
29+
private int _copyTreeMaxRecursion;
30+
private bool _combineInherited;
31+
private bool _hideStaticInObjects;
32+
private bool _hideFullClasspaths;
33+
private bool _hideObjectIds;
3034

3135
public Collection<Node> Nodes
3236
{
33-
get
37+
get { return _model.Root.Nodes; }
38+
}
39+
40+
public TreeViewAdv Tree
41+
{
42+
get { return _tree; }
43+
}
44+
45+
public ViewerForm Viewer
46+
{
47+
get { return viewerForm; }
48+
}
49+
50+
public int CopyTreeMaxChars
51+
{
52+
get { return _copyTreeMaxChars; }
53+
set
3454
{
35-
return _model.Root.Nodes;
55+
if (_copyTreeMaxChars == value) return;
56+
_copyTreeMaxChars = value;
57+
Tree.FullUpdate();
3658
}
3759
}
3860

39-
public TreeViewAdv Tree
61+
public int CopyTreeMaxRecursion
4062
{
41-
get
63+
get { return _copyTreeMaxRecursion; }
64+
set
4265
{
43-
return _tree;
66+
if (_copyTreeMaxRecursion == value) return;
67+
_copyTreeMaxRecursion = value;
68+
Tree.FullUpdate();
4469
}
4570
}
4671

47-
public ViewerForm Viewer
72+
public bool CombineInherited
4873
{
49-
get
74+
get { return _combineInherited; }
75+
set
5076
{
51-
return viewerForm;
77+
if (_combineInherited == value) return;
78+
_combineInherited = value;
79+
Tree.FullUpdate();
5280
}
5381
}
5482

55-
public DataTreeControl():this(false)
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+
public DataTreeControl()
117+
: this(false)
56118
{
57119
}
58120

@@ -376,7 +438,11 @@ public void ListChildItems(ValueNode node)
376438
int tmpLimit = node.ChildrenShowLimit;
377439
foreach (Variable member in node.PlayerValue.getMembers(flashInterface.Session))
378440
{
379-
VariableNode memberNode = new VariableNode(member);
441+
VariableNode memberNode = new VariableNode(member)
442+
{
443+
HideClassId = HideObjectIds,
444+
HideFullClasspath = HideFullClasspaths
445+
};
380446

381447
if (member.isAttributeSet(VariableAttribute_.IS_STATIC))
382448
{
@@ -395,7 +461,7 @@ public void ListChildItems(ValueNode node)
395461
// inherited vars
396462
if (inherited.Count > 0)
397463
{
398-
if (m_combineInherited)
464+
if (_combineInherited)
399465
{
400466
// list inherited alongside main class members
401467
foreach (DataNode item in inherited)
@@ -419,7 +485,7 @@ public void ListChildItems(ValueNode node)
419485
}
420486

421487
// static vars
422-
if (m_showStaticInObjects && statics.Count > 0)
488+
if (!_hideStaticInObjects && statics.Count > 0)
423489
{
424490
DataNode staticNode = new ValueNode("[static]");
425491
statics.Sort();
@@ -447,7 +513,11 @@ public void ListChildItems(ValueNode node)
447513
var ctx = new ExpressionContext(flashInterface.Session, flashInterface.GetFrames()[PluginMain.debugManager.CurrentFrame]);
448514
var obj = exp.evaluate(ctx);
449515
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());
450-
DataNode childNode = new VariableNode((Variable)obj);
516+
DataNode childNode = new VariableNode((Variable) obj)
517+
{
518+
HideClassId = HideObjectIds,
519+
HideFullClasspath = HideFullClasspaths
520+
};
451521
childNode.Text = "child_" + i;
452522
childrenNode.Nodes.Add(childNode);
453523
}
@@ -661,49 +731,9 @@ private void CopyItemTreeClick(Object sender, System.EventArgs e)
661731
private void CopyTreeInternal(int levelLimit)
662732
{
663733
ValueNode node = Tree.SelectedNode.Tag as ValueNode;
664-
Clipboard.SetText(CopyTreeHelper.GetTreeAsText(Tree.SelectedNode, node, "\t", this, levelLimit));
665-
}
666-
667-
#endregion
668-
669-
#region Settings
670-
671-
public static int CopyTreeMaxChars
672-
{
673-
get { return CopyTreeHelper._CopyTreeMaxChars; }
674-
set { CopyTreeHelper._CopyTreeMaxChars = value; }
675-
}
676-
677-
public static int CopyTreeMaxRecursion
678-
{
679-
get { return CopyTreeHelper._CopyTreeMaxRecursion; }
680-
set { CopyTreeHelper._CopyTreeMaxRecursion = value; }
734+
Clipboard.SetText(new Helpers.DefaultDataTreeExporter() {CopyTreeMaxChars = PluginMain.settingObject.CopyTreeMaxChars, CopyTreeMaxRecursion = PluginMain.settingObject.CopyTreeMaxRecursion}.GetTreeAsText(node, "\t", this, levelLimit));
681735
}
682736

683-
public static bool CombineInherited
684-
{
685-
get { return DataTreeControl.m_combineInherited; }
686-
set { DataTreeControl.m_combineInherited = value; }
687-
}
688-
689-
public static bool ShowStaticInObjects
690-
{
691-
get { return DataTreeControl.m_showStaticInObjects; }
692-
set { DataTreeControl.m_showStaticInObjects = value; }
693-
}
694-
695-
public static bool ShowFullClasspaths
696-
{
697-
get { return ValueNode.m_ShowFullClasspaths; }
698-
set { ValueNode.m_ShowFullClasspaths = value; }
699-
}
700-
701-
public static bool ShowObjectIDs
702-
{
703-
get { return ValueNode.m_ShowObjectIDs; }
704-
set { ValueNode.m_ShowObjectIDs = value; }
705-
}
706-
707737
#endregion
708738

709739
}

External/Plugins/FlashDebugger/Controls/LocalsUI.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public void SetData(Variable[] variables)
5050
{
5151
foreach (Variable item in variables)
5252
{
53-
treeControl.AddNode(new VariableNode(item));
53+
treeControl.AddNode(new VariableNode(item)
54+
{
55+
HideClassId = treeControl.HideObjectIds,
56+
HideFullClasspath = treeControl.HideFullClasspaths
57+
});
5458
}
5559
}
5660
finally

External/Plugins/FlashDebugger/Controls/WatchUI.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Drawing;
5-
using System.Data;
6-
using System.Text;
73
using System.Windows.Forms;
8-
using Aga.Controls.Tree.NodeControls;
94
using FlashDebugger.Controls.DataTree;
105
using PluginCore;
116
using PluginCore.Localization;

External/Plugins/FlashDebugger/FlashDebugger.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@
148148
<Compile Include="Debugger\ExpressionContext.cs" />
149149
<Compile Include="Debugger\FlashInterface.cs" />
150150
<Compile Include="Debugger\VariableFacade.cs" />
151-
<Compile Include="Helpers\CopyAsTree.cs" />
151+
<Compile Include="Helpers\DefaultDataTreeExporter.cs" />
152+
<Compile Include="Helpers\IDataTreeExporter.cs" />
152153
<Compile Include="Helpers\MenusHelper.cs" />
153154
<Compile Include="Helpers\PanelsHelper.cs" />
154155
<Compile Include="Helpers\StringsHelper.cs" />

0 commit comments

Comments
 (0)