Skip to content

Commit

Permalink
Edit Python Port Properties (#13788)
Browse files Browse the repository at this point in the history
* Outport - added Edit Port Properties button to port context menu

- added a new button to the OutPortContextMenu to allow users to Edit Port Properties
- for the time being, it is only enabled and visible in case of Python Node Model (in future this check can be removed allowing other nodes to use this functionality as well)

* Output rename working

- At this point, output port can be renamed
- TODO: handle contextmenu - should close after interaction, now keeps alive
- TODO: remove Categories
- TODO: create validation checks (cannot be the same as any other Port, cannot be null, cannot be an Integer, anything else?)
- TODO: Set Prompt name based on Inport/Outport usage

* Hide popup after interaction

- since we no longer need the popup to stick around after we have launched the Edit Properties Prompt, hide the popup

* Resource properties added

- added Port Properties Prompt property values as resources
- added a dynamic prompt title based on the PortType value of the port
- further cleaned the UI design

* WindowsStartupLocation - Screen

- cannot find DynamoView as an owner for some reason, using WindowStartupLocation.CenterScreen instead
- control cleanup

* Code refactor, name validation

- refactor chunks of code for better usability
- incorporated number and unique port name validation checks

* Added Port Properties Prompt to context menu of Input port

- now works for both Input and Output ports

* Added port removal notification message

- will prompt the user to agree to lose changes when removing port

* Validation changed to status label

- changed the validation warning method to status label underneath the Name text box

* Save disabled on warning

- disable 'Save' button when we are in a warning state (invalid port name)
- cleans up interaction around blank name

* Public converter comment

- added comment to public converter

* Moved private property

- moved private property to top of class for better readability

* Used DynamoUtilities method

- used DynamoUtilities.PathHelper method to check for name validation

* Removed commented out code

- removed unnecessary code

* Added back the missing page tag

- fixed page tag
  • Loading branch information
dnenov authored and sm6srw committed Apr 5, 2023
1 parent 9c6170f commit 01f3104
Show file tree
Hide file tree
Showing 17 changed files with 918 additions and 12 deletions.
33 changes: 32 additions & 1 deletion src/DynamoCoreWpf/Controls/DynamoNodeButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Dynamo.UI;
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Wpf.Utilities;

namespace Dynamo.Nodes
{
Expand All @@ -28,6 +29,17 @@ private DynamoViewModel DynamoViewModel
}
}

private Window Owner
{
get
{
var f = WpfUtilities.FindUpVisualTree<DynamoView>(this);
if (f != null) return f;

return null;
}
}

public DynamoNodeButton()
{
}
Expand All @@ -49,9 +61,28 @@ private void OnDynamoNodeButtonClick(object sender, RoutedEventArgs e)
//
if (null != this.model && (!string.IsNullOrEmpty(this.eventName)))
{
MessageBoxResult result = MessageBoxResult.None;

if (eventName.Equals("RemoveInPort"))
{
result = MessageBoxService.Show
(
Owner,
Dynamo.Wpf.Properties.Resources.MessageRemovePythonPort,
Dynamo.Wpf.Properties.Resources.RemovePythonPortWarningMessageBoxTitle,
MessageBoxButton.OKCancel,
MessageBoxImage.Information
);
}

if (result == MessageBoxResult.Cancel)
{
return;
}

var command = new DynamoModel.ModelEventCommand(model.GUID, eventName);
this.DynamoViewModel.ExecuteCommand(command);
}
}
}
}
}
19 changes: 16 additions & 3 deletions src/DynamoCoreWpf/Controls/InPortContextMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="Dynamo.UI.Controls.InPortContextMenu"
<UserControl x:Class="Dynamo.UI.Controls.InPortContextMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down Expand Up @@ -100,7 +100,8 @@
Command="{Binding Path=UseLevelsCommand}"
CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource Self}}"
Content="{x:Static p:Resources.UseLevelPopupMenuItem}"
IsChecked="{Binding Path=UseLevels, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
IsChecked="{Binding Path=UseLevels, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding IsPythonNodePort, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}" />

