Skip to content

Commit

Permalink
DYN-7203 [Cherry-pick] #15355 and #15361 (#15368)
Browse files Browse the repository at this point in the history
Co-authored-by: pinzart90 <46732933+pinzart90@users.noreply.github.com>
Co-authored-by: Roberto T <61755417+RobertGlobant20@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 2, 2024
1 parent f1cb198 commit 0404772
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ private void OnUpdateGraphCompleted(AsyncTask task)
}
}

// All nodes that have runtime warnings or infos
HashSet<Guid> nodesWithInfos = [.. warnings.Keys];

// Update node info message.
foreach (var info in updateTask.RuntimeInfos)
{
Expand All @@ -716,6 +719,8 @@ private void OnUpdateGraphCompleted(AsyncTask task)
if (node == null)
continue;

nodesWithInfos.Add(guid);

// 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)))
Expand All @@ -735,8 +740,8 @@ private void OnUpdateGraphCompleted(AsyncTask task)
// Dispatch the failure message display for execution on UI thread.
//
EvaluationCompletedEventArgs e = task.Exception == null || IsTestMode
? new EvaluationCompletedEventArgs(true,warnings.Keys,null)
: new EvaluationCompletedEventArgs(true, warnings.Keys, task.Exception);
? new EvaluationCompletedEventArgs(true, nodesWithInfos, null)
: new EvaluationCompletedEventArgs(true, nodesWithInfos, task.Exception);

EvaluationCount ++;

Expand Down
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,10 @@ Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultCommand.get -> Dyna
Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultCommand.set -> void
Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogCommand.set -> void
Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultAsyncCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.DynamoViewModel.ShowOpenDialogAndOpenResultAsyncCommand.set -> void
Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogAsyncCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.DynamoViewModel.ShowOpenTemplateDialogAsyncCommand.set -> void
Dynamo.ViewModels.DynamoViewModel.ShowPackageManagerCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.DynamoViewModel.ShowPackageManagerCommand.set -> void
Dynamo.ViewModels.DynamoViewModel.ShowPackageManagerSearchCommand.get -> Dynamo.UI.Commands.DelegateCommand
Expand Down
5 changes: 5 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,11 @@ private void ShowOpenDialogAndOpenResult(object parameter)
}
}

private async void ShowOpenDialogAndOpenResultAsync(object parameter)
{
UIDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, () => ShowOpenDialogAndOpenResult(parameter));
}

private void SetDefaultInitialDirectory(DynamoOpenFileDialog _fileDialog)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ private void InitializeDelegateCommands()
SaveCommand = new DelegateCommand(Save, CanSave);
SaveAsCommand = new DelegateCommand(SaveAs, CanSaveAs);
ShowOpenDialogAndOpenResultCommand = new DelegateCommand(ShowOpenDialogAndOpenResult, CanShowOpenDialogAndOpenResultCommand);
ShowOpenDialogAndOpenResultAsyncCommand = new DelegateCommand(ShowOpenDialogAndOpenResultAsync, CanShowOpenDialogAndOpenResultCommand);
ShowOpenTemplateDialogAsyncCommand = new DelegateCommand(ShowOpenDialogAndOpenResultAsync, CanShowOpenDialogAndOpenResultCommand);
ShowOpenTemplateDialogCommand = new DelegateCommand(ShowOpenDialogAndOpenResult, CanShowOpenDialogAndOpenResultCommand);
ShowInsertDialogAndInsertResultCommand = new DelegateCommand(ShowInsertDialogAndInsertResult, CanShowInsertDialogAndInsertResultCommand);
ShowSaveDialogAndSaveResultCommand = new DelegateCommand(ShowSaveDialogAndSaveResult, CanShowSaveDialogAndSaveResult);
Expand Down Expand Up @@ -99,8 +101,10 @@ private void InitializeDelegateCommands()
public DelegateCommand OpenFromJsonCommand { get; set; }
public DelegateCommand OpenIfSavedCommand { get; set; }
public DelegateCommand OpenCommand { get; set; }
public DelegateCommand ShowOpenDialogAndOpenResultAsyncCommand { get; set; }
public DelegateCommand ShowOpenDialogAndOpenResultCommand { get; set; }
public DelegateCommand ShowOpenTemplateDialogCommand { get; set; }
public DelegateCommand ShowOpenTemplateDialogAsyncCommand { get; set; }
public DelegateCommand ShowInsertDialogAndInsertResultCommand { get; set; }
public DelegateCommand WriteToLogCmd { get; set; }
public DelegateCommand PostUiActivationCommand { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
Command="{Binding Path=DataContext.ShowSaveDialogAndSaveResultCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" />
<KeyBinding Key="O"
Modifiers="Control"
Command="{Binding Path=DataContext.ShowOpenDialogAndOpenResultCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" />
Command="{Binding Path=DataContext.ShowOpenDialogAndOpenResultAsyncCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" />
<KeyBinding Key="T"
Modifiers="Control"
Command="{Binding Path=DataContext.ShowOpenTemplateDialogCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}"
Command="{Binding Path=DataContext.ShowOpenTemplateDialogAsyncCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}"
CommandParameter="Template"/>
<KeyBinding Key="I"
Modifiers="Control+Shift"
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ internal void OpenWorkspace()
return;
}

this.startPage?.DynamoViewModel?.ShowOpenDialogAndOpenResultCommand.Execute(null);
this.startPage?.DynamoViewModel?.ShowOpenDialogAndOpenResultAsyncCommand.Execute(null);
Logging.Analytics.TrackEvent(Logging.Actions.Open, Logging.Categories.DynamoHomeOperations, "Workspace");
}

