Fixed node labels, status, sub types (#338)

This commit is contained in:
Leila Lali
2017-05-09 09:33:25 -07:00
committed by GitHub
parent 5b5c5861d8
commit 0d570fa29b
25 changed files with 1975 additions and 657 deletions

View File

@@ -4,6 +4,7 @@
//
using System.Collections.Generic;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
{
@@ -27,13 +28,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// </summary>
/// <param name="parent"></param>
/// <returns></returns>
public abstract IEnumerable<TreeNode> Expand(TreeNode parent);
public abstract IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh);
/// <summary>
/// The list of filters that should be applied on the smo object list
/// </summary>
public abstract IEnumerable<NodeFilter> Filters { get; }
/// <summary>
/// Returns the node sub type if the object can have sub types otehr wise returns empty string
/// </summary>
public abstract string GetNodeSubType(object context);
/// <summary>
/// Returns the status of the object assigned to node. If the object doesn't spport status returns empty string
/// </summary>
public abstract string GetNodeStatus(object context);
/// <summary>
/// Returns the custom name of the object assigned to the node. If the object doesn't have custom name, returns empty string
/// </summary>
public abstract string GetNodeCustomName(object smoObject, SmoQueryContext smoContext);
public abstract bool CanCreateChild(TreeNode parent, object context);
public abstract TreeNode CreateChild(TreeNode parent, object context);

View File

@@ -67,6 +67,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// </summary>
public NodeTypes NodeTypeId { get; set; }
/// <summary>
/// Node Sub type - for example a key can have type as "Key" and sub type as "PrimaryKey"
/// </summary>
public string NodeSubType { get; set; }
/// <summary>
/// Node status - for example login can be disabled/enabled
/// </summary>
public string NodeStatus { get; set; }
/// <summary>
/// Label to display to the user, describing this node.
/// If not explicitly set this will fall back to the <see cref="NodeValue"/> but
@@ -176,7 +186,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
Label = this.Label,
NodePath = this.GetNodePath(),
NodeType = this.NodeType,
Metadata = this.ObjectMetadata
Metadata = this.ObjectMetadata,
NodeStatus = this.NodeStatus,
NodeSubType = this.NodeSubType
};
}
@@ -191,7 +203,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
{
return children;
}
PopulateChildren();
PopulateChildren(false);
return children;
}
@@ -199,10 +211,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// Refresh this node and returns its children
/// </summary>
/// <returns>Children as an IList. This is the raw children collection, not a copy</returns>
public IList<TreeNode> Refresh()
public virtual IList<TreeNode> Refresh()
{
// TODO consider why solution explorer has separate Children and Items options
PopulateChildren();
PopulateChildren(true);
return children;
}
@@ -254,7 +266,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
return Parent as T;
}
protected void PopulateChildren()
protected void PopulateChildren(bool refresh)
{
Debug.Assert(IsAlwaysLeaf == false);
@@ -273,7 +285,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
{
foreach (var factory in childFactories)
{
IEnumerable<TreeNode> items = factory.Expand(this);
IEnumerable<TreeNode> items = factory.Expand(this, refresh);
if (items != null)
{
foreach (TreeNode item in items)