Skip to content

Commit 2ba02c0

Browse files
committed
Missing localized text.
Possible to now set custom data tree exporters through a rather basic static factory. Data tree update at runtime when changing settings.
1 parent 606ae5e commit 2ba02c0

File tree

11 files changed

+144
-97
lines changed

11 files changed

+144
-97
lines changed

External/Plugins/FlashDebugger/Controls/DataTipForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public void SetVariable(Variable variable)
4747
DataTree.Nodes.Clear();
4848
DataTree.AddNode(new VariableNode(variable)
4949
{
50-
HideClassId = DataTree.HideObjectIds,
51-
HideFullClasspath = DataTree.HideFullClasspaths
50+
HideClassId = PluginMain.settingObject.HideClassIds,
51+
HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
5252
});
5353
DoResize();
5454
}

External/Plugins/FlashDebugger/Controls/DataTreeControl.cs

Lines changed: 68 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,10 @@ 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, copyValueMenuItem, copyIdMenuItem, copyTreeMenuItem;
24+
private ToolStripMenuItem copyMenuItem, viewerMenuItem, watchMenuItem, copyValueMenuItem, copyIdMenuItem;
2525
private DataTreeState state;
2626
private bool watchMode;
2727
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;
3428

3529
public Collection<Node> Nodes
3630
{
@@ -47,72 +41,6 @@ public ViewerForm Viewer
4741
get { return viewerForm; }
4842
}
4943

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-
11644
public DataTreeControl()
11745
: this(false)
11846
{
@@ -161,14 +89,12 @@ public DataTreeControl(bool watchMode)
16189
NameTreeColumn.Header = TextHelper.GetString("Label.Name");
16290
ValueTreeColumn.Header = TextHelper.GetString("Label.Value");
16391
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);
16794
viewerMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Viewer"), null, ViewerItemClick);
16895
_contextMenuStrip.Items.AddRange(new ToolStripItem[]
16996
{
170-
copyMenuItem, copyIdMenuItem, copyValueMenuItem, copyTreeMenuItem,
171-
viewerMenuItem
97+
copyMenuItem, copyIdMenuItem, copyValueMenuItem, viewerMenuItem
17298
});
17399
if (watchMode)
174100
watchMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Unwatch"), null, WatchItemClick);
@@ -178,6 +104,10 @@ public DataTreeControl(bool watchMode)
178104
_contextMenuStrip.Opening += ContextMenuStrip_Opening;
179105
viewerForm = new ViewerForm();
180106
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;
181111
}
182112

183113
void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
@@ -190,7 +120,51 @@ void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventAr
190120
if (watchMode) watchMenuItem.Enabled = (enabled && Tree.SelectedNode.Level == 1 && Tree.SelectedNode.NextNode != null);
191121

192122
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();
194168
}
195169

196170
void NameNodeTextBox_DrawText(object sender, DrawEventArgs e)
@@ -440,8 +414,8 @@ public void ListChildItems(ValueNode node)
440414
{
441415
VariableNode memberNode = new VariableNode(member)
442416
{
443-
HideClassId = HideObjectIds,
444-
HideFullClasspath = HideFullClasspaths
417+
HideClassId = PluginMain.settingObject.HideClassIds,
418+
HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
445419
};
446420

447421
if (member.isAttributeSet(VariableAttribute_.IS_STATIC))
@@ -461,7 +435,7 @@ public void ListChildItems(ValueNode node)
461435
// inherited vars
462436
if (inherited.Count > 0)
463437
{
464-
if (_combineInherited)
438+
if (PluginMain.settingObject.CombineInherited)
465439
{
466440
// list inherited alongside main class members
467441
foreach (DataNode item in inherited)
@@ -485,7 +459,7 @@ public void ListChildItems(ValueNode node)
485459
}
486460

487461
// static vars
488-
if (!_hideStaticInObjects && statics.Count > 0)
462+
if (!PluginMain.settingObject.HideStaticMembers && statics.Count > 0)
489463
{
490464
DataNode staticNode = new ValueNode("[static]");
491465
statics.Sort();
@@ -515,8 +489,8 @@ public void ListChildItems(ValueNode node)
515489
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());
516490
DataNode childNode = new VariableNode((Variable) obj)
517491
{
518-
HideClassId = HideObjectIds,
519-
HideFullClasspath = HideFullClasspaths
492+
HideClassId = PluginMain.settingObject.HideClassIds,
493+
HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
520494
};
521495
childNode.Text = "child_" + i;
522496
childrenNode.Nodes.Add(childNode);
@@ -554,7 +528,7 @@ public void ListChildItems(ValueNode node)
554528
}
555529
//test children
556530
nodes.Sort();
557-
531+
558532
// add child items
559533
_tree.BeginUpdate();
560534
foreach (DataNode item in nodes)
@@ -725,13 +699,17 @@ private void CopyItemIdClick(Object sender, System.EventArgs e)
725699

726700
private void CopyItemTreeClick(Object sender, System.EventArgs e)
727701
{
728-
CopyTreeInternal(0);
702+
string exporterKey = (string) ((ToolStripItem) sender).Tag;
703+
CopyTreeInternal(exporterKey, 0);
729704
}
730705

731-
private void CopyTreeInternal(int levelLimit)
706+
private void CopyTreeInternal(string exporterKey, int levelLimit)
732707
{
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));
735713
}
736714

