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

DYN-3572 std.lib should be visible in manage node and package path UI #11622

Merged
merged 29 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8d6ec9
Refactor Package Loader
sm6srw Apr 16, 2021
12f46b4
Revert unneeded change
sm6srw Apr 16, 2021
272d703
Add some tests
sm6srw Apr 16, 2021
f37b52b
Add standard library token to startup code.
sm6srw Apr 16, 2021
a15f651
Add/update tests.
sm6srw Apr 16, 2021
0145546
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into DYN-…
sm6srw Apr 16, 2021
c961b8e
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into DYN-…
sm6srw Apr 19, 2021
7d3927e
Make internal and add prop for token.
sm6srw Apr 19, 2021
d6bd0fa
Add UI support.
sm6srw Apr 19, 2021
6fc1567
Disable delete and edit for standard library.
sm6srw Apr 19, 2021
cedafde
Move UI string to resources.
sm6srw Apr 19, 2021
fce87f8
Add token prop
sm6srw Apr 19, 2021
b9817b4
Fix tests.
sm6srw Apr 19, 2021
b21cced
Add more filtering
sm6srw Apr 20, 2021
e091bd3
Update tests
sm6srw Apr 20, 2021
f39bdd9
Revert changes
sm6srw Apr 20, 2021
af16ce7
Revert debug changes
sm6srw Apr 20, 2021
9fd0045
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into DYN-…
sm6srw Apr 20, 2021
f31582f
Update defaults
sm6srw Apr 20, 2021
35bc719
Add more tests
sm6srw Apr 20, 2021
496ac14
Add more tests
sm6srw Apr 20, 2021
91c9286
Refactor
sm6srw Apr 20, 2021
0d84132
Update test
sm6srw Apr 20, 2021
fb7caa9
Consolidate the use of the StandardLibraryToken Prop.
sm6srw Apr 21, 2021
9de3279
Refresh dialog
sm6srw Apr 22, 2021
8b2e7fb
Update wording
sm6srw Apr 23, 2021
f1b9e08
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into DYN-…
sm6srw Apr 23, 2021
9a80526
More resource tweaks
sm6srw Apr 23, 2021
75527f5
Final resource tweaks!
sm6srw Apr 23, 2021
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
3 changes: 2 additions & 1 deletion src/DynamoCore/Configuration/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Dynamo.Interfaces;
using Dynamo.Properties;
using DynamoUtilities;
using Dynamo.Models;

namespace Dynamo.Core
{
Expand Down Expand Up @@ -93,7 +94,7 @@ class PathManager : IPathManager

private IEnumerable<string> RootDirectories
{
get { return Preferences != null ? Preferences.CustomPackageFolders : rootDirectories; }
get { return Preferences != null ? Preferences.CustomPackageFolders.Where(path => path != DynamoModel.StandardLibraryToken) : rootDirectories; }
}

//Todo in Dynamo 3.0, Add this to the IPathManager interface
Expand Down
10 changes: 9 additions & 1 deletion src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ public static DynamoModel Start(IStartConfiguration configuration)
return new DynamoModel(configuration);
}

// Token representing the standard library directory
internal static readonly string StandardLibraryToken = @"%StandardLibrary%";
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Default constructor for DynamoModel
/// </summary>
Expand Down Expand Up @@ -724,7 +727,12 @@ protected DynamoModel(IStartConfiguration config)
// is no additional location specified. Otherwise, update pathManager.PackageDirectories to include
// PackageFolders
if (PreferenceSettings.CustomPackageFolders.Count == 0)
PreferenceSettings.CustomPackageFolders = new List<string> { pathManager.UserDataDirectory };
PreferenceSettings.CustomPackageFolders = new List<string> { StandardLibraryToken, pathManager.UserDataDirectory };

if (!PreferenceSettings.CustomPackageFolders.Contains(StandardLibraryToken))
sm6srw marked this conversation as resolved.
Show resolved Hide resolved
{
PreferenceSettings.CustomPackageFolders.Insert(0, StandardLibraryToken);
}

// Make sure that the default package folder is added in the list if custom packages folder.
var userDataFolder = pathManager.GetUserDataFolder(); // Get the default user data path
Expand Down
20 changes: 19 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.Designer.cs

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

