Skip to content

Commit

Permalink
Bug fixes - group naming & table visibility (#72)
Browse files Browse the repository at this point in the history
* bugs fixed

- retain group prefix when nodes move between state groups.
- hide table labels when collections are empty.

* xml summary
  • Loading branch information
ivaylo-matov authored Oct 25, 2024
1 parent 41f5113 commit 041d190
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
22 changes: 18 additions & 4 deletions TuneUp/ProfiledNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ public string Name
}
else if (GroupModel != null)
{
return GroupModel.AnnotationText == DefaultGroupName ?
$"{GroupNodePrefix}{DefaultDisplayGroupName}" : GroupModel.AnnotationText;
return GetProfiledGroupName(GroupModel.AnnotationText);
}
}
return name;
}
internal set { name = value; }
internal set
{
name = value;
RaisePropertyChanged(nameof(Name));
}
}

/// <summary>
Expand Down Expand Up @@ -421,7 +424,7 @@ public ProfiledNodeViewModel(AnnotationModel group)
/// <param name="group">the annotation model</param>
public ProfiledNodeViewModel(ProfiledNodeViewModel pNode)
{
Name = pNode.GroupName == DefaultGroupName ? DefaultDisplayGroupName : pNode.GroupName;
Name = GetProfiledGroupName(pNode.GroupName);
GroupName = pNode.GroupName;
State = pNode.State;
NodeGUID = Guid.NewGuid();
Expand All @@ -430,5 +433,16 @@ public ProfiledNodeViewModel(ProfiledNodeViewModel pNode)
BackgroundBrush = pNode.BackgroundBrush;
ShowGroupIndicator = true;
}

/// <summary>
/// Returns the formatted profiled group name with the group prefix.
/// Uses a default display name if the group name matches the default.
/// </summary>
public static string GetProfiledGroupName(string groupName)
{
return groupName == DefaultGroupName
? $"{GroupNodePrefix}{DefaultDisplayGroupName}"
: $"{GroupNodePrefix}{groupName}";
}
}
}
23 changes: 15 additions & 8 deletions TuneUp/TuneUpWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,7 @@ internal void ResetProfiledNodes()
ApplyGroupNodeFilter();

// Ensure table visibility is updated in case TuneUp was closed and reopened with the same graph.
RaisePropertyChanged(nameof(LatestRunTableVisibility));
RaisePropertyChanged(nameof(PreviousRunTableVisibility));
RaisePropertyChanged(nameof(NotExecutedTableVisibility));
UpdateTableVisibility();
}

/// <summary>
Expand Down Expand Up @@ -453,10 +451,7 @@ private void CurrentWorkspaceModel_EvaluationCompleted(object sender, Dynamo.Mod

CalculateGroupNodes();
UpdateExecutionTime();

RaisePropertyChanged(nameof(LatestRunTableVisibility));
RaisePropertyChanged(nameof(PreviousRunTableVisibility));
RaisePropertyChanged(nameof(NotExecutedTableVisibility));
UpdateTableVisibility();

RaisePropertyChanged(nameof(ProfiledNodesCollectionLatestRun));
RaisePropertyChanged(nameof(ProfiledNodesCollectionPreviousRun));
Expand Down Expand Up @@ -701,7 +696,7 @@ internal void OnGroupPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (pNode.IsGroup)
{
pNode.Name = $"{ProfiledNodeViewModel.GroupNodePrefix}{groupModel.AnnotationText}";
pNode.Name = ProfiledNodeViewModel.GetProfiledGroupName(groupModel.AnnotationText);
}
pNode.GroupName = groupModel.AnnotationText;
}
Expand Down Expand Up @@ -889,6 +884,7 @@ private void CurrentWorkspaceModel_NodeRemoved(NodeModel node)

//Recalculate the execution times
UpdateExecutionTime();
UpdateTableVisibility();
}

private void CurrentWorkspaceModel_GroupAdded(AnnotationModel group)
Expand Down Expand Up @@ -1003,6 +999,7 @@ private void CurrentWorkspaceModel_GroupRemoved(AnnotationModel group)
}

RefreshAllCollectionViews();
UpdateTableVisibility();
}

private void OnCurrentWorkspaceChanged(IWorkspaceModel workspace)
Expand All @@ -1023,6 +1020,16 @@ private void OnCurrentWorkspaceCleared(IWorkspaceModel workspace)

#region Helpers

/// <summary>
/// Raises property change notifications for the visibility of the Latest Run, Previous Run, and Not Executed tables.
/// </summary>
private void UpdateTableVisibility()
{
RaisePropertyChanged(nameof(LatestRunTableVisibility));
RaisePropertyChanged(nameof(PreviousRunTableVisibility));
RaisePropertyChanged(nameof(NotExecutedTableVisibility));
}

/// <summary>
/// Resets group-related properties of the node and unregisters it from the group model dictionary.
/// </summary>
Expand Down

0 comments on commit 041d190

Please sign in to comment.