737715
#endregion

External/Plugins/FlashDebugger/Controls/LocalsUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public void SetData(Variable[] variables)
5252
{
5353
treeControl.AddNode(new VariableNode(item)
5454
{
55-
HideClassId = treeControl.HideObjectIds,
56-
HideFullClasspath = treeControl.HideFullClasspaths
55+
HideClassId = PluginMain.settingObject.HideClassIds,
56+
HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
5757
});
5858
}
5959
}

External/Plugins/FlashDebugger/Controls/WatchUI.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,17 @@ private DataNode GetExpressionNode(string item)
103103
var ctx = new ExpressionContext(PluginMain.debugManager.FlashInterface.Session, PluginMain.debugManager.FlashInterface.GetFrames()[PluginMain.debugManager.CurrentFrame]);
104104
var obj = exp.evaluate(ctx);
105105
if (obj is Variable)
106-
node = new VariableNode((Variable)obj);
106+
node = new VariableNode((Variable)obj)
107+
{
108+
HideClassId = PluginMain.settingObject.HideClassIds,
109+
HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
110+
};
107111
else if (obj is Value)
108-
node = new ValueNode(item, (Value)obj);
112+
node = new ValueNode(item, (Value) obj)
113+
{
114+
HideClassId = PluginMain.settingObject.HideClassIds,
115+
HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
116+
};
109117
else
110118
node = new ScalarNode(item, obj.toString());
111119
node.Tag = item;

External/Plugins/FlashDebugger/FlashDebugger.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<Compile Include="Debugger\ExpressionContext.cs" />
149149
<Compile Include="Debugger\FlashInterface.cs" />
150150
<Compile Include="Debugger\VariableFacade.cs" />
151+
<Compile Include="Helpers\DataTreeExporterFactory.cs" />
151152
<Compile Include="Helpers\DefaultDataTreeExporter.cs" />
152153
<Compile Include="Helpers\IDataTreeExporter.cs" />
153154
<Compile Include="Helpers\MenusHelper.cs" />

