Skip to content

Commit

Permalink
Merge branch 'master' into test_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 authored Apr 25, 2024
2 parents bfb3891 + 50627dd commit 6b574dd
Show file tree
Hide file tree
Showing 21 changed files with 36,500 additions and 190 deletions.
4 changes: 4 additions & 0 deletions src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ internal ObservableHashSet<Info> Infos
get { return infos; }
}

/// <summary>
/// BlockInfoBubbleUpdates is flag used to block InfoBubble updates during (or immediately after) graph execution.
/// </summary>
internal bool BlockInfoBubbleUpdates = false;

/// <summary>
/// A publicly accessible collector of all Info/Warning/Error data
Expand Down
8 changes: 8 additions & 0 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,11 @@ private void OnUpdateGraphCompleted(AsyncTask task)
var node = workspace.Nodes.FirstOrDefault(n => n.GUID == guid);
if (node == null)
continue;

// Block Infos updates during the many errors/warnings/notifications added here
// InfoBubbles will be updated on NodeViewModel's EvaluationCompleted handler.
using (node.PropertyChangeManager.SetPropsToSuppress(nameof(NodeModel.Infos), nameof(NodeModel.State)))
using (Disposable.Create(() => { node.BlockInfoBubbleUpdates = true; }, () => { node.BlockInfoBubbleUpdates = false; }))
{
node.Warning(warning.Value); // Update node warning message.
}
Expand All @@ -711,7 +715,11 @@ private void OnUpdateGraphCompleted(AsyncTask task)
var node = workspace.Nodes.FirstOrDefault(n => n.GUID == guid);
if (node == null)
continue;