<!-- Keep List Structure -->
<CheckBox Name="KeepListStructure"
Expand All @@ -110,7 +111,8 @@
CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource Self}}"
Content="{x:Static p:Resources.UseLevelKeepListStructurePopupMenuItem}"
IsChecked="{Binding Path=ShouldKeepListStructure, Mode=OneWay}"
IsEnabled="{Binding ElementName=UseLevel, Path=IsChecked}" />
IsEnabled="{Binding ElementName=UseLevel, Path=IsChecked}"
Visibility="{Binding IsPythonNodePort, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}" />

<!-- Use Default Value -->
<CheckBox Name="UseDefaultValue"
Expand All @@ -119,6 +121,17 @@
Content="{x:Static p:Resources.PortViewContextMenuUserDefaultValue}"
IsChecked="{Binding Path=UsingDefaultValue, Mode=TwoWay}"
Visibility="{Binding DefaultValueEnabled, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />

<!-- Rename Port -->
<Button Name="RenamePortButton"
Margin="0,3"
HorizontalAlignment="Left"
Command="{Binding Path=EditPortPropertiesCommand}"
Content="{x:Static p:Resources.RenamePortPopupMenuItem}"
IsEnabled="{Binding RenameNodeButtonEnabled, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding RenameNodeButtonEnabled, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
Style="{StaticResource PopupButtonStyle}" />

</StackPanel>
</Border>

Expand Down
12 changes: 11 additions & 1 deletion src/DynamoCoreWpf/Controls/OutPortContextMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="Dynamo.UI.Controls.OutPortContextMenu"
<UserControl x:Class="Dynamo.UI.Controls.OutPortContextMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down Expand Up @@ -48,6 +48,16 @@
IsEnabled="{Binding HideWiresButtonEnabled, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource PopupButtonStyle}" />

<!-- Rename Port -->
<Button Name="RenamePortButton"
Margin="0,3"
HorizontalAlignment="Left"
Command="{Binding Path=EditPortPropertiesCommand}"
Content="{x:Static p:Resources.RenamePortPopupMenuItem}"
IsEnabled="{Binding RenameNodeButtonEnabled, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding RenameNodeButtonEnabled, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
Style="{StaticResource PopupButtonStyle}" />

</StackPanel>
</Border>

Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/Controls/OutPortContextMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System;
using System.Windows;
using System.Windows.Controls;
using Dynamo.ViewModels;