External/Plugins/FlashDebugger/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public bool HideStaticMembers
191191
[LocalizedCategory("FlashDebugger.Category.DataTree")]
192192
[LocalizedDescription("FlashDebugger.Description.HideFullClasspaths")]
193193
[DefaultValue(false)]
194-
public bool ShowFullClasspaths
194+
public bool HideFullClasspaths
195195
{
196196
get { return m_HideFullClassPaths; }
197197
set

PluginCore/PluginCore/Resources/de_DE.resX

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5932,6 +5932,18 @@ Eigene Sprachumgebungen müssen eine Erweiterung der Standard-Sprachumgebung sei
59325932
<value>The approximate maximum size, in characters, the object tree may take when copied to the clipboard.</value>
59335933
<comment>Added after 4.7.2</comment>
59345934
</data>
5935+
<data name="FlashDebugger.Label.CopyValue" xml:space="preserve">
5936+
<value>Copy Value</value>
5937+
<comment>Added after 4.7.2</comment>
5938+
</data>
5939+
<data name="FlashDebugger.Label.CopyID" xml:space="preserve">
5940+
<value>Copy ID</value>
5941+
<comment>Added after 4.7.2</comment>
5942+
</data>
5943+
<data name="FlashDebugger.Label.CopyTree" xml:space="preserve">
5944+
<value>Copy Tree</value>
5945+
<comment>Added after 4.7.2</comment>
5946+
</data>
59355947
<data name="FlashDebugger.TreeExporter.MaxDepthReached" xml:space="preserve">
59365948
<value>[Recursion too deep, increase Copy Tree Max Level in FlashDebugger settings]</value>
59375949
<comment>Added after 4.7.2</comment>

PluginCore/PluginCore/Resources/en_US.resX

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5945,6 +5945,18 @@ Custom locales must be an extension of a default locale, e.g. en-US.</value>
59455945
<value>The approximate maximum size, in characters, the object tree may take when copied to the clipboard.</value>
59465946
<comment>Added after 4.7.2</comment>
59475947
</data>
5948+
<data name="FlashDebugger.Label.CopyValue" xml:space="preserve">
5949+
<value>Copy Value</value>
5950+
<comment>Added after 4.7.2</comment>
5951+
</data>
5952+
<data name="FlashDebugger.Label.CopyID" xml:space="preserve">
5953+
<value>Copy ID</value>
5954+
<comment>Added after 4.7.2</comment>
5955+
</data>
5956+
<data name="FlashDebugger.Label.CopyTree" xml:space="preserve">
5957+
<value>Copy Tree</value>
5958+
<comment>Added after 4.7.2</comment>
5959+
</data>
59485960
<data name="FlashDebugger.TreeExporter.MaxDepthReached" xml:space="preserve">
59495961
<value>[Recursion too deep, increase Copy Tree Max Level in FlashDebugger settings]</value>
59505962
<comment>Added after 4.7.2</comment>

PluginCore/PluginCore/Resources/eu_ES.resX

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5929,6 +5929,18 @@ Lokalizazio pertsonalizatuek lehenetsiaren luzapen bat izan behar dute, adb. en-
59295929
<value>The approximate maximum size, in characters, the object tree may take when copied to the clipboard.</value>
59305930
<comment>Added after 4.7.2</comment>
59315931
</data>
5932+
<data name="FlashDebugger.Label.CopyValue" xml:space="preserve">
5933+
<value>Copy Value</value>
5934+
<comment>Added after 4.7.2</comment>
5935+
</data>
5936+
<data name="FlashDebugger.Label.CopyID" xml:space="preserve">
5937+
<value>Copy ID</value>
5938+
<comment>Added after 4.7.2</comment>
5939+
</data>
5940+
<data name="FlashDebugger.Label.CopyTree" xml:space="preserve">
5941+
<value>Copy Tree</value>
5942+
<comment>Added after 4.7.2</comment>
5943+
</data>
59325944
<data name="FlashDebugger.TreeExporter.MaxDepthReached" xml:space="preserve">
59335945
<value>[Recursion too deep, increase Copy Tree Max Level in FlashDebugger settings]</value>
59345946
<comment>Added after 4.7.2</comment>

PluginCore/PluginCore/Resources/ja_JP.resX

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5994,6 +5994,18 @@ UseData:"</value>
59945994
<value>The approximate maximum size, in characters, the object tree may take when copied to the clipboard.</value>
59955995
<comment>Added after 4.7.2</comment>
59965996
</data>
5997+
<data name="FlashDebugger.Label.CopyValue" xml:space="preserve">
5998+
<value>Copy Value</value>
5999+
<comment>Added after 4.7.2</comment>
6000+
</data>
6001+
<data name="FlashDebugger.Label.CopyID" xml:space="preserve">
6002+
<value>Copy ID</value>
6003+
<comment>Added after 4.7.2</comment>
6004+
</data>
6005+
<data name="FlashDebugger.Label.CopyTree" xml:space="preserve">
6006+
<value>Copy Tree</value>
6007+
<comment>Added after 4.7.2</comment>
6008+
</data>
59976009
<data name="FlashDebugger.TreeExporter.MaxDepthReached" xml:space="preserve">
59986010
<value>[Recursion too deep, increase Copy Tree Max Level in FlashDebugger settings]</value>
59996011
<comment>Added after 4.7.2</comment>

0 commit comments

Comments
 (0)