in BismNormalizer/BismNormalizer/TabularCompare/UI/TreeGridViewComparison.cs [182:381]
private void PopulateNode(TreeGridNode node, ComparisonObject comparisonObject)
{
switch (comparisonObject.Status)
{
case ComparisonObjectStatus.MissingInTarget:
node.Cells[3].Value = ">";
node.Cells[4].Value = "Missing in Target";
node.Cells[5].Style.BackColor = Color.LightGray;
node.Cells[6].Style.BackColor = Color.LightGray;
break;
case ComparisonObjectStatus.MissingInSource:
node.Cells[1].Style.BackColor = Color.LightGray;
node.Cells[2].Style.BackColor = Color.LightGray;
node.Cells[3].Value = "<";
node.Cells[4].Value = "Missing in Source";
break;
case ComparisonObjectStatus.SameDefinition:
node.Cells[3].Value = "=";
node.Cells[4].Value = "Same Definition";
break;
case ComparisonObjectStatus.DifferentDefinitions:
node.Cells[3].Value = "≠";
node.Cells[4].Value = "Different Definitions";
break;
default:
break;
}
node.Cells[1].Value = comparisonObject.SourceObjectName;
node.Cells[2].Value = comparisonObject.SourceObjectInternalName;
//node.Cells[8].Value = comparisonObject.MergeAction.ToString(); //set below instead
node.Cells[9].Value = comparisonObject.ComparisonObjectType.ToString();
node.Cells[5].Value = comparisonObject.TargetObjectName;
node.Cells[6].Value = comparisonObject.TargetObjectInternalName;
node.Cells[10].Value = comparisonObject.SourceObjectDefinition;
node.Cells[11].Value = comparisonObject.TargetObjectDefinition;
bool isMdMetadata = (comparisonObject is MultidimensionalMetadata.ComparisonObject);
string treeIndentLevel1 = new String(' ', 13);
string treeIndentLevel2 = new String(' ', 20);
string treeIndentLevel3 = new String(' ', 27);
switch (comparisonObject.ComparisonObjectType)
{
// Tabular objecs
case ComparisonObjectType.Model:
node.ImageIndex = 25;
node.Cells[0].Value = treeIndentLevel1 + "Model";
break;
case ComparisonObjectType.DataSource:
node.ImageIndex = 0;
node.Cells[0].Value = treeIndentLevel1 + "Data Source";
break;
case ComparisonObjectType.Table:
if (comparisonObject.ComparisonObjectType == ComparisonObjectType.Table &&
(
(comparisonObject.Status != ComparisonObjectStatus.MissingInSource && comparisonObject.SourceObjectDefinition.Contains("\"calculationGroup\":")) ||
(comparisonObject.Status == ComparisonObjectStatus.MissingInSource && comparisonObject.TargetObjectDefinition.Contains("\"calculationGroup\":"))
))
{
node.ImageIndex = 23;
node.Cells[0].Value = treeIndentLevel1 + "Calculation Group";
}
else
{
node.ImageIndex = 1;
node.Cells[0].Value = (isMdMetadata ? treeIndentLevel2 : treeIndentLevel1) + "Table";
}
break;
case ComparisonObjectType.Relationship:
node.ImageIndex = 2;
node.Cells[0].Value = (isMdMetadata ? treeIndentLevel3 : treeIndentLevel2) + "Relationship";
break;
case ComparisonObjectType.Measure:
node.ImageIndex = 3;
node.Cells[0].Value = (isMdMetadata ? treeIndentLevel3 : treeIndentLevel2) + "Measure";
break;
case ComparisonObjectType.Kpi:
node.ImageIndex = 4;
node.Cells[0].Value = (isMdMetadata ? treeIndentLevel3 : treeIndentLevel2) + "KPI";
break;
case ComparisonObjectType.CalculationItem:
node.ImageIndex = 24;
node.Cells[0].Value = treeIndentLevel2 + "Calculation Item";
break;
case ComparisonObjectType.Expression:
node.ImageIndex = 22;
node.Cells[0].Value = treeIndentLevel1 + "Expression";
break;
case ComparisonObjectType.Perspective:
node.ImageIndex = 15;
node.Cells[0].Value = treeIndentLevel1 + "Perspective";
break;
case ComparisonObjectType.Culture:
node.ImageIndex = 21;
node.Cells[0].Value = treeIndentLevel1 + "Culture";
break;
case ComparisonObjectType.Role:
node.ImageIndex = 14;
node.Cells[0].Value = treeIndentLevel1 + "Role";
break;
case ComparisonObjectType.Action:
node.ImageIndex = 16;
node.Cells[0].Value = treeIndentLevel1 + "Action";
break;
default:
break;
};
DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)node.Cells[8];
DataGridViewCell parentMergeActionCell = node.Parent.Cells[8];
DataGridViewCell parentStatusCell = node.Parent.Cells[4];
// set drop-down to have limited members based on what is available
switch (comparisonObject.MergeAction)
{
case MergeAction.Create:
node.Cells[7].Value = this.ImageList.Images[7]; //7: Create
node.Cells[8].Value = comparisonObject.MergeAction.ToString();
comboCell.DataSource = new string[] { "Create", "Skip" };
if (parentStatusCell.Value != null && parentMergeActionCell.Value != null &&
parentStatusCell.Value.ToString() == "Missing in Target" && parentMergeActionCell.Value.ToString() == "Skip")
{
// Can only happen if loading from file
node.Cells[7].Value = this.ImageList.Images[19]; //19: Skip Gray
node.Cells[8].Value = MergeAction.Skip.ToString();
node.Cells[8].Style.ForeColor = Color.DimGray;
node.Cells[8].ReadOnly = true;
SetNodeTooltip(node, true);
}
break;
case MergeAction.Update:
node.Cells[7].Value = this.ImageList.Images[6]; //6: Update
node.Cells[8].Value = comparisonObject.MergeAction.ToString();
comboCell.DataSource = new string[] { "Update", "Skip" };
break;
case MergeAction.Delete:
node.Cells[7].Value = this.ImageList.Images[5]; //5: Delete
node.Cells[8].Value = comparisonObject.MergeAction.ToString();
comboCell.DataSource = new string[] { "Delete", "Skip" };
//check if parent is also set to delete, in which case make this cell readonly
if (parentMergeActionCell.Value != null && parentMergeActionCell.Value.ToString() == "Delete")
{
node.Cells[7].Value = this.ImageList.Images[18]; //18: Delete Gray
node.Cells[8].Style.ForeColor = Color.DimGray;
node.Cells[8].ReadOnly = true;
SetNodeTooltip(node, true);
}
break;
case MergeAction.Skip:
node.Cells[7].Value = this.ImageList.Images[8]; //8: Skip
node.Cells[8].Value = comparisonObject.MergeAction.ToString();
switch (comparisonObject.Status)
{
case ComparisonObjectStatus.MissingInTarget:
comboCell.DataSource = new string[] { "Create", "Skip" };
//check if parent is also MissingInTarget and Skip, make this cell readonly
if (parentStatusCell.Value != null && parentMergeActionCell.Value != null &&
parentStatusCell.Value.ToString() == "Missing in Target" && parentMergeActionCell.Value.ToString() == "Skip")
{
node.Cells[7].Value = this.ImageList.Images[19]; //19: Skip Gray
node.Cells[8].Style.ForeColor = Color.DimGray;
node.Cells[8].ReadOnly = true;
SetNodeTooltip(node, true);
}
break;
case ComparisonObjectStatus.MissingInSource:
comboCell.DataSource = new string[] { "Delete", "Skip" };
break;
case ComparisonObjectStatus.DifferentDefinitions:
comboCell.DataSource = new string[] { "Update", "Skip" };
break;
default:
//default covers ComparisonObjectStatus.SameDefinition: which is most common case (above cases are for saved skip selections from file)
node.Cells[7].Value = this.ImageList.Images[19]; //19: Skip Gray
comboCell.DataSource = new string[] { "Skip" };
node.Cells[8].Style.ForeColor = Color.DimGray;
node.Cells[8].ReadOnly = true;
break;
}
break;
default:
break;
};
if (comparisonObject.ChildComparisonObjects != null && comparisonObject.ChildComparisonObjects.Count > 0)
{
foreach (ComparisonObject childComparisonObject in comparisonObject.ChildComparisonObjects)
{
TreeGridNode childNode = node.Nodes.Add();
PopulateNode(childNode, childComparisonObject);
//node.Expand(); //for inexplicable reason, keeps erroring on this line as though the node doesn't belong to the grid, but it does because its parent does. So instead will iterate all nodes once fully populate to expand.
}
}
}