namespace Dynamo.UI.Controls
{
/// <summary>
/// Interaction logic for InPortContextMenu.xaml
/// Interaction logic for OutPortContextMenu.xaml
/// </summary>
public partial class OutPortContextMenu : UserControl
{
Expand Down
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<None Remove="Packages\SplashScreen\build\index.bundle.js" />
<None Remove="Packages\SplashScreen\build\index.html" />
<None Remove="UI\Images\Canvas\canvas-button-geometry-scaling.png" />
<None Remove="UI\Prompts\PortPropertiesEditPrompt.xaml" />
<None Remove="Views\Core\CustomColorPicker.xaml" />
<None Remove="Views\Core\GeometryScalingPopup.xaml" />
<None Remove="UI\Images\question-hover-blue-16px.png" />
Expand Down Expand Up @@ -226,6 +227,7 @@
<Compile Include="Controls\InPortContextMenu.xaml.cs">
<DependentUpon>InPortContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="UI\Prompts\PortPropertiesEditPrompt.xaml.cs" />
<Compile Include="Utilities\CompactBubbleHandler.cs" />
<Compile Include="Interfaces\IShellCom.cs" />
<Compile Include="Rendering\HelixRenderPackage.cs" />
Expand Down Expand Up @@ -561,6 +563,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\Prompts\PortPropertiesEditPrompt.xaml"></Page>
<Page Include="Views\Core\CustomColorPicker.xaml">
<CopyToOutputDirectory></CopyToOutputDirectory>
<Generator>MSBuild:Compile</Generator>
Expand Down
90 changes: 90 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,9 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down
<data name="BreakConnectionsPopupMenuItem" xml:space="preserve">
<value>Break Connections</value>
</data>
<data name="RenamePortPopupMenuItem" xml:space="preserve">
<value>Edit Port Properties</value>
</data>
<data name="HideWiresPopupMenuItem" xml:space="preserve">
<value>Hide Wires</value>
</data>
Expand Down Expand Up @@ -3494,6 +3497,39 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="DynamoViewSettingLibraryZoomScale" xml:space="preserve">
<value>Library</value>
</data>
<data name="PortPropertiesPromptInputWindowTitle">
<value>Input Port Properties</value>
<comment>Input Port title</comment>
</data>
<data name="PortPropertiesPromptOutputWindowTitle">
<value>Output Port Properties</value>
<comment>Output Port title</comment>
</data>
<data name="PortPropertiesPromptDescriptionTooltip">
<value>Description of port</value>
<comment>Description of port</comment>
</data>
<data name="PortPropertiesPromptWindowDescription">
<value>Description</value>
<comment>Port Description Label</comment>
</data>
<data name="PortPropertiesPromptNameTooltip">
<value>Port name</value>
<comment>Name of port</comment>
</data>
<data name="PortPropertiesPromptWindowName">
<value>Name</value>
<comment>Port Name Label</comment>
</data>
<data name="RemovePythonPortWarningMessageBoxTitle" xml:space="preserve">
<value>Remove port?</value>
</data>
<data name="MessageRemovePythonPort" xml:space="preserve">
<value>Your custom port properties will be lost once the port is removed.</value>
</data>
<data name="MessagePortNameInvalid" xml:space="preserve">
<value>Cannot contain special characters (# % * ? \ : [ ])</value>
</data>
<data name="PreferencesViewEnablePersistExtensions" xml:space="preserve">
<value>On launch, remember open extensions panels from last session</value>
</data>
Expand Down
36 changes: 36 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,9 @@ Next assemblies were loaded several times:
<data name="BreakConnectionsPopupMenuItem" xml:space="preserve">
<value>Break Connections</value>
</data>
<data name="RenamePortPopupMenuItem" xml:space="preserve">
<value>Edit Port Properties</value>
</data>
<data name="HideWiresPopupMenuItem" xml:space="preserve">
<value>Hide Wires</value>
</data>
Expand Down Expand Up @@ -3481,6 +3484,39 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="DynamoViewSettingLibraryZoomScale" xml:space="preserve">
<value>Library</value>
</data>
<data name="PortPropertiesPromptInputWindowTitle">
<value>Input Port Properties</value>
<comment>Input Port title</comment>
</data>
<data name="PortPropertiesPromptOutputWindowTitle">
<value>Output Port Properties</value>
<comment>Output Port title</comment>
</data>
<data name="PortPropertiesPromptDescriptionTooltip">
<value>Description of port</value>
<comment>Description of port</comment>
</data>
<data name="PortPropertiesPromptWindowDescription">
<value>Description</value>
<comment>Port Description Label</comment>
</data>
<data name="PortPropertiesPromptNameTooltip">
<value>Port name</value>
<comment>Name of port</comment>
</data>
<data name="PortPropertiesPromptWindowName">
<value>Name</value>
<comment>Port Name Label</comment>
</data>
<data name="RemovePythonPortWarningMessageBoxTitle" xml:space="preserve">
<value>Remove port?</value>
</data>
<data name="MessageRemovePythonPort" xml:space="preserve">
<value>Your custom port properties will be lost once the port is removed.</value>
</data>
<data name="MessagePortNameInvalid" xml:space="preserve">
<value>Cannot contain special characters (# % * ? \ : [ ])</value>
</data>
<data name="PreferencesViewEnablePersistExtensions" xml:space="preserve">
<value>On launch, remember open extensions panels from last session</value>
</data>
Expand Down
Loading

0 comments on commit 01f3104

Please sign in to comment.