Fixing faulty showInTooltip logic and adding prop display value for Query Plan (#1401)

* Fixing faulty showInTooltip logic

* Renaming one prop appropriately

* Fixing prop function

* Fixed PR related comments

* Fixing stuff

* Logging errors now
This commit is contained in:
Aasim Khan
2022-02-09 22:54:17 -08:00
committed by GitHub
parent cf959b3278
commit 00c2fdbe99
3 changed files with 50 additions and 6 deletions

View File

@@ -87,9 +87,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ShowPlan
/// </summary>
public int DisplayOrder { get; set; }
/// <summary>
/// Flag to indicate if the property has a longer value so that it will be shown at the bottom of the tooltip
/// Flag to show property at the bottom of tooltip. Generally done for for properties with longer value.
/// </summary>
public bool IsLongString { get; set; }
public bool PositionAtBottom { get; set; }
/// <summary>
/// Value to be displayed in UI like tooltips and properties View
/// </summary>
/// <value></value>
public string DisplayValue { get; set; }
}
public class NestedExecutionPlanGraphProperty : ExecutionPlanGraphPropertyBase

View File

@@ -49,6 +49,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ShowPlan.ShowPlanGraph
}
}
public bool ShowInTooltip
{
get
{
return this.showInTooltip;
}
}
public bool IsLongString
{
get
@@ -189,6 +197,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ShowPlan.ShowPlanGraph
if (showInToolTipAttribute != null)
{
this.isLongString = showInToolTipAttribute.LongString;
this.showInTooltip = showInToolTipAttribute.Value;
} else
{
this.showInTooltip = false;
}
}
@@ -203,6 +215,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ShowPlan.ShowPlanGraph
private PropertyDescriptor baseProperty;
private bool isLongString;
private bool initialized;
private bool showInTooltip;
#endregion

View File

@@ -8,6 +8,8 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Microsoft.SqlTools.ServiceLayer.ShowPlan.ShowPlanGraph;
using Microsoft.SqlTools.Utility;
using System.Diagnostics;
namespace Microsoft.SqlTools.ServiceLayer.ShowPlan
{
@@ -70,9 +72,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ShowPlan
{
Name = prop.DisplayName,
Value = propertyValue,
ShowInTooltip = prop.IsBrowsable,
ShowInTooltip = prop.ShowInTooltip,
DisplayOrder = prop.DisplayOrder,
IsLongString = prop.IsLongString,
PositionAtBottom = prop.IsLongString,
DisplayValue = GetPropertyDisplayValue(prop)
});
}
else
@@ -82,9 +85,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ShowPlan
{
Name = prop.DisplayName,
Value = propertyValue,
ShowInTooltip = prop.IsBrowsable,
ShowInTooltip = prop.ShowInTooltip,
DisplayOrder = prop.DisplayOrder,
IsLongString = prop.IsLongString,
PositionAtBottom = prop.IsLongString,
DisplayValue = GetPropertyDisplayValue(prop)
});
}
@@ -122,5 +126,27 @@ GO
*/
";
}
private static string GetPropertyDisplayValue(PropertyValue property)
{
try
{
// Get the property value.
object propertyValue = property.GetValue(property.Value);
if (propertyValue == null)
{
return String.Empty;
}
// Convert the property value to the text.
return property.Converter.ConvertToString(propertyValue).Trim();
}
catch (Exception e)
{
Logger.Write(TraceEventType.Error, e.ToString());
return String.Empty;
}
}
}
}