// Block Infos updates during the many errors/warnings/notifications added here
// InfoBubbles will be updated on NodeViewModel's EvaluationCompleted handler.
using (node.PropertyChangeManager.SetPropsToSuppress(nameof(NodeModel.Infos), nameof(NodeModel.State)))
using (Disposable.Create(() => { node.BlockInfoBubbleUpdates = true; }, () => { node.BlockInfoBubbleUpdates = false; }))
{
node.Info(string.Join(Environment.NewLine, info.Value.Select(w => w.Message)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!--This command updates the npm registry configuration if necessary-->
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" />
<!--Download a specific build of the Dynamo Home package from npm-->
<Exec Command="npm pack @dynamods/[email protected].5" />
<Exec Command="npm pack @dynamods/[email protected].6" />
</Target>

<Target Name="ExtractTGZFileDynamoHome" DependsOnTargets="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
Expand Down
8 changes: 4 additions & 4 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ You can always redownload the package.</value>
<value>The package or one of its dependencies contains Python scripts or binaries. Do you want to continue?</value>
</data>
<data name="MessagePackageNewerDynamo" xml:space="preserve">
<value>The package or one of its dependencies use a newer version of {0} than you are currently using. Do you want to continue?</value>
<value>This package or one of its dependencies were created for a newer version of Dynamo. It may not work in this version. Do you want to continue?</value>
</data>
<data name="MessageSelectAtLeastOneNode" xml:space="preserve">
<value>You must select at least one custom node.</value>
Expand Down Expand Up @@ -3963,12 +3963,12 @@ To make this file into a new template, save it to a different folder, then move
<value>Dynamo 1.x file format</value>
</data>
<data name="MessagePackageOlderDynamo" xml:space="preserve">
<value>The package or one of its dependencies use an older version of {0} than you are currently using. Do you want to continue?</value>
<value>This package or one of its dependencies were created for a previous version of Dynamo. It may not work in this version. Do you want to continue?</value>
</data>
<data name="PackageUseOlderDynamoMessageBoxTitle" xml:space="preserve">
<value>Package may not work in this version of Dynamo {0}!</value>
<value>Package may not work in this version of {0}!</value>
</data>
<data name="MessagePackOlderDynamoLink" xml:space="preserve">
<value>#Learn more=https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/updating-your-packages-and-dynamo-libraries-for-dynamo-3x-net8</value>
</data>
</root>
</root>
60 changes: 60 additions & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4440,6 +4440,66 @@
</Setter>
</Style>

<!-- This is a Padlock toggle button -->
<PathGeometry x:Key="PadlockIcon" Figures="M18 3C15.7909 3 14 4.79086 14 7V10H6C5.44772 10 5 10.4477 5 11V19C5 19.5523 5.44772 20 6 20H16C16.5523 20 17 19.5523 17 19V11C17 10.4477 16.5523 10 16 10H15V7C15 5.34315 16.3431 4 18 4C19.6569 4 21 5.34315 21 7V9H22V7C22 4.79086 20.2091 3 18 3ZM6 11H16V19H6L6 11Z"/>
<PathGeometry x:Key="PadlockLockedIcon" Figures="M11 4C8.79084 4 6.99998 5.79087 6.99999 8.00001L7 10H6C5.44772 10 5 10.4477 5 11V19C5 19.5523 5.44772 20 6 20H16C16.5523 20 17 19.5523 17 19V11C17 10.4477 16.5523 10 16 10H15V7.99999C15 5.79086 13.2091 4 11 4ZM14 10V7.99999C14 6.34314 12.6568 5 11 5C9.34313 5 7.99998 6.34315 7.99999 8L8 10H14ZM6 11H16V19H6L6 11Z"/>
<Style x:Key="PadlockToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid x:Name="mainGrid">
<Border Background="Transparent" Name="_borderOn">
<Viewbox Width="24"
Height="24"
VerticalAlignment="Center"
Margin="2 0 0 0">
<Path x:Name="_toggleOn"
Fill="#999999"
Data="{StaticResource PadlockIcon}"
StrokeThickness="0"
Stroke="#999999">
</Path>
</Viewbox>
</Border>
<Border Background="Transparent" Name="_borderOff">
<Viewbox Width="22"
Height="22"
VerticalAlignment="Center"
Margin="0 0 4 1">
<Path x:Name="_toggleOff"
Fill="#999999"
Data="{StaticResource PadlockLockedIcon}"
StrokeThickness="0"
Stroke="#999999">
</Path>
</Viewbox>
</Border>
</Grid>

<!-- triggers toggle visual appearance -->
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="_borderOff" Property="Visibility" Value="Collapsed" />
<Setter TargetName="_borderOn" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="_borderOff" Property="Visibility" Value="Visible" />
<Setter TargetName="_borderOn" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="_toggleOn" Property="Fill" Value="#6AC0E7" />
<Setter TargetName="_toggleOff" Property="Fill" Value="#6AC0E7" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="mainGrid" Property="OpacityMask" Value="{StaticResource SemiTransparent}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!-- This is a Toogle button shown in the Preferences Window for the General tab, when is checked shows a Blue button -->
<Style x:Key="EllipseToggleButton1" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
Expand Down
29 changes: 29 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public partial class DynamoViewModel : ViewModelBase, IDynamoViewModel

internal DynamoMLDataPipelineExtension MLDataPipelineExtension { get; set; }

internal Dictionary<string, NodeSearchElementViewModel> DefaultAutocompleteCandidates;

/// <summary>
/// Collection of Right SideBar tab items: view extensions and docked windows.
/// </summary>
Expand Down Expand Up @@ -695,6 +697,28 @@ public struct StartConfiguration
return new DynamoViewModel(startConfiguration);
}

private void SearchDefaultNodeAutocompleteCandidates()
{
var tempSearchViewModel = new SearchViewModel(this)
{
Visible = true
};
DefaultAutocompleteCandidates = new Dictionary<string, NodeSearchElementViewModel>();

// TODO: These are basic input types in Dynamo
// This should be only served as a temporary default case.
var queries = new List<string>() { "String", "Number Slider", "Integer Slider", "Number", "Boolean", "Watch", "Watch 3D", "Python Script" };
foreach (var query in queries)
{
var foundNode = tempSearchViewModel.Search(query).Where(n => n.Name.Equals(query)).FirstOrDefault();
if (foundNode != null)
{
DefaultAutocompleteCandidates.Add(foundNode.Name, foundNode);
}
}
tempSearchViewModel.Dispose();
}

protected DynamoViewModel(StartConfiguration startConfiguration)
{
// CurrentDomain_UnhandledException - catches unhandled exceptions that are fatal to the current process. These exceptions cannot be handled and process termination is guaranteed
Expand Down Expand Up @@ -734,6 +758,11 @@ protected DynamoViewModel(StartConfiguration startConfiguration)

//add the initial workspace and register for future
//updates to the workspaces collection
if(!Model.IsServiceMode)
{
SearchDefaultNodeAutocompleteCandidates();
}

var homespaceViewModel = new HomeWorkspaceViewModel(model.CurrentWorkspace as HomeWorkspaceModel, this);
workspaces.Add(homespaceViewModel);
currentWorkspaceViewModel = homespaceViewModel;
Expand Down
29 changes: 19 additions & 10 deletions src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,10 +1256,17 @@ private void UpdateErrorBubbleWidth()
/// </summary>
private void BuildErrorBubble()
{
if (ErrorBubble == null) ErrorBubble = new InfoBubbleViewModel(this)
if (ErrorBubble == null)
{
IsCollapsed = this.IsCollapsed
};
ErrorBubble = new InfoBubbleViewModel(this)
{
IsCollapsed = this.IsCollapsed,
// The Error bubble sits above the node in ZIndex. Since pinned notes sit above
// the node as well and the ErrorBubble needs to display on top of these, the
// ErrorBubble's ZIndex should be the node's ZIndex + 2.
ZIndex = ZIndex + 2
};
}

ErrorBubble.NodeInfoToDisplay.CollectionChanged += UpdateOverlays;
ErrorBubble.NodeWarningsToDisplay.CollectionChanged += UpdateOverlays;
Expand All @@ -1273,14 +1280,8 @@ private void BuildErrorBubble()
WorkspaceViewModel.Errors.Add(ErrorBubble);
});
}

