Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes - group naming & table visibility #72

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions TuneUp/ProfiledNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,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 @@ -420,7 +423,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 @@ -429,5 +432,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 @@ -360,9 +360,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 @@ -451,10 +449,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 @@ -699,7 +694,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 @@ -887,6 +882,7 @@ private void CurrentWorkspaceModel_NodeRemoved(NodeModel node)

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

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

RefreshAllCollectionViews();
UpdateTableVisibility();
}

private void OnCurrentWorkspaceChanged(IWorkspaceModel workspace)
Expand All @@ -1021,6 +1018,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