mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Add modifiable sort priority to OE nodes (#1627)
* modifiable sort priority, dropped ledger folders sorted to the bottom * reorganizing dropped table and view objects in OE integration test * update to Int32
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
|
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -11,8 +11,8 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection class for <see cref="TreeNode"/>
|
/// A collection class for <see cref="TreeNode"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class NodeObservableCollection : ObservableCollection<TreeNode>
|
public sealed class NodeObservableCollection : ObservableCollection<TreeNode>
|
||||||
{
|
{
|
||||||
@@ -30,13 +30,17 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
|||||||
get { return numInits.HasValue && numInits != 0; }
|
get { return numInits.HasValue && numInits != 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSorted
|
public bool IsSorted
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// SMO objects are already sorted so no need to sort them again
|
// SMO objects are already sorted so no need to sort them again, unless they have dropped folders
|
||||||
return this.FirstOrDefault() is SmoTreeNode;
|
bool anyDroppedFolders = this.Any(
|
||||||
}
|
node => node is FolderNode &&
|
||||||
|
(node.NodeTypeId == NodeTypes.DroppedLedgerTables ||
|
||||||
|
node.NodeTypeId == NodeTypes.DroppedLedgerViews));
|
||||||
|
return this.FirstOrDefault() is SmoTreeNode && !anyDroppedFolders;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginInit()
|
public void BeginInit()
|
||||||
@@ -64,9 +68,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!IsSorted)
|
if (!IsSorted)
|
||||||
{
|
{
|
||||||
DoSort();
|
DoSort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deferredChildren != null)
|
if (deferredChildren != null)
|
||||||
|
|||||||
@@ -413,23 +413,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
|||||||
return CompareSamePriorities(this, other);
|
return CompareSamePriorities(this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.SortPriority.HasValue &&
|
// Higher SortPriority = lower in the list. A couple nodes are defined with SortPriority of Int16.MaxValue
|
||||||
!other.SortPriority.HasValue)
|
// so they're placed at the bottom of the node list (Dropped Ledger Tables and Dropped Ledger Views folders)
|
||||||
{
|
// Individual objects, like tables and views, don't have a SortPriority defined, so their values need
|
||||||
return -1; // this is above other
|
// to be resolved. If a node doesn't have a SortPriority, set it to the second-highest value.
|
||||||
}
|
int thisPriority = this.SortPriority ?? Int32.MaxValue - 1;
|
||||||
if (!this.SortPriority.HasValue)
|
int otherPriority = other.SortPriority ?? Int32.MaxValue - 1;
|
||||||
{
|
|
||||||
return 1; // this is below other
|
|
||||||
}
|
|
||||||
|
|
||||||
// Both have sort priority
|
// diff > 0 == this below other
|
||||||
int priDiff = this.SortPriority.Value - other.SortPriority.Value;
|
// diff < 0 == other below this
|
||||||
if (priDiff < 0)
|
return thisPriority - otherPriority;
|
||||||
return -1; // this is below other
|
|
||||||
if (priDiff == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -858,7 +858,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
NodeTypeId = NodeTypes.DroppedLedgerTables,
|
NodeTypeId = NodeTypes.DroppedLedgerTables,
|
||||||
IsSystemObject = false,
|
IsSystemObject = false,
|
||||||
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||||
SortPriority = SmoTreeNode.NextSortPriority,
|
SortPriority = Int32.MaxValue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,7 +922,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
NodeTypeId = NodeTypes.DroppedLedgerViews,
|
NodeTypeId = NodeTypes.DroppedLedgerViews,
|
||||||
IsSystemObject = false,
|
IsSystemObject = false,
|
||||||
IsMsShippedOwned = true,
|
IsMsShippedOwned = true,
|
||||||
SortPriority = SmoTreeNode.NextSortPriority,
|
SortPriority = Int32.MaxValue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,7 +241,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
WriteLine(" {");
|
WriteLine(" {");
|
||||||
foreach (var child in children)
|
foreach (var child in children)
|
||||||
{
|
{
|
||||||
XmlElement childAsXmlElement = GetNodeElement(xmlFile, child.GetAttribute("Name"));
|
var childName = child.GetAttribute("Name");
|
||||||
|
|
||||||
|
XmlElement childAsXmlElement = GetNodeElement(xmlFile, childName);
|
||||||
if (childAsXmlElement == null)
|
if (childAsXmlElement == null)
|
||||||
{
|
{
|
||||||
// TODO SHould we error with clear message that this needs to be fixed?
|
// TODO SHould we error with clear message that this needs to be fixed?
|
||||||
@@ -251,16 +253,22 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
var msShippedOwned = childAsXmlElement.GetAttributeNode("IsMsShippedOwned");
|
var msShippedOwned = childAsXmlElement.GetAttributeNode("IsMsShippedOwned");
|
||||||
var validFor = childAsXmlElement.GetAttribute("ValidFor");
|
var validFor = childAsXmlElement.GetAttribute("ValidFor");
|
||||||
|
|
||||||
if (TreeNodeExists(xmlFile, child.GetAttribute("Name") + "TreeNode"))
|
var sortPriority = childAsXmlElement.GetAttribute("SortPriority");
|
||||||
|
if (sortPriority == string.Empty)
|
||||||
{
|
{
|
||||||
WriteLine(" currentChildren.Add(new {0}TreeNode {{ SortPriority = SmoTreeNode.NextSortPriority }} );", child.GetAttribute("Name"));
|
sortPriority = "SmoTreeNode.NextSortPriority";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TreeNodeExists(xmlFile, childName + "TreeNode"))
|
||||||
|
{
|
||||||
|
WriteLine(" currentChildren.Add(new {0}TreeNode {{ SortPriority = {1} }} );", childName, sortPriority);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteLine(" currentChildren.Add(new FolderNode {");
|
WriteLine(" currentChildren.Add(new FolderNode {");
|
||||||
WriteLine(" NodeValue = {0},", childAsXmlElement.GetAttribute("LocLabel"));
|
WriteLine(" NodeValue = {0},", childAsXmlElement.GetAttribute("LocLabel"));
|
||||||
WriteLine(" NodeType = \"{0}\",", "Folder");
|
WriteLine(" NodeType = \"{0}\",", "Folder");
|
||||||
WriteLine(" NodeTypeId = NodeTypes.{0},", child.GetAttribute("Name"));
|
WriteLine(" NodeTypeId = NodeTypes.{0},", childName);
|
||||||
WriteLine(" IsSystemObject = {0},", child.GetAttribute("IsSystemObject") == "1" ? "true" : "false");
|
WriteLine(" IsSystemObject = {0},", child.GetAttribute("IsSystemObject") == "1" ? "true" : "false");
|
||||||
|
|
||||||
if (msShippedOwned != null)
|
if (msShippedOwned != null)
|
||||||
@@ -271,7 +279,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
WriteLine(" ValidFor = {0},", GetValidForFlags(validFor));
|
WriteLine(" ValidFor = {0},", GetValidForFlags(validFor));
|
||||||
}
|
}
|
||||||
WriteLine(" SortPriority = SmoTreeNode.NextSortPriority,");
|
WriteLine(" SortPriority = {0},", sortPriority);
|
||||||
WriteLine(" });");
|
WriteLine(" });");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@
|
|||||||
<Filter Property="IsSystemObject" Value="1" Type="bool" />
|
<Filter Property="IsSystemObject" Value="1" Type="bool" />
|
||||||
</Filters>
|
</Filters>
|
||||||
</Node>
|
</Node>
|
||||||
<Node Name="DroppedLedgerTables" LocLabel="SR.SchemaHierarchy_DroppedLedgerTables" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlTable" TreeNode="TableTreeNode" ValidFor="Sql2022|AzureV12">
|
<Node Name="DroppedLedgerTables" LocLabel="SR.SchemaHierarchy_DroppedLedgerTables" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlTable" TreeNode="TableTreeNode" ValidFor="Sql2022|AzureV12" SortPriority="Int32.MaxValue">
|
||||||
<Filters >
|
<Filters >
|
||||||
<Filter Property="IsDroppedLedgerTable" Value="1" Type="bool" />
|
<Filter Property="IsDroppedLedgerTable" Value="1" Type="bool" />
|
||||||
</Filters>
|
</Filters>
|
||||||
@@ -251,7 +251,7 @@
|
|||||||
</Filters>
|
</Filters>
|
||||||
</Node>
|
</Node>
|
||||||
|
|
||||||
<Node Name="DroppedLedgerViews" LocLabel="SR.SchemaHierarchy_DroppedLedgerViews" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode">
|
<Node Name="DroppedLedgerViews" LocLabel="SR.SchemaHierarchy_DroppedLedgerViews" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode" SortPriority="Int32.MaxValue">
|
||||||
<Filters>
|
<Filters>
|
||||||
<Filter Property="IsDroppedLedgerView" Value="1" Type="bool" ValidFor="Sql2022|AzureV12" />
|
<Filter Property="IsDroppedLedgerView" Value="1" Type="bool" ValidFor="Sql2022|AzureV12" />
|
||||||
</Filters>
|
</Filters>
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
NodeType: Table Label: HumanResources.MSSQL_DroppedLedgerTable_Ledger_For_Drop_<<NonDeterministic>> (Updatable Ledger) SubType:Ledger Status:
|
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
|
||||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
|
||||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_end_transaction_id (bigint, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_end_sequence_number (bigint, null) SubType: Status:
|
|
||||||
NodeType: HistoryTable Label: HumanResources.MSSQL_DroppedLedgerHistory_Ledger_For_Drop_History_<<NonDeterministic>> (History) SubType:LedgerHistory Status:
|
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
|
||||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
|
||||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_end_transaction_id (bigint, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_end_sequence_number (bigint, null) SubType: Status:
|
|
||||||
NodeType: Table Label: dbo.tableWithAllDataTypes SubType: Status:
|
NodeType: Table Label: dbo.tableWithAllDataTypes SubType: Status:
|
||||||
NodeType: Column Label: cDecimal (decimal(18,5), null) SubType: Status:
|
NodeType: Column Label: cDecimal (decimal(18,5), null) SubType: Status:
|
||||||
NodeType: Column Label: cNumeric (numeric(18,2), null) SubType: Status:
|
NodeType: Column Label: cNumeric (numeric(18,2), null) SubType: Status:
|
||||||
@@ -178,15 +160,24 @@ NodeType: Constraint Label: DF_Person_ModifiedDate SubType: Status:
|
|||||||
NodeType: Trigger Label: TableTrigger SubType: Status:
|
NodeType: Trigger Label: TableTrigger SubType: Status:
|
||||||
NodeType: Index Label: PK_Person_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status:
|
NodeType: Index Label: PK_Person_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status:
|
||||||
NodeType: Statistic Label: PK_Person_BusinessEntityID SubType: Status:
|
NodeType: Statistic Label: PK_Person_BusinessEntityID SubType: Status:
|
||||||
NodeType: View Label: HumanResources.MSSQL_DroppedLedgerView_Ledger_For_Drop_Ledger_<<NonDeterministic>> (Ledger) SubType:Ledger Status:
|
NodeType: Table Label: HumanResources.MSSQL_DroppedLedgerTable_Ledger_For_Drop_<<NonDeterministic>> (Updatable Ledger) SubType:Ledger Status:
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||||
NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status:
|
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
||||||
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
NodeType: Column Label: ledger_end_transaction_id (bigint, null) SubType: Status:
|
||||||
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
||||||
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
NodeType: Column Label: ledger_end_sequence_number (bigint, null) SubType: Status:
|
||||||
|
NodeType: HistoryTable Label: HumanResources.MSSQL_DroppedLedgerHistory_Ledger_For_Drop_History_<<NonDeterministic>> (History) SubType:LedgerHistory Status:
|
||||||
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
|
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||||
|
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_end_transaction_id (bigint, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_end_sequence_number (bigint, null) SubType: Status:
|
||||||
NodeType: View Label: HumanResources.Employee_Ledger_AppendOnly_Ledger (Ledger) SubType:Ledger Status:
|
NodeType: View Label: HumanResources.Employee_Ledger_AppendOnly_Ledger (Ledger) SubType:Ledger Status:
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
@@ -235,6 +226,15 @@ NodeType: Column Label: Suffix (nvarchar(10), null) SubType: Status:
|
|||||||
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
||||||
NodeType: Column Label: AdditionalContactInfo (AdditionalContactInfoSchemaCollection, null) SubType: Status:
|
NodeType: Column Label: AdditionalContactInfo (AdditionalContactInfoSchemaCollection, null) SubType: Status:
|
||||||
NodeType: Trigger Label: ViewTrigger SubType: Status:
|
NodeType: Trigger Label: ViewTrigger SubType: Status:
|
||||||
|
NodeType: View Label: HumanResources.MSSQL_DroppedLedgerView_Ledger_For_Drop_Ledger_<<NonDeterministic>> (Ledger) SubType:Ledger Status:
|
||||||
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
|
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||||
|
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
||||||
NodeType: Synonym Label: dbo.MyProduct SubType: Status:
|
NodeType: Synonym Label: dbo.MyProduct SubType: Status:
|
||||||
NodeType: StoredProcedure Label: dbo.uspGetList SubType: Status:
|
NodeType: StoredProcedure Label: dbo.uspGetList SubType: Status:
|
||||||
NodeType: StoredProcedureParameter Label: @Product (varchar, Input, No default) SubType:Input Status:
|
NodeType: StoredProcedureParameter Label: @Product (varchar, Input, No default) SubType:Input Status:
|
||||||
|
|||||||
Reference in New Issue
Block a user