// The Error bubble sits above the node in ZIndex. Since pinned notes sit above
// the node as well and the ErrorBubble needs to display on top of these, the
// ErrorBubble's ZIndex should be the node's ZIndex + 2.
ErrorBubble.ZIndex = ZIndex + 2;

// The Node displays a count of dismissed messages, listening to that collection in the node's ErrorBubble

ErrorBubble.DismissedMessages.CollectionChanged += DismissedNodeMessages_CollectionChanged;
}

Expand Down Expand Up @@ -1464,7 +1465,15 @@ private void DisposeErrorBubble()

public void UpdateBubbleContent()
{
if (DynamoViewModel == null) return;
if (NodeModel.BlockInfoBubbleUpdates)
{
return;
}

if (DynamoViewModel == null)
{
return;
}

bool hasErrorOrWarning = NodeModel.IsInErrorState || NodeModel.State == ElementState.Warning;
bool isNodeStateInfo = NodeModel.State == ElementState.Info || NodeModel.State == ElementState.PersistentInfo;
Expand Down
8 changes: 5 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ void Model_NodeRemoved(NodeModel node)
lock (Nodes)
{
nodeViewModel = Nodes.First(x => x.NodeLogic == node);
Errors.Remove(nodeViewModel.ErrorBubble);
if (nodeViewModel.ErrorBubble != null)
Errors.Remove(nodeViewModel.ErrorBubble);
Nodes.Remove(nodeViewModel);
}
//unsub the events we attached below in NodeAdded.
Expand All @@ -904,8 +905,9 @@ void Model_NodeAdded(NodeModel node)
{
Nodes.Add(nodeViewModel);
}
Errors.Add(nodeViewModel.ErrorBubble);

if (nodeViewModel.ErrorBubble != null)
Errors.Add(nodeViewModel.ErrorBubble);

PostNodeChangeActions();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public bool DisplayLowConfidence
internal NodeAutoCompleteSearchViewModel(DynamoViewModel dynamoViewModel) : base(dynamoViewModel)
{
// Off load some time consuming operation here
InitializeDefaultAutoCompleteCandidates();
DefaultResults = dynamoViewModel.DefaultAutocompleteCandidates.Values;
ServiceVersion = string.Empty;
}

Expand All @@ -179,23 +179,6 @@ internal void ResetAutoCompleteSearchViewState()
searchElementsCache = new List<NodeSearchElementViewModel>();
}

private void InitializeDefaultAutoCompleteCandidates()
{
var candidates = new List<NodeSearchElementViewModel>();
// TODO: These are basic input types in Dynamo
// This should be only served as a temporary default case.
var queries = new List<string>(){"String", "Number Slider", "Integer Slider", "Number", "Boolean", "Watch", "Watch 3D", "Python Script"};
foreach (var query in queries)
{
var foundNode = Search(query).Where(n => n.Name.Equals(query)).FirstOrDefault();
if(foundNode != null)
{
candidates.Add(foundNode);
}
}
DefaultResults = candidates;
}

internal MLNodeAutoCompletionRequest GenerateRequestForMLAutocomplete()
{
// Initialize request for the the ML API
Expand Down
Loading

0 comments on commit 6b574dd

Please sign in to comment.