Expand Down Expand Up @@ -575,7 +575,7 @@ internal void OpenTemplate()
}

// Equivalent to CommandParameter="Template"
this.startPage?.DynamoViewModel?.ShowOpenTemplateDialogCommand.Execute("Template");
this.startPage?.DynamoViewModel?.ShowOpenTemplateDialogAsyncCommand.Execute("Template");
Logging.Analytics.TrackEvent(Logging.Actions.Open, Logging.Categories.DynamoHomeOperations, "Template");
}

Expand Down
19 changes: 19 additions & 0 deletions test/DynamoCoreWpfTests/PreviewBubbleTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using CoreNodeModels;
using Dynamo.Controls;
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Workspaces;
using Dynamo.Models;
using Dynamo.Utilities;
using DynamoCoreWpfTests.Utility;
Expand Down Expand Up @@ -915,6 +917,23 @@ public void PreviewBubble_CopyToClipboard()
Assert.AreEqual(singleItemTreeExpected, clipboardContent);
}

[Test]
public void GeometryScalingInfoBubble()
{
Open(@"UI\GeometryScalingInfoBubble.dyn");
var workspace = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;
Debug.Assert(workspace != null, nameof(workspace) + " != null");
workspace.Run();

List<NodeModel> errorNodes = ViewModel.Model.CurrentWorkspace.Nodes.ToList().FindAll(n => n.State == ElementState.Error);
List<NodeModel> warningNodes = ViewModel.Model.CurrentWorkspace.Nodes.ToList().FindAll(n => n.State == ElementState.Warning || n.State == ElementState.PersistentWarning);
List<NodeModel> infoNodes = ViewModel.Model.CurrentWorkspace.Nodes.ToList().FindAll(n => n.State == ElementState.Info);

Assert.AreEqual(0, errorNodes.Count);
Assert.AreEqual(0, warningNodes.Count);
Assert.AreEqual(1, infoNodes.Count);
}

private bool ElementIsInContainer(FrameworkElement element, FrameworkElement container, int offset)
{
var relativePosition = element.TranslatePoint(new Point(), container);
Expand Down
160 changes: 160 additions & 0 deletions test/UI/GeometryScalingInfoBubble.dyn
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"Uuid": "dbf58b8e-9c0f-4739-b651-86909a9ff802",
"IsCustomNode": false,
"Description": "",
"Name": "GeometryScalingInfoBubble",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore",
"Id": "f16400ac984e4818800d15aa324a0956",
"NodeType": "FunctionNode",
"Inputs": [
{
"Id": "aff3dd620552421a8628da8a3712cc98",
"Name": "x",
"Description": "X coordinate\n\ndouble\nDefault value : 0",
"UsingDefaultValue": true,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "2ac43c47bd4149d988fa8f62896bfd05",
"Name": "y",
"Description": "Y coordinate\n\ndouble\nDefault value : 0",
"UsingDefaultValue": true,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "d56001c28a0247409c740f4f48c79126",
"Name": "z",
"Description": "Z coordinate\n\ndouble\nDefault value : 0",
"UsingDefaultValue": true,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "7069ed19976246f382c3765f78657b08",
"Name": "Point",
"Description": "Point created by coordinates",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"FunctionSignature": "Autodesk.DesignScript.Geometry.Point.ByCoordinates@double,double,double",
"Replication": "Auto",
"Description": "Form a Point given 3 cartesian coordinates\n\nPoint.ByCoordinates (x: double = 0, y: double = 0, z: double = 0): Point"
},
{
"ConcreteType": "CoreNodeModels.Input.DoubleInput, CoreNodeModels",
"NumberType": "Double",
"Id": "7556b378a2484190bb10ee4c5c8f89cc",
"NodeType": "NumberInputNode",
"Inputs": [],
"Outputs": [
{
"Id": "05869dc333194864b3dff3efda633d9e",
"Name": "",
"Description": "Double",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Creates a number",
"InputValue": 2000000000.0
}
],
"Connectors": [
{
"Start": "05869dc333194864b3dff3efda633d9e",
"End": "d56001c28a0247409c740f4f48c79126",
"Id": "761c9400d67e4425b0c559faec43f5b2",
"IsHidden": "False"
}
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"EnableLegacyPolyCurveBehavior": null,
"Thumbnail": "",
"GraphDocumentationURL": null,
"ExtensionWorkspaceData": [
{
"ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670",
"Name": "Properties",
"Version": "3.2",
"Data": {}
}
],
"Author": "",
"Linting": {
"activeLinter": "None",
"activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a",
"warningCount": 0,
"errorCount": 0
},
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": true,
"IsVisibleInDynamoLibrary": true,
"Version": "3.2.1.5440",
"RunType": "Manual",
"RunPeriod": "1000"
},
"Camera": {
"Name": "_Background Preview",
"EyeX": -17.0,
"EyeY": 24.0,
"EyeZ": 50.0,
"LookX": 12.0,
"LookY": -13.0,
"LookZ": -58.0,
"UpX": 0.0,
"UpY": 1.0,
"UpZ": 0.0
},
"ConnectorPins": [],
"NodeViews": [
{
"Id": "f16400ac984e4818800d15aa324a0956",
"Name": "Point.ByCoordinates",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"ShowGeometry": true,
"X": 404.79999999999995,
"Y": 194.00000000000006
},
{
"Id": "7556b378a2484190bb10ee4c5c8f89cc",
"Name": "Number",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"ShowGeometry": true,
"X": 2.0000000000001137,
"Y": 326.4000000000001
}
],
"Annotations": [],
"X": 28.600000000000023,
"Y": -12.400000000000091,
"Zoom": 1.0
}
}

0 comments on commit 0404772

Please sign in to comment.