17 changes: 12 additions & 5 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1559,10 +1559,6 @@ Next assemblies were loaded several times:
<value>Add paths to make nodes and packages show up in the library.</value>
<comment>Package path management dialog content</comment>
</data>
<data name="PackagePathViewSummary2" xml:space="preserve">
<value>Top path is the default save location.</value>
<comment>Package path management dialog content that describes about the first entry being the default save location.</comment>
</data>
<data name="PackagePathViewTitle" xml:space="preserve">
<value>Manage Node and Package Paths</value>
<comment>Package path management dialog title</comment>
Expand Down Expand Up @@ -2354,4 +2350,15 @@ Uninstall the following packages: {0}?</value>
<data name="MessageSamePackageDiffVersInStdLib" xml:space="preserve">
<value>A different version of the package {1} is already installed as part of the Standard Library. {0} cannot override packages in the Standard Library location.</value>
</data>
</root>
<data name="PackagePathViewModel_Standard_Library" xml:space="preserve">
<value>Standard Library</value>
</data>
<data name="PackagePathViewSummary2" xml:space="preserve">
<value>The default install location is the first path that is not the Standard Library location.</value>
<comment>Package path management dialog content that describes about the first non standard libary entry being the default save location.</comment>
sm6srw marked this conversation as resolved.
Show resolved Hide resolved
</data>
<data name="PackagePathViewSummary3" xml:space="preserve">
<value>Locations in italic(s) are disabled.</value>
<comment>Italic locations are disabled. This can currently only be the standard library.</comment>
</data>
</root>
13 changes: 10 additions & 3 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1906,8 +1906,8 @@ Do you want to install the latest Dynamo update?</value>
<comment>Package path management dialog content</comment>
</data>
<data name="PackagePathViewSummary2" xml:space="preserve">
<value>Top path is the default save location.</value>
<comment>Package path management dialog content that describes about the first entry being the default save location.</comment>
<value>The default install location is the first path that is not the Standard Library location.</value>
<comment>Package path management dialog content that describes about the first non standard libary entry being the default save location.</comment>
</data>
<data name="PackagePathViewTitle" xml:space="preserve">
<value>Manage Node and Package Paths</value>
Expand Down Expand Up @@ -2354,4 +2354,11 @@ Uninstall the following packages: {0}?</value>
<data name="MessageSamePackageDiffVersInStdLib" xml:space="preserve">
<value>A different version of the package {1} is already installed as part of the Standard Library. {0} cannot override packages in the Standard Library location.</value>
</data>
</root>
<data name="PackagePathViewModel_Standard_Library" xml:space="preserve">
<value>Standard Library</value>
</data>
<data name="PackagePathViewSummary3" xml:space="preserve">
<value>Locations in italic(s) are disabled.</value>
<comment>Italic locations are disabled. This can currently only be the standard library.</comment>
sm6srw marked this conversation as resolved.
Show resolved Hide resolved
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Controls;
using Dynamo.Core;
using Dynamo.Interfaces;
using Dynamo.PackageManager;
using Dynamo.Wpf.Properties;
using DelegateCommand = Dynamo.UI.Commands.DelegateCommand;
using Dynamo.Models;
using System.Windows.Data;

namespace Dynamo.ViewModels
{
public sealed class PathEnabledConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null && parameter != null)
{
var disableStandardLibrary = (bool)parameter;
if (disableStandardLibrary)
{
var path = value as string;
return String.CompareOrdinal(path, Resources.PackagePathViewModel_Standard_Library) != 0;
}
}
return true;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}

public class PackagePathEventArgs : EventArgs
{
/// <summary>
Expand All @@ -34,7 +60,7 @@ public int SelectedIndex
set
{
selectedIndex = value;
RaisePropertyChanged("SelectedIndex");
RaisePropertyChanged(nameof(SelectedIndex));
RaiseCanExecuteChanged();
}
}
Expand Down Expand Up @@ -63,18 +89,21 @@ private IPreferences setting
public DelegateCommand UpdatePathCommand { get; private set; }
public DelegateCommand SaveSettingCommand { get; private set; }

public static bool DisableStandardLibrary = false;

public PackagePathViewModel(PackageLoader loader, LoadPackageParams loadParams, CustomNodeManager customNodeManager)
{
this.packageLoader = loader;
this.loadPackageParams = loadParams;
this.customNodeManager = customNodeManager;
RootLocations = new ObservableCollection<string>(setting.CustomPackageFolders);

InitializeRootLocations();

AddPathCommand = new DelegateCommand(p => InsertPath());
DeletePathCommand = new DelegateCommand(p => RemovePathAt((int) p), CanDelete);
MovePathUpCommand = new DelegateCommand(p => SwapPath((int) p, ((int) p) - 1), CanMoveUp);
MovePathDownCommand = new DelegateCommand(p => SwapPath((int) p, ((int) p) + 1), CanMoveDown);
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int) p));
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int) p), CanUpdate);
SaveSettingCommand = new DelegateCommand(CommitChanges);

SelectedIndex = 0;
Expand All @@ -86,13 +115,13 @@ public PackagePathViewModel(PackageLoader loader, LoadPackageParams loadParams,
public PackagePathViewModel(IPreferences setting)
{

RootLocations = new ObservableCollection<string>(setting.CustomPackageFolders);
InitializeRootLocations();

AddPathCommand = new DelegateCommand(p => InsertPath());
DeletePathCommand = new DelegateCommand(p => RemovePathAt((int)p), CanDelete);
MovePathUpCommand = new DelegateCommand(p => SwapPath((int)p, ((int)p) - 1), CanMoveUp);
MovePathDownCommand = new DelegateCommand(p => SwapPath((int)p, ((int)p) + 1), CanMoveDown);
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int)p));
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int)p), CanUpdate);
SaveSettingCommand = new DelegateCommand(CommitChanges);

SelectedIndex = 0;
Expand All @@ -105,10 +134,15 @@ private void RaiseCanExecuteChanged()
MovePathUpCommand.RaiseCanExecuteChanged();
AddPathCommand.RaiseCanExecuteChanged();
DeletePathCommand.RaiseCanExecuteChanged();
UpdatePathCommand.RaiseCanExecuteChanged();
}

private bool CanDelete(object param)
{
if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == SelectedIndex)
{
return false;
}
return RootLocations.Count > 1;
}

Expand All @@ -122,6 +156,11 @@ private bool CanMoveDown(object param)
return SelectedIndex < RootLocations.Count - 1;
}

private bool CanUpdate(object param)
{
return RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) != SelectedIndex;
}

// The position of the selected entry must always be the first parameter.
private void SwapPath(int x, int y)
{
Expand Down Expand Up @@ -184,12 +223,40 @@ private void RemovePathAt(int index)

private void CommitChanges(object param)
{
setting.CustomPackageFolders = new List<string>(RootLocations);
setting.CustomPackageFolders = CommitRootLocations();
if (this.packageLoader != null)
{
this.packageLoader.LoadCustomNodesAndPackages(loadPackageParams, customNodeManager);
}
}

private void InitializeRootLocations()
{
RootLocations = new ObservableCollection<string>(setting.CustomPackageFolders);
var index = RootLocations.IndexOf(DynamoModel.StandardLibraryToken);

if (index != -1)
{
RootLocations[index] = Resources.PackagePathViewModel_Standard_Library;

if (setting is IDisablePackageLoadingPreferences disablePrefs)
{
DisableStandardLibrary = disablePrefs.DisableStandardLibrary;
}
}
}

private List<string> CommitRootLocations()
{
var rootLocations = new List<string>(RootLocations);
var index = rootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library);

if (index != -1)
{
rootLocations[index] = DynamoModel.StandardLibraryToken;
}

return rootLocations;
}
}
}
12 changes: 9 additions & 3 deletions src/DynamoCoreWpf/Views/PackageManager/PackagePathView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
d:DesignWidth="300"
Background="#515151"
Style="{DynamicResource DynamoWindowStyle}"
d:DataContext="{d:DesignInstance ViewModels:InstalledPackagesViewModel, IsDesignTimeCreatable=False}">
d:DataContext="{d:DesignInstance ViewModels:PackagePathViewModel, IsDesignTimeCreatable=False}">
sm6srw marked this conversation as resolved.
Show resolved Hide resolved

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoModernDictionaryUri}" />
</ResourceDictionary.MergedDictionaries>

<ViewModels:PathEnabledConverter x:Key="PathEnabledConverter" />
<Style x:Key="PathListBoxStyle"
TargetType="ListBox">
<Setter Property="SnapsToDevicePixels"
Expand Down Expand Up @@ -88,7 +88,6 @@
Background="Transparent">
<ContentPresenter />
</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsSelected"
Value="True">
Expand All @@ -107,6 +106,10 @@
Property="Background"
Value="#666666" />
</MultiTrigger>
<DataTrigger Binding="{Binding Converter={StaticResource PathEnabledConverter}, ConverterParameter={x:Static ViewModels:PackagePathViewModel.DisableStandardLibrary}, UpdateSourceTrigger=PropertyChanged}" Value="False">
<Setter Property="FontStyle"
Value="Italic" />
</DataTrigger>
</ControlTemplate.Triggers>

</ControlTemplate>
Expand Down Expand Up @@ -141,6 +144,9 @@
<TextBlock TextWrapping="Wrap"
FontStyle="Italic"
Text="{x:Static p:Resources.PackagePathViewSummary2}" />
<TextBlock TextWrapping="Wrap"
FontStyle="Italic"
Text="{x:Static p:Resources.PackagePathViewSummary3}" />
</StackPanel>

<TextBlock Grid.Row="1"
Expand Down
Loading