diff --git a/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs index e6073f476d..736148ab0f 100644 --- a/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs @@ -43,6 +43,7 @@ public sealed class CodeExplorerViewModel : ViewModelBase private readonly RemoveCommand _externalRemoveCommand; private readonly IConfigurationService _generalSettingsProvider; private readonly IConfigurationService _windowSettingsProvider; + private readonly IConfigurationService _projectSettingsProvider; private readonly IUiDispatcher _uiDispatcher; private readonly IVBE _vbe; private readonly ITemplateProvider _templateProvider; @@ -52,7 +53,8 @@ public CodeExplorerViewModel( RubberduckParserState state, RemoveCommand removeCommand, IConfigurationService generalSettingsProvider, - IConfigurationService windowSettingsProvider, + IConfigurationService windowSettingsProvider, + IConfigurationService projectSettingsProvider, IUiDispatcher uiDispatcher, IVBE vbe, ITemplateProvider templateProvider, @@ -66,8 +68,10 @@ public CodeExplorerViewModel( _generalSettingsProvider = generalSettingsProvider; _generalSettingsProvider.SettingsChanged += GeneralSettingsChanged; RefreshDragAndDropSetting(); + + _projectSettingsProvider = projectSettingsProvider; - _windowSettingsProvider = windowSettingsProvider; + _windowSettingsProvider = windowSettingsProvider; _uiDispatcher = uiDispatcher; _vbe = vbe; _templateProvider = templateProvider; diff --git a/Rubberduck.Core/Properties/Settings.Designer.cs b/Rubberduck.Core/Properties/Settings.Designer.cs index 6c0e8ff9c6..879eca1f9e 100644 --- a/Rubberduck.Core/Properties/Settings.Designer.cs +++ b/Rubberduck.Core/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace Rubberduck.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -25,15 +25,24 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - M - true - false - false - true - IndentCurrentModuleCommand -")] + public global::Rubberduck.Settings.AutoCompleteSettings Setting { + get { + return ((global::Rubberduck.Settings.AutoCompleteSettings)(this["Setting"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + M + true + false + false + true + IndentCurrentModuleCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_IndentCurrentModuleCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_IndentCurrentModuleCommand"])); @@ -42,15 +51,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - R - true - true - false - true - CodePaneRefactorRenameCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + R + true + true + false + true + CodePaneRefactorRenameCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_CodePaneRefactorRenameCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_CodePaneRefactorRenameCommand"])); @@ -59,15 +69,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - F - true - true - false - true - RefactorEncapsulateFieldCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + F + true + true + false + true + RefactorEncapsulateFieldCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_RefactorEncapsulateFieldCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_RefactorEncapsulateFieldCommand"])); @@ -76,15 +87,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - M - true - true - false - true - RefactorExtractMethodCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + M + true + true + false + true + RefactorExtractMethodCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_RefactorExtractMethodCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_RefactorExtractMethodCommand"])); @@ -93,15 +105,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - C - true - true - false - true - RefactorMoveCloserToUsageCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + C + true + true + false + true + RefactorMoveCloserToUsageCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_RefactorMoveCloserToUsageCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_RefactorMoveCloserToUsageCommand"])); @@ -110,15 +123,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - R - true - false - false - true - CodeExplorerCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + R + true + false + false + true + CodeExplorerCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_CodeExplorerCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_CodeExplorerCommand"])); @@ -127,15 +141,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - E - true - true - false - true - ExportAllCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + E + true + true + false + true + ExportAllCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_ExportAllCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_ExportAllCommand"])); @@ -144,15 +159,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - T - true - false - false - true - FindSymbolCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + T + true + false + false + true + FindSymbolCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_FindSymbolCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_FindSymbolCommand"])); @@ -161,15 +177,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - P - true - false - false - true - IndentCurrentProcedureCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + P + true + false + false + true + IndentCurrentProcedureCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_IndentCurrentProcedureCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_IndentCurrentProcedureCommand"])); @@ -178,15 +195,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - I - true - true - false - true - InspectionResultsCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + I + true + true + false + true + InspectionResultsCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_InspectionResultsCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_InspectionResultsCommand"])); @@ -195,15 +213,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - ` - true - false - false - true - ReparseCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + ` + true + false + false + true + ReparseCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_ReparseCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_ReparseCommand"])); @@ -212,15 +231,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - T - true - true - false - true - TestExplorerCommand -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + T + true + true + false + true + TestExplorerCommand + + ")] public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_TestExplorerCommand { get { return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_TestExplorerCommand"])); @@ -229,9 +249,8 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n ")] public global::Rubberduck.Settings.ToDoMarker ToDoMarker_ToDo { get { return ((global::Rubberduck.Settings.ToDoMarker)(this["ToDoMarker_ToDo"])); @@ -240,9 +259,8 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n ")] public global::Rubberduck.Settings.ToDoMarker ToDoMarker_Note { get { return ((global::Rubberduck.Settings.ToDoMarker)(this["ToDoMarker_Note"])); @@ -251,9 +269,8 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n ")] public global::Rubberduck.Settings.ToDoMarker ToDoMarker_Bug { get { return ((global::Rubberduck.Settings.ToDoMarker)(this["ToDoMarker_Bug"])); @@ -262,16 +279,17 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - false - false - false - false - true - false - false -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + false + false + false + false + true + false + false + + ")] public global::Rubberduck.Settings.WindowSettings WindowSettings { get { return ((global::Rubberduck.Settings.WindowSettings)(this["WindowSettings"])); @@ -280,20 +298,23 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - - true - true - true - false - false - 10 - false - 0 - false - -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + + true + true + false + true + false + false + 10 + false + 0 + false + false + + + ")] public global::Rubberduck.Settings.GeneralSettings GeneralSettings { get { return ((global::Rubberduck.Settings.GeneralSettings)(this["GeneralSettings"])); @@ -302,15 +323,16 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - - None - 25 - - - -")] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + + None + 25 + + + + + ")] public global::Rubberduck.Settings.AutoCompleteSettings AutoCompleteSettings { get { return ((global::Rubberduck.Settings.AutoCompleteSettings)(this["AutoCompleteSettings"])); @@ -319,9 +341,10 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n 0\r\n \r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n 0\r\n \r\n \r\n" + + " ")] public global::Rubberduck.Settings.ToDoGridViewColumnInfo ToDoGridViewColumnInfo_Description { get { return ((global::Rubberduck.Settings.ToDoGridViewColumnInfo)(this["ToDoGridViewColumnInfo_Description"])); @@ -330,9 +353,10 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n 1\r\n \r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n 1\r\n \r\n \r\n" + + " ")] public global::Rubberduck.Settings.ToDoGridViewColumnInfo ToDoGridViewColumnInfo_Project { get { return ((global::Rubberduck.Settings.ToDoGridViewColumnInfo)(this["ToDoGridViewColumnInfo_Project"])); @@ -341,9 +365,10 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n 2\r\n \r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n 2\r\n \r\n \r\n" + + " ")] public global::Rubberduck.Settings.ToDoGridViewColumnInfo ToDoGridViewColumnInfo_Module { get { return ((global::Rubberduck.Settings.ToDoGridViewColumnInfo)(this["ToDoGridViewColumnInfo_Module"])); @@ -352,13 +377,25 @@ public static Settings Default { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n 3\r\n \r\n")] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n 3\r\n \r\n \r\n" + + " ")] public global::Rubberduck.Settings.ToDoGridViewColumnInfo ToDoGridViewColumnInfo_LineNumber { get { return ((global::Rubberduck.Settings.ToDoGridViewColumnInfo)(this["ToDoGridViewColumnInfo_LineNumber"])); } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n \r\n 1\r\n \r\n ")] + public global::Rubberduck.Settings.ProjectSettings CodeExplorer_ImportCommand_OpenFileDialogFilterIndex { + get { + return ((global::Rubberduck.Settings.ProjectSettings)(this["CodeExplorer_ImportCommand_OpenFileDialogFilterIndex"])); + } + } } } diff --git a/Rubberduck.Core/Properties/Settings.settings b/Rubberduck.Core/Properties/Settings.settings index fe0adf7d83..dae2e37942 100644 --- a/Rubberduck.Core/Properties/Settings.settings +++ b/Rubberduck.Core/Properties/Settings.settings @@ -2,216 +2,250 @@ + + + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>M</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>false</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>IndentCurrentModuleCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>M</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>IndentCurrentModuleCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>R</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>CodePaneRefactorRenameCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>R</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>CodePaneRefactorRenameCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>F</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>RefactorEncapsulateFieldCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>F</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>RefactorEncapsulateFieldCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>M</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>RefactorExtractMethodCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>M</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>RefactorExtractMethodCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>C</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>RefactorMoveCloserToUsageCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>C</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>RefactorMoveCloserToUsageCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>R</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>false</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>CodeExplorerCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>R</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>CodeExplorerCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>E</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>ExportAllCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>E</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>ExportAllCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>T</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>false</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>FindSymbolCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>T</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>FindSymbolCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>P</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>false</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>IndentCurrentProcedureCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>P</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>IndentCurrentProcedureCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>I</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>InspectionResultsCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>I</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>InspectionResultsCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>`</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>false</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>ReparseCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>`</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>ReparseCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Key1>T</Key1> - <IsEnabled>true</IsEnabled> - <HasShiftModifier>true</HasShiftModifier> - <HasAltModifier>false</HasAltModifier> - <HasCtrlModifier>true</HasCtrlModifier> - <CommandTypeName>TestExplorerCommand</CommandTypeName> -</HotkeySetting> + + <HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>T</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>TestExplorerCommand</CommandTypeName> + </HotkeySetting> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="TODO" /> + + <ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="TODO" /> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="NOTE" /> + + <ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="NOTE" /> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="BUG" /> + + <ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="BUG" /> + - <?xml version="1.0" encoding="utf-16"?> -<WindowSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <CodeExplorerVisibleOnStartup>false</CodeExplorerVisibleOnStartup> - <CodeInspectionsVisibleOnStartup>false</CodeInspectionsVisibleOnStartup> - <TestExplorerVisibleOnStartup>false</TestExplorerVisibleOnStartup> - <TodoExplorerVisibleOnStartup>false</TodoExplorerVisibleOnStartup> - <CodeExplorer_SortByName>true</CodeExplorer_SortByName> - <CodeExplorer_SortByCodeOrder>false</CodeExplorer_SortByCodeOrder> - <CodeExplorer_GroupByType>false</CodeExplorer_GroupByType> -</WindowSettings> + + <WindowSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <CodeExplorerVisibleOnStartup>false</CodeExplorerVisibleOnStartup> + <CodeInspectionsVisibleOnStartup>false</CodeInspectionsVisibleOnStartup> + <TestExplorerVisibleOnStartup>false</TestExplorerVisibleOnStartup> + <TodoExplorerVisibleOnStartup>false</TodoExplorerVisibleOnStartup> + <CodeExplorer_SortByName>true</CodeExplorer_SortByName> + <CodeExplorer_SortByCodeOrder>false</CodeExplorer_SortByCodeOrder> + <CodeExplorer_GroupByType>false</CodeExplorer_GroupByType> + </WindowSettings> + - <?xml version="1.0" encoding="utf-16"?> -<GeneralSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Language Code="en-US" /> - <CanShowSplash>true</CanShowSplash> - <CanCheckVersion>true</CanCheckVersion> - <CompileBeforeParse>true</CompileBeforeParse> - <IsSmartIndenterPrompted>false</IsSmartIndenterPrompted> - <IsAutoSaveEnabled>false</IsAutoSaveEnabled> - <AutoSavePeriod>10</AutoSavePeriod> - <UserEditedLogLevel>false</UserEditedLogLevel> - <MinimumLogLevel>0</MinimumLogLevel> - <SetDpiUnaware>false</SetDpiUnaware> - <EnableExperimentalFeatures /> -</GeneralSettings> + + <GeneralSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Language Code="en-US" /> + <CanShowSplash>true</CanShowSplash> + <CanCheckVersion>true</CanCheckVersion> + <IncludePreRelease>false</IncludePreRelease> + <CompileBeforeParse>true</CompileBeforeParse> + <IsSmartIndenterPrompted>false</IsSmartIndenterPrompted> + <IsAutoSaveEnabled>false</IsAutoSaveEnabled> + <AutoSavePeriod>10</AutoSavePeriod> + <UserEditedLogLevel>false</UserEditedLogLevel> + <MinimumLogLevel>0</MinimumLogLevel> + <SetDpiUnaware>false</SetDpiUnaware> + <EnableFolderDragAndDrop>false</EnableFolderDragAndDrop> + <EnableExperimentalFeatures /> + </GeneralSettings> + - <?xml version="1.0" encoding="utf-16"?> -<AutoCompleteSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" IsEnabled="true"> - <SmartConcat IsEnabled="true"> - <ConcatVbNewLineModifier>None</ConcatVbNewLineModifier> - <ConcatMaxLines>25</ConcatMaxLines> - </SmartConcat> - <SelfClosingPairs IsEnabled="true" /> - <BlockCompletion IsEnabled="false" CompleteOnEnter="false" CompleteOnTab="false" /> -</AutoCompleteSettings> + + <AutoCompleteSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" IsEnabled="true"> + <SmartConcat IsEnabled="true"> + <ConcatVbNewLineModifier>None</ConcatVbNewLineModifier> + <ConcatMaxLines>25</ConcatMaxLines> + </SmartConcat> + <SelfClosingPairs IsEnabled="true" /> + <BlockCompletion IsEnabled="true" CompleteOnEnter="true" CompleteOnTab="true" /> + </AutoCompleteSettings> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <DisplayIndex>0</DisplayIndex> - <Width /> -</ToDoGridViewColumnInfo> + + <ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <DisplayIndex>0</DisplayIndex> + <Width /> + </ToDoGridViewColumnInfo> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <DisplayIndex>1</DisplayIndex> - <Width /> -</ToDoGridViewColumnInfo> + + <ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <DisplayIndex>1</DisplayIndex> + <Width /> + </ToDoGridViewColumnInfo> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <DisplayIndex>2</DisplayIndex> - <Width /> -</ToDoGridViewColumnInfo> + + <ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <DisplayIndex>2</DisplayIndex> + <Width /> + </ToDoGridViewColumnInfo> + - <?xml version="1.0" encoding="utf-16"?> -<ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <DisplayIndex>3</DisplayIndex> - <Width /> -</ToDoGridViewColumnInfo> + + <ToDoGridViewColumnInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <DisplayIndex>3</DisplayIndex> + <Width /> + </ToDoGridViewColumnInfo> + + + + + <ProjectSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <OpenFileDialogFilterIndex>1</OpenFileDialogFilterIndex> + </ProjectSettings> + - + \ No newline at end of file diff --git a/Rubberduck.Core/Rubberduck.Core.csproj b/Rubberduck.Core/Rubberduck.Core.csproj index 2960a7b9fb..d4fdf5229b 100644 --- a/Rubberduck.Core/Rubberduck.Core.csproj +++ b/Rubberduck.Core/Rubberduck.Core.csproj @@ -103,5 +103,16 @@ ResXFileCodeGenerator Resources.Designer.cs + + True + True + Settings.settings + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + diff --git a/Rubberduck.Core/Settings/ConfigurationLoader.cs b/Rubberduck.Core/Settings/ConfigurationLoader.cs index ea53c7f105..1c6dc1a927 100644 --- a/Rubberduck.Core/Settings/ConfigurationLoader.cs +++ b/Rubberduck.Core/Settings/ConfigurationLoader.cs @@ -18,6 +18,7 @@ public class ConfigurationLoader : IConfigurationService private readonly IConfigurationService _unitTestProvider; private readonly IConfigurationService _indenterProvider; private readonly IConfigurationService _windowProvider; + private readonly IConfigurationService _projectSettingsProvider; public ConfigurationLoader(IConfigurationService generalProvider, IConfigurationService hotkeyProvider, @@ -26,7 +27,8 @@ public ConfigurationLoader(IConfigurationService generalProvide IConfigurationService inspectionProvider, IConfigurationService unitTestProvider, IConfigurationService indenterProvider, - IConfigurationService windowProvider) + IConfigurationService windowProvider, + IConfigurationService projectSettingsProvider) { _generalProvider = generalProvider; _hotkeyProvider = hotkeyProvider; @@ -36,6 +38,7 @@ public ConfigurationLoader(IConfigurationService generalProvide _unitTestProvider = unitTestProvider; _indenterProvider = indenterProvider; _windowProvider = windowProvider; + _projectSettingsProvider = projectSettingsProvider; } /// @@ -55,7 +58,8 @@ public virtual Configuration Read() _inspectionProvider.Read(), _unitTestProvider.Read(), _indenterProvider.Read(), - _windowProvider.Read() + _windowProvider.Read(), + _projectSettingsProvider.Read() ) }; return config; @@ -74,7 +78,8 @@ public Configuration ReadDefaults() _inspectionProvider.ReadDefaults(), _unitTestProvider.ReadDefaults(), _indenterProvider.ReadDefaults(), - _windowProvider.ReadDefaults() + _windowProvider.ReadDefaults(), + _projectSettingsProvider.ReadDefaults() ) }; } @@ -91,6 +96,10 @@ public void Save(Configuration toSerialize) var newAutoCompleteSettings = toSerialize.UserSettings.AutoCompleteSettings; var autoCompletesChanged = oldAutoCompleteSettings.Equals(newAutoCompleteSettings); + var oldProjectSettings = _projectSettingsProvider.Read(); + var newProjectSettings = toSerialize.UserSettings.ProjectSettings; + var openFileDialogFilterIndexChanged = oldProjectSettings.OpenFileDialogFilterIndex != newProjectSettings.OpenFileDialogFilterIndex; + _generalProvider.Save(toSerialize.UserSettings.GeneralSettings); _hotkeyProvider.Save(toSerialize.UserSettings.HotkeySettings); _autoCompleteProvider.Save(toSerialize.UserSettings.AutoCompleteSettings); @@ -99,8 +108,9 @@ public void Save(Configuration toSerialize) _unitTestProvider.Save(toSerialize.UserSettings.UnitTestSettings); _indenterProvider.Save(toSerialize.UserSettings.IndenterSettings); _windowProvider.Save(toSerialize.UserSettings.WindowSettings); + _projectSettingsProvider.Save(toSerialize.UserSettings.ProjectSettings); - OnSettingsChanged(new ConfigurationChangedEventArgs(inspectOnReparse, langChanged, inspectionsChanged, autoCompletesChanged)); + OnSettingsChanged(new ConfigurationChangedEventArgs(inspectOnReparse, langChanged, inspectionsChanged, autoCompletesChanged, openFileDialogFilterIndexChanged)); } public event EventHandler SettingsChanged; @@ -122,7 +132,8 @@ public Configuration Import(string fileName) _inspectionProvider.Import(fileName), _unitTestProvider.Import(fileName), _indenterProvider.Import(fileName), - _windowProvider.Import(fileName) + _windowProvider.Import(fileName), + _projectSettingsProvider.Import(fileName) ) }; } diff --git a/Rubberduck.Core/Settings/ProjectSettings.cs b/Rubberduck.Core/Settings/ProjectSettings.cs new file mode 100644 index 0000000000..5d8cf225d7 --- /dev/null +++ b/Rubberduck.Core/Settings/ProjectSettings.cs @@ -0,0 +1,36 @@ +using System; +using System.Configuration; +using System.Xml.Serialization; + +namespace Rubberduck.Settings +{ + public interface IProjectSettings + { + int OpenFileDialogFilterIndex { get; set; } + } + + [SettingsSerializeAs(SettingsSerializeAs.Xml)] + [XmlType(AnonymousType = true)] + public class ProjectSettings : IProjectSettings, IEquatable + { + [XmlElement(Type = typeof(int))] + public int OpenFileDialogFilterIndex { get; set; } = 1; + + /// + /// Default constructor required for XML serialization. + /// + public ProjectSettings() + { + } + + public ProjectSettings(int openFileDialogFilterIndex) + { + OpenFileDialogFilterIndex = openFileDialogFilterIndex; + } + + public bool Equals(ProjectSettings other) + { + return OpenFileDialogFilterIndex == other.OpenFileDialogFilterIndex; + } + } +} diff --git a/Rubberduck.Core/Settings/UserSettings.cs b/Rubberduck.Core/Settings/UserSettings.cs index 3c19cade1c..505f8eddd5 100644 --- a/Rubberduck.Core/Settings/UserSettings.cs +++ b/Rubberduck.Core/Settings/UserSettings.cs @@ -16,6 +16,7 @@ public class UserSettings public UnitTestSettings UnitTestSettings { get; set; } public IndenterSettings IndenterSettings { get; set; } public WindowSettings WindowSettings { get; set; } + public ProjectSettings ProjectSettings { get; set; } public UserSettings(GeneralSettings generalSettings, HotkeySettings hotkeySettings, @@ -24,7 +25,8 @@ public UserSettings(GeneralSettings generalSettings, CodeInspectionSettings codeInspectionSettings, UnitTestSettings unitTestSettings, IndenterSettings indenterSettings, - WindowSettings windowSettings) + WindowSettings windowSettings, + ProjectSettings projectSettings) { GeneralSettings = generalSettings; HotkeySettings = hotkeySettings; @@ -34,6 +36,7 @@ public UserSettings(GeneralSettings generalSettings, UnitTestSettings = unitTestSettings; IndenterSettings = indenterSettings; WindowSettings = windowSettings; + ProjectSettings = projectSettings; } } } diff --git a/Rubberduck.Core/UI/CodeExplorer/Commands/ImportCommand.cs b/Rubberduck.Core/UI/CodeExplorer/Commands/ImportCommand.cs index df2af27c10..9a202cee25 100644 --- a/Rubberduck.Core/UI/CodeExplorer/Commands/ImportCommand.cs +++ b/Rubberduck.Core/UI/CodeExplorer/Commands/ImportCommand.cs @@ -10,6 +10,8 @@ using Rubberduck.Parsing.VBA; using Rubberduck.Parsing.VBA.DeclarationCaching; using Rubberduck.Resources; +using Rubberduck.Settings; +using Rubberduck.SettingsProvider; using Rubberduck.VBEditor; using Rubberduck.VBEditor.ComManagement; using Rubberduck.VBEditor.Events; @@ -38,6 +40,7 @@ public class ImportCommand : CodeExplorerCommandBase private readonly IModuleNameFromFileExtractor _moduleNameFromFileExtractor; private readonly IDictionary> _binaryFileExtractors; private readonly IFileSystem _fileSystem; + private readonly IConfigurationService _projectSettingsProvider; protected readonly IDeclarationFinderProvider DeclarationFinderProvider; protected readonly IMessageBox MessageBox; @@ -52,7 +55,8 @@ public ImportCommand( IModuleNameFromFileExtractor moduleNameFromFileExtractor, IEnumerable binaryFileExtractors, IFileSystem fileSystem, - IMessageBox messageBox) + IMessageBox messageBox, + IConfigurationService projectSettingsProvider) : base(vbeEvents) { _vbe = vbe; @@ -67,6 +71,8 @@ public ImportCommand( MessageBox = messageBox; DeclarationFinderProvider = declarationFinderProvider; + _projectSettingsProvider = projectSettingsProvider; + AddToCanExecuteEvaluation(SpecialEvaluateCanExecute); ComponentTypesForExtension = ComponentTypeExtensions.ComponentTypesForExtension(_vbe.Kind); @@ -146,8 +152,21 @@ private IDictionary FilesToImport(object parameter) { + if (_cachedProjectSettings == null) + { + _cachedProjectSettings = _projectSettingsProvider.Read(); + } + using (var dialog = _dialogFactory.CreateOpenFileDialog()) { dialog.AddExtension = true; @@ -157,15 +176,33 @@ protected virtual ICollection FilesToImport(object parameter) dialog.Multiselect = true; dialog.ShowHelp = false; dialog.Title = DialogsTitle; - dialog.Filter = - $"{RubberduckUI.ImportCommand_OpenDialog_Filter_VBFiles} ({FilterExtension})|{FilterExtension}|" + - $"{RubberduckUI.ImportCommand_OpenDialog_Filter_AllFiles}, (*.*)|*.*"; + dialog.FilterIndex = _cachedProjectSettings.OpenFileDialogFilterIndex; + var vbFilesFilter = IndividualFilter(RubberduckUI.ImportCommand_OpenDialog_Filter_VBFiles, FilterExtension); + var nonDocumentModulesFilter = IndividualFilter(Resources.CodeExplorer.CodeExplorerUI.ImportCommand_OpenDialog_Filter_NonDocumentModules, AllNonDocumentModulesExtension); + var standardModulesFilter = IndividualFilter(Resources.CodeExplorer.CodeExplorerUI.ImportCommand_OpenDialog_Filter_StandardModules, StandardModuleExtension); + var classModulesFilter = IndividualFilter(Resources.CodeExplorer.CodeExplorerUI.ImportCommand_OpenDialog_Filter_ClassModules, ClassModuleExtension); + var formModulesFilter = IndividualFilter(Resources.CodeExplorer.CodeExplorerUI.ImportCommand_OpenDialog_Filter_FormModules, FormModuleExtension); + var documentModulesFilter = IndividualFilter(Resources.CodeExplorer.CodeExplorerUI.ImportCommand_OpenDialog_Filter_DocumentModules, DocumentModuleExtension); + var allFilesFilter = IndividualFilter(RubberduckUI.ImportCommand_OpenDialog_Filter_AllFiles, "*.*"); + dialog.Filter = CompositeFilter("|", + vbFilesFilter, + nonDocumentModulesFilter, + standardModulesFilter, + classModulesFilter, + formModulesFilter, + documentModulesFilter, + allFilesFilter); if (dialog.ShowDialog() != DialogResult.OK) { return new List(); } + if (_cachedProjectSettings.OpenFileDialogFilterIndex != dialog.FilterIndex) + { + UpdateFilterIndex(dialog.FilterIndex); + } + var fileNames = dialog.FileNames; var fileExtensions = fileNames.Select(Path.GetExtension); if (fileExtensions.Any(fileExt => !ImportableExtensions.Contains(fileExt))) @@ -176,6 +213,18 @@ protected virtual ICollection FilesToImport(object parameter) return fileNames; } + + string IndividualFilter(string filterDescription, string fileExtension) + { + return fileExtension != null + ? $"{filterDescription} ({fileExtension})|{fileExtension}" + : null; + } + + string CompositeFilter(string separator, params string[] filters) + { + return string.Join(separator, filters.Where(filter => !string.IsNullOrEmpty(filter))); + } } protected virtual string DialogsTitle => RubberduckUI.ImportCommand_OpenDialog_Title; @@ -562,6 +611,18 @@ protected override void OnExecute(object parameter) private string FilterExtension => string.Join("; ", ImportableExtensions.Select(ext => $"*{ext}")); + private string AllNonDocumentModulesExtension => string.Join("; ", + ImportableExtensions.Where(ext => !ext.EndsWith("doccls")) + .Select(ext => $"*{ext}")); + + private string StandardModuleExtension => "*" + ImportableExtensions.Where(ext => ext.EndsWith("bas")).FirstOrDefault(); + + private string ClassModuleExtension => "*" + ImportableExtensions.Where(ext => ext.EndsWith(".cls")).FirstOrDefault(); + + private string FormModuleExtension => "*" + ImportableExtensions.Where(ext => ext.EndsWith("frm")).FirstOrDefault(); + + private string DocumentModuleExtension => "*" + ImportableExtensions.Where(ext => ext.EndsWith("doccls")).FirstOrDefault(); + protected IDictionary> ComponentTypesForExtension { get; } } } \ No newline at end of file diff --git a/Rubberduck.Core/UI/CodeExplorer/Commands/ReplaceProjectContentsFromFilesCommand.cs b/Rubberduck.Core/UI/CodeExplorer/Commands/ReplaceProjectContentsFromFilesCommand.cs index 805ad0b1df..a4490be681 100644 --- a/Rubberduck.Core/UI/CodeExplorer/Commands/ReplaceProjectContentsFromFilesCommand.cs +++ b/Rubberduck.Core/UI/CodeExplorer/Commands/ReplaceProjectContentsFromFilesCommand.cs @@ -6,6 +6,8 @@ using Rubberduck.Parsing.Symbols; using Rubberduck.Parsing.VBA; using Rubberduck.Resources; +using Rubberduck.Settings; +using Rubberduck.SettingsProvider; using Rubberduck.VBEditor; using Rubberduck.VBEditor.ComManagement; using Rubberduck.VBEditor.Events; @@ -26,8 +28,9 @@ public ReplaceProjectContentsFromFilesCommand( IModuleNameFromFileExtractor moduleNameFromFileExtractor, IEnumerable binaryFileExtractors, IFileSystem fileSystem, - IMessageBox messageBox) - :base(vbe, dialogFactory, vbeEvents, parseManager, declarationFinderProvider, projectsProvider, moduleNameFromFileExtractor, binaryFileExtractors, fileSystem, messageBox) + IMessageBox messageBox, + IConfigurationService projectSettingsProvider) + :base(vbe, dialogFactory, vbeEvents, parseManager, declarationFinderProvider, projectsProvider, moduleNameFromFileExtractor, binaryFileExtractors, fileSystem, messageBox, projectSettingsProvider) {} protected override string DialogsTitle => RubberduckUI.ReplaceProjectContentsFromFilesCommand_DialogCaption; diff --git a/Rubberduck.Core/UI/CodeExplorer/Commands/UpdateFromFileCommand.cs b/Rubberduck.Core/UI/CodeExplorer/Commands/UpdateFromFileCommand.cs index 4af827133a..84e5122118 100644 --- a/Rubberduck.Core/UI/CodeExplorer/Commands/UpdateFromFileCommand.cs +++ b/Rubberduck.Core/UI/CodeExplorer/Commands/UpdateFromFileCommand.cs @@ -3,6 +3,8 @@ using Rubberduck.Interaction; using Rubberduck.Parsing.VBA; using Rubberduck.Resources; +using Rubberduck.Settings; +using Rubberduck.SettingsProvider; using Rubberduck.VBEditor; using Rubberduck.VBEditor.Events; using Rubberduck.VBEditor.ComManagement; @@ -25,8 +27,9 @@ public UpdateFromFilesCommand( IModuleNameFromFileExtractor moduleNameFromFileExtractor, IEnumerable binaryFileExtractors, IFileSystem fileSystem, - IMessageBox messageBox) - : base(vbe, dialogFactory, vbeEvents, parseManager, declarationFinderProvider, projectsProvider, moduleNameFromFileExtractor, binaryFileExtractors, fileSystem, messageBox) + IMessageBox messageBox, + IConfigurationService projectSettingsProvider) + : base(vbe, dialogFactory, vbeEvents, parseManager, declarationFinderProvider, projectsProvider, moduleNameFromFileExtractor, binaryFileExtractors, fileSystem, messageBox, projectSettingsProvider) {} protected override string DialogsTitle => RubberduckUI.UpdateFromFilesCommand_DialogCaption; diff --git a/Rubberduck.Core/app.config b/Rubberduck.Core/app.config index b2fcaac379..c18c950e55 100644 --- a/Rubberduck.Core/app.config +++ b/Rubberduck.Core/app.config @@ -273,6 +273,15 @@ + + + + 1 + + + diff --git a/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.Designer.cs b/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.Designer.cs index 1f58086ca7..b646e3a135 100644 --- a/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.Designer.cs +++ b/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.Designer.cs @@ -788,6 +788,51 @@ public static System.Drawing.Bitmap FolderOpen { } } + /// + /// Looks up a localized string similar to Class modules. + /// + public static string ImportCommand_OpenDialog_Filter_ClassModules { + get { + return ResourceManager.GetString("ImportCommand_OpenDialog_Filter_ClassModules", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Document modules. + /// + public static string ImportCommand_OpenDialog_Filter_DocumentModules { + get { + return ResourceManager.GetString("ImportCommand_OpenDialog_Filter_DocumentModules", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Form modules. + /// + public static string ImportCommand_OpenDialog_Filter_FormModules { + get { + return ResourceManager.GetString("ImportCommand_OpenDialog_Filter_FormModules", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Non-document modules. + /// + public static string ImportCommand_OpenDialog_Filter_NonDocumentModules { + get { + return ResourceManager.GetString("ImportCommand_OpenDialog_Filter_NonDocumentModules", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Standard modules. + /// + public static string ImportCommand_OpenDialog_Filter_StandardModules { + get { + return ResourceManager.GetString("ImportCommand_OpenDialog_Filter_StandardModules", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.resx b/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.resx index c6337af7be..28935557cc 100644 --- a/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.resx +++ b/Rubberduck.Resources/CodeExplorer/CodeExplorerUI.resx @@ -461,4 +461,19 @@ Continue? Annotate + + Class modules + + + Document modules + + + Form modules + + + Non-document modules + + + Standard modules + \ No newline at end of file diff --git a/Rubberduck.Resources/Rubberduck.Resources.csproj b/Rubberduck.Resources/Rubberduck.Resources.csproj index 1d1ae891d0..215a912a20 100644 --- a/Rubberduck.Resources/Rubberduck.Resources.csproj +++ b/Rubberduck.Resources/Rubberduck.Resources.csproj @@ -27,6 +27,9 @@ + + True + True diff --git a/Rubberduck.SettingsProvider/Facade/ConfigurationServiceBase.cs b/Rubberduck.SettingsProvider/Facade/ConfigurationServiceBase.cs index c28181f254..ecb00ffa2e 100644 --- a/Rubberduck.SettingsProvider/Facade/ConfigurationServiceBase.cs +++ b/Rubberduck.SettingsProvider/Facade/ConfigurationServiceBase.cs @@ -20,7 +20,7 @@ public ConfigurationServiceBase(IPersistenceService persister, IDefaultSettin protected void OnSettingsChanged() { - var eventArgs = new ConfigurationChangedEventArgs(false, false, false, false); + var eventArgs = new ConfigurationChangedEventArgs(false, false, false, false, false); SettingsChanged?.Invoke(this, eventArgs); } diff --git a/Rubberduck.SettingsProvider/Facade/IConfigurationService.cs b/Rubberduck.SettingsProvider/Facade/IConfigurationService.cs index 9c8e192521..65b3dd7e19 100644 --- a/Rubberduck.SettingsProvider/Facade/IConfigurationService.cs +++ b/Rubberduck.SettingsProvider/Facade/IConfigurationService.cs @@ -20,13 +20,16 @@ public class ConfigurationChangedEventArgs : EventArgs public bool InspectionSettingsChanged { get; } public bool RunInspectionsOnReparse { get; } public bool AutoCompleteSettingsChanged { get; } + public bool OpenFileDialogFilterIndexChanged { get; } - public ConfigurationChangedEventArgs(bool runInspections, bool languageChanged, bool inspectionSettingsChanged, bool autoCompleteSettingsChanged) + public ConfigurationChangedEventArgs(bool runInspections, bool languageChanged, bool inspectionSettingsChanged, bool autoCompleteSettingsChanged, + bool openFileDialogFilterIndexChanged) { AutoCompleteSettingsChanged = autoCompleteSettingsChanged; RunInspectionsOnReparse = runInspections; LanguageChanged = languageChanged; InspectionSettingsChanged = inspectionSettingsChanged; + OpenFileDialogFilterIndexChanged = openFileDialogFilterIndexChanged; } } } \ No newline at end of file diff --git a/RubberduckTests/CodeExplorer/CodeExplorerViewModelTests.cs b/RubberduckTests/CodeExplorer/CodeExplorerViewModelTests.cs index 90f8800d6c..086951166b 100644 --- a/RubberduckTests/CodeExplorer/CodeExplorerViewModelTests.cs +++ b/RubberduckTests/CodeExplorer/CodeExplorerViewModelTests.cs @@ -725,6 +725,188 @@ public void ImportCommand_DocumentWithoutExistingModule_Aborts() } } + [Category("CodeExplorer")] + [Test] + [TestCase(1, 1)] + [TestCase(2, 2)] + public void OpenFileDialog_filterIndex_matches_cached_value_Saving_filterIndex_to_config_file_doesnt_occur(int configFilterIndex, int selectedFilterIndex) + { + const string path = @"C:\Users\Rubberduck\Desktop\StdModule.bas"; + const string code = @"Option Explicit + +Public Sub FooBar() + +End Sub"; + var openDialog = new Mock(); + openDialog.Setup(dialog => dialog.ShowDialog()).Returns(DialogResult.OK); + openDialog.Setup(dialog => dialog.FileNames).Returns(new[] { path }); + openDialog.Setup(dialog => dialog.FilterIndex).Returns(selectedFilterIndex); + using (var mockedCodeExplorer = new MockedCodeExplorer(ProjectType.HostProject) + .ConfigureOpenDialog(openDialog.Object) + .SelectFirstProject()) + { + var vbe = MockVbeBuilder.BuildFromSingleStandardModule(code, out _); + var state = MockParser.CreateAndParse(vbe.Object); + + var generalSettings = new GeneralSettings(); + var generalSettingsProvider = new Mock>(); + generalSettingsProvider.Setup(provider => provider.Read()) + .Returns(generalSettings); + + var projectSettings = new ProjectSettings(configFilterIndex); + var projectSettingsProvider = new Mock>(); + projectSettingsProvider.Setup(provider => provider.Read()) + .Returns(projectSettings); + + var vbeEvents = MockVbeEvents.CreateMockVbeEvents(vbe); + var codeExplorerSyncProvider = new CodeExplorerSyncProvider(vbe.Object, state, vbeEvents.Object); + + var viewModel = new CodeExplorerViewModel(state, null, generalSettingsProvider.Object, null, projectSettingsProvider.Object, null, vbe.Object, null, codeExplorerSyncProvider, new List()); + mockedCodeExplorer.ViewModel = viewModel; + + mockedCodeExplorer.ExecuteImportCommand(projectSettingsProvider: projectSettingsProvider); + + projectSettingsProvider.Verify(provider => provider.Save(projectSettings), Times.Never()); + Assert.AreEqual(selectedFilterIndex, projectSettings.OpenFileDialogFilterIndex); + } + } + + [Category("CodeExplorer")] + [Test] + [TestCase(1, 2)] + [TestCase(2, 1)] + public void OpenFileDialog_filterIndex_differs_from_cached_value_Saving_filterIndex_to_config_file_occurs(int configFilterIndex, int selectedFilterIndex) + { + const string path = @"C:\Users\Rubberduck\Desktop\StdModule.bas"; + const string code = @"Option Explicit + +Public Sub FooBar() + +End Sub"; + var openDialog = new Mock(); + openDialog.Setup(dialog => dialog.ShowDialog()).Returns(DialogResult.OK); + openDialog.Setup(dialog => dialog.FileNames).Returns(new[] { path }); + openDialog.Setup(dialog => dialog.FilterIndex).Returns(selectedFilterIndex); + using (var mockedCodeExplorer = new MockedCodeExplorer(ProjectType.HostProject) + .ConfigureOpenDialog(openDialog.Object) + .SelectFirstProject()) + { + var vbe = MockVbeBuilder.BuildFromSingleStandardModule(code, out _); + var state = MockParser.CreateAndParse(vbe.Object); + + var generalSettings = new GeneralSettings(); + var generalSettingsProvider = new Mock>(); + generalSettingsProvider.Setup(provider => provider.Read()) + .Returns(generalSettings); + + var projectSettings = new ProjectSettings(configFilterIndex); + var projectSettingsProvider = new Mock>(); + projectSettingsProvider.Setup(provider => provider.Read()) + .Returns(projectSettings); + + var vbeEvents = MockVbeEvents.CreateMockVbeEvents(vbe); + var codeExplorerSyncProvider = new CodeExplorerSyncProvider(vbe.Object, state, vbeEvents.Object); + + var viewModel = new CodeExplorerViewModel(state, null, generalSettingsProvider.Object, null, projectSettingsProvider.Object, null, vbe.Object, null, codeExplorerSyncProvider, new List()); + mockedCodeExplorer.ViewModel = viewModel; + + mockedCodeExplorer.ExecuteImportCommand(projectSettingsProvider: projectSettingsProvider); + + projectSettingsProvider.Verify(provider => provider.Save(projectSettings), Times.Once()); + Assert.AreEqual(selectedFilterIndex, projectSettings.OpenFileDialogFilterIndex); + } + } + + [Category("CodeExplorer")] + [Test] + [TestCase(1, 2)] + [TestCase(2, 1)] + public void OpenFileDialog_filterIndex_differs_from_cached_value_Canceling_dialog_doesnt_save(int configFilterIndex, int selectedFilterIndex) + { + const string path = @"C:\Users\Rubberduck\Desktop\StdModule.bas"; + const string code = @"Option Explicit + +Public Sub FooBar() + +End Sub"; + var openDialog = new Mock(); + openDialog.Setup(dialog => dialog.ShowDialog()).Returns(DialogResult.Cancel); + openDialog.Setup(dialog => dialog.FileNames).Returns(new[] { path }); + openDialog.Setup(dialog => dialog.FilterIndex).Returns(selectedFilterIndex); + using (var mockedCodeExplorer = new MockedCodeExplorer(ProjectType.HostProject) + .ConfigureOpenDialog(openDialog.Object) + .SelectFirstProject()) + { + var vbe = MockVbeBuilder.BuildFromSingleStandardModule(code, out _); + var state = MockParser.CreateAndParse(vbe.Object); + + var generalSettings = new GeneralSettings(); + var generalSettingsProvider = new Mock>(); + generalSettingsProvider.Setup(provider => provider.Read()) + .Returns(generalSettings); + + var projectSettings = new ProjectSettings(configFilterIndex); + var projectSettingsProvider = new Mock>(); + projectSettingsProvider.Setup(provider => provider.Read()) + .Returns(projectSettings); + + var vbeEvents = MockVbeEvents.CreateMockVbeEvents(vbe); + var codeExplorerSyncProvider = new CodeExplorerSyncProvider(vbe.Object, state, vbeEvents.Object); + + var viewModel = new CodeExplorerViewModel(state, null, generalSettingsProvider.Object, null, projectSettingsProvider.Object, null, vbe.Object, null, codeExplorerSyncProvider, new List()); + mockedCodeExplorer.ViewModel = viewModel; + + mockedCodeExplorer.ExecuteImportCommand(projectSettingsProvider: projectSettingsProvider); + + projectSettingsProvider.Verify(provider => provider.Save(projectSettings), Times.Never()); + } + } + + [Category("CodeExplorer")] + [Test] + [TestCase(1, 2)] + [TestCase(2, 1)] + public void OpenFileDialog_filterIndex_differs_from_cached_value_Canceling_doesnt_update_cached_filterIndex(int configFilterIndex, int selectedFilterIndex) + { + const string path = @"C:\Users\Rubberduck\Desktop\StdModule.bas"; + const string code = @"Option Explicit + +Public Sub FooBar() + +End Sub"; + var openDialog = new Mock(); + openDialog.Setup(dialog => dialog.ShowDialog()).Returns(DialogResult.Cancel); + openDialog.Setup(dialog => dialog.FileNames).Returns(new[] { path }); + openDialog.Setup(dialog => dialog.FilterIndex).Returns(selectedFilterIndex); + using (var mockedCodeExplorer = new MockedCodeExplorer(ProjectType.HostProject) + .ConfigureOpenDialog(openDialog.Object) + .SelectFirstProject()) + { + var vbe = MockVbeBuilder.BuildFromSingleStandardModule(code, out _); + var state = MockParser.CreateAndParse(vbe.Object); + + var generalSettings = new GeneralSettings(); + var generalSettingsProvider = new Mock>(); + generalSettingsProvider.Setup(provider => provider.Read()) + .Returns(generalSettings); + + var projectSettings = new ProjectSettings(configFilterIndex); + var projectSettingsProvider = new Mock>(); + projectSettingsProvider.Setup(provider => provider.Read()) + .Returns(projectSettings); + + var vbeEvents = MockVbeEvents.CreateMockVbeEvents(vbe); + var codeExplorerSyncProvider = new CodeExplorerSyncProvider(vbe.Object, state, vbeEvents.Object); + + var viewModel = new CodeExplorerViewModel(state, null, generalSettingsProvider.Object, null, projectSettingsProvider.Object, null, vbe.Object, null, codeExplorerSyncProvider, new List()); + mockedCodeExplorer.ViewModel = viewModel; + + mockedCodeExplorer.ExecuteImportCommand(projectSettingsProvider: projectSettingsProvider); + + Assert.AreEqual(projectSettings.OpenFileDialogFilterIndex, configFilterIndex); + } + } + [Category("Code Explorer")] [Test] public void ImportModule_Cancel() @@ -2365,11 +2547,11 @@ public void UnparsedSetToTrue_NoProjects() var generalSettingsProvider = new Mock>(); var generalSettings = new GeneralSettings(); generalSettingsProvider.Setup(m => m.Read()).Returns(generalSettings); - + dispatcher.Setup(m => m.Invoke(It.IsAny())).Callback((Action argument) => argument.Invoke()); dispatcher.Setup(m => m.StartTask(It.IsAny(), It.IsAny())).Returns((Action argument, TaskCreationOptions options) => Task.Factory.StartNew(argument.Invoke, options)); - var viewModel = new CodeExplorerViewModel(state, null, generalSettingsProvider.Object, null, dispatcher.Object, vbe.Object, null, + var viewModel = new CodeExplorerViewModel(state, null, generalSettingsProvider.Object, null, null,dispatcher.Object, vbe.Object, null, new CodeExplorerSyncProvider(vbe.Object, state, vbeEvents.Object), new List()); parser.Parse(new CancellationTokenSource()); diff --git a/RubberduckTests/CodeExplorer/MockedCodeExplorer.cs b/RubberduckTests/CodeExplorer/MockedCodeExplorer.cs index 19239633f9..ac5c29c977 100644 --- a/RubberduckTests/CodeExplorer/MockedCodeExplorer.cs +++ b/RubberduckTests/CodeExplorer/MockedCodeExplorer.cs @@ -46,6 +46,7 @@ internal class MockedCodeExplorer : IDisposable private readonly Mock _uiDispatcher = new Mock(); private readonly Mock> _generalSettingsProvider = new Mock>(); private readonly Mock> _windowSettingsProvider = new Mock>(); + private readonly Mock> _projectSettingsProvider = new Mock>(); private readonly Mock> _unitTestSettingsProvider = new Mock>(); private readonly Mock _configLoader = new Mock(null, null, null, null, null, null, null, null); private readonly Mock _interaction = new Mock(); @@ -187,6 +188,7 @@ private void SetupViewModelAndParse() ViewModel = new CodeExplorerViewModel(State, removeCommand, _generalSettingsProvider.Object, _windowSettingsProvider.Object, + _projectSettingsProvider.Object, _uiDispatcher.Object, Vbe.Object, null, new CodeExplorerSyncProvider(Vbe.Object, State, VbeEvents.Object), @@ -379,11 +381,12 @@ public void ExecuteAddTestModuleWithStubsCommand() public void ExecuteImportCommand( Func fileNameToModuleNameConverter = null, - Mock mockMessageBock = null, + Mock mockMessageBox = null, IEnumerable binaryFileNameExtractors = null, - Mock fileSystem = null) + Mock fileSystem = null, + Mock> projectSettingsProvider = null) { - var messageBox = mockMessageBock?.Object ?? new Mock().Object; + var messageBox = mockMessageBox?.Object ?? new Mock().Object; var mockModuleNameExtractor = new Mock(); var fileNameConverter = fileNameToModuleNameConverter ?? ((fileName) => fileName); mockModuleNameExtractor.Setup(m => m.ModuleName(It.IsAny())).Returns((string filename) => fileNameConverter(filename)); @@ -394,7 +397,15 @@ public void ExecuteImportCommand( mockFileSystem = new Mock(); mockFileSystem.Setup(m => m.File.Exists(It.IsAny())).Returns(true); } - ViewModel.ImportCommand = new ImportCommand(Vbe.Object, BrowserFactory.Object, VbeEvents.Object, State, State, State.ProjectsProvider, mockModuleNameExtractor.Object, extractors, mockFileSystem.Object, messageBox); + var mockProjectSettingsProvider = projectSettingsProvider; + if (mockProjectSettingsProvider == null) + { + var projectSettings = new ProjectSettings(); + mockProjectSettingsProvider = new Mock>(); + mockProjectSettingsProvider.Setup(ps => ps.Read()) + .Returns(projectSettings); + } + ViewModel.ImportCommand = new ImportCommand(Vbe.Object, BrowserFactory.Object, VbeEvents.Object, State, State, State.ProjectsProvider, mockModuleNameExtractor.Object, extractors, mockFileSystem.Object, messageBox, mockProjectSettingsProvider.Object); ViewModel.ImportCommand.Execute(ViewModel.SelectedItem); } @@ -402,7 +413,8 @@ public void ExecuteUpdateFromFileCommand( Func fileNameToModuleNameConverter, Mock mockMessageBox = null, IEnumerable binaryFileNameExtractors = null, - Mock fileSystem = null) + Mock fileSystem = null, + Mock> projectSettingsProvider = null) { var messageBox = mockMessageBox?.Object ?? new Mock().Object; var mockModuleNameExtractor = new Mock(); @@ -414,7 +426,15 @@ public void ExecuteUpdateFromFileCommand( mockFileSystem = new Mock(); mockFileSystem.Setup(m => m.File.Exists(It.IsAny())).Returns(true); } - ViewModel.UpdateFromFilesCommand = new UpdateFromFilesCommand(Vbe.Object, BrowserFactory.Object, VbeEvents.Object, State, State, State.ProjectsProvider, mockModuleNameExtractor.Object, extractors, mockFileSystem.Object, messageBox); + var mockProjectSettingsProvider = projectSettingsProvider; + if (mockProjectSettingsProvider == null) + { + var projectSettings = new ProjectSettings(); + mockProjectSettingsProvider = new Mock>(); + mockProjectSettingsProvider.Setup(ps => ps.Read()) + .Returns(projectSettings); + } + ViewModel.UpdateFromFilesCommand = new UpdateFromFilesCommand(Vbe.Object, BrowserFactory.Object, VbeEvents.Object, State, State, State.ProjectsProvider, mockModuleNameExtractor.Object, extractors, mockFileSystem.Object, messageBox, mockProjectSettingsProvider.Object); ViewModel.UpdateFromFilesCommand.Execute(ViewModel.SelectedItem); } @@ -422,7 +442,8 @@ public void ExecuteReplaceProjectContentsFromFilesCommand( Func fileNameToModuleNameConverter = null, Mock mockMessageBock = null, IEnumerable binaryFileNameExtractors = null, - Mock fileSystem = null) + Mock fileSystem = null, + Mock> projectSettingsProvider = null) { var messageBoxMock = mockMessageBock; if (messageBoxMock == null) @@ -442,7 +463,15 @@ public void ExecuteReplaceProjectContentsFromFilesCommand( mockFileSystem = new Mock(); mockFileSystem.Setup(m => m.File.Exists(It.IsAny())).Returns(true); } - ViewModel.ReplaceProjectContentsFromFilesCommand = new ReplaceProjectContentsFromFilesCommand(Vbe.Object, BrowserFactory.Object, VbeEvents.Object, State, State, State.ProjectsProvider, mockModuleNameExtractor.Object, extractors, mockFileSystem.Object, messageBoxMock.Object); + var mockProjectSettingsProvider = projectSettingsProvider; + if (mockProjectSettingsProvider == null) + { + var projectSettings = new ProjectSettings(); + mockProjectSettingsProvider = new Mock>(); + mockProjectSettingsProvider.Setup(ps => ps.Read()) + .Returns(projectSettings); + } + ViewModel.ReplaceProjectContentsFromFilesCommand = new ReplaceProjectContentsFromFilesCommand(Vbe.Object, BrowserFactory.Object, VbeEvents.Object, State, State, State.ProjectsProvider, mockModuleNameExtractor.Object, extractors, mockFileSystem.Object, messageBoxMock.Object, mockProjectSettingsProvider.Object); ViewModel.ReplaceProjectContentsFromFilesCommand.Execute(ViewModel.SelectedItem); } @@ -546,6 +575,15 @@ public MockedCodeExplorer ConfigureOpenDialog(string[] paths, DialogResult resul { OpenDialog.Setup(o => o.FileNames).Returns(paths); OpenDialog.Setup(o => o.ShowDialog()).Returns(result); + OpenDialog.Setup(o => o.FilterIndex).Returns(1); //one based index + return this; + } + + public MockedCodeExplorer ConfigureOpenDialog(IOpenFileDialog configuredDialog) + { + OpenDialog.Setup(o => o.FileNames).Returns(configuredDialog.FileNames); + OpenDialog.Setup(o => o.ShowDialog()).Returns(configuredDialog.ShowDialog()); + OpenDialog.Setup(o => o.FilterIndex).Returns(configuredDialog.FilterIndex); return this; } @@ -598,7 +636,7 @@ private Configuration GetDefaultUnitTestConfig() } }; - var userSettings = new UserSettings(generalSettings, null, null, null, null, unitTestSettings, null, null); + var userSettings = new UserSettings(generalSettings, null, null, null, null, unitTestSettings, null, null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/Settings/AutoCompleteSettingsTests.cs b/RubberduckTests/Settings/AutoCompleteSettingsTests.cs index db45bd0b52..06894a36b0 100644 --- a/RubberduckTests/Settings/AutoCompleteSettingsTests.cs +++ b/RubberduckTests/Settings/AutoCompleteSettingsTests.cs @@ -30,7 +30,7 @@ private static Configuration GetDefaultConfig() } }; - var userSettings = new UserSettings(null, null, autoCompleteSettings, null, null, null, null, null); + var userSettings = new UserSettings(null, null, autoCompleteSettings, null, null, null, null, null, null); return new Configuration(userSettings); } @@ -57,7 +57,7 @@ private static Configuration GetNonDefaultConfig() }; - var userSettings = new UserSettings(null, null, autoCompleteSettings, null, null, null, null, null); + var userSettings = new UserSettings(null, null, autoCompleteSettings, null, null, null, null, null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/Settings/GeneralSettingsTests.cs b/RubberduckTests/Settings/GeneralSettingsTests.cs index 5bf142d444..443be47b7f 100644 --- a/RubberduckTests/Settings/GeneralSettingsTests.cs +++ b/RubberduckTests/Settings/GeneralSettingsTests.cs @@ -59,7 +59,7 @@ private Configuration GetDefaultConfig() new HotkeySetting {CommandTypeName = "BarCommand", IsEnabled = true, Key1 = "B"} }); - var userSettings = new UserSettings(generalSettings, hotkeySettings, null, null, null, null, null, null); + var userSettings = new UserSettings(generalSettings, hotkeySettings, null, null, null, null, null, null, null); return new Configuration(userSettings); } @@ -82,7 +82,7 @@ private Configuration GetNondefaultConfig() } }; - var userSettings = new UserSettings(generalSettings, hotkeySettings, null, null, null, null, null, null); + var userSettings = new UserSettings(generalSettings, hotkeySettings, null, null, null, null, null, null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/Settings/IndenterSettingsTests.cs b/RubberduckTests/Settings/IndenterSettingsTests.cs index d63a9b8c21..354ca7b543 100644 --- a/RubberduckTests/Settings/IndenterSettingsTests.cs +++ b/RubberduckTests/Settings/IndenterSettingsTests.cs @@ -82,13 +82,13 @@ public static Rubberduck.SmartIndenter.IndenterSettings GetMockIndenterSettings( private Configuration GetDefaultConfig() { - var userSettings = new UserSettings(null, null, null, null, null, null, GetMockIndenterSettings(), null); + var userSettings = new UserSettings(null, null, null, null, null, null, GetMockIndenterSettings(), null, null); return new Configuration(userSettings); } private Configuration GetNondefaultConfig() { - var userSettings = new UserSettings(null, null, null, null, null, null, GetMockIndenterSettings(true), null); + var userSettings = new UserSettings(null, null, null, null, null, null, GetMockIndenterSettings(true), null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/Settings/InspectionSettingsTests.cs b/RubberduckTests/Settings/InspectionSettingsTests.cs index 4f6fae5afa..93dd22aa94 100644 --- a/RubberduckTests/Settings/InspectionSettingsTests.cs +++ b/RubberduckTests/Settings/InspectionSettingsTests.cs @@ -27,7 +27,7 @@ private Configuration GetDefaultConfig() .ThenBy(cis => cis.Description)) // Explicit sorting is to match InspectionSettingsViewModel.cs }; - var userSettings = new UserSettings(null, null, null, null, inspectionSettings, null, null, null); + var userSettings = new UserSettings(null, null, null, null, inspectionSettings, null, null, null, null); return new Configuration(userSettings); } @@ -47,7 +47,7 @@ private Configuration GetNondefaultConfig() .ThenBy(cis => cis.Description)) // Explicit sorting is to match InspectionSettingsViewModel.cs }; - var userSettings = new UserSettings(null, null, null, null, inspectionSettings, null, null, null); + var userSettings = new UserSettings(null, null, null, null, inspectionSettings, null, null, null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/Settings/ProjectSettingsTests.cs b/RubberduckTests/Settings/ProjectSettingsTests.cs new file mode 100644 index 0000000000..7bcdbf3cdc --- /dev/null +++ b/RubberduckTests/Settings/ProjectSettingsTests.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using Rubberduck.Settings; +using Moq; + +namespace RubberduckTests.Settings +{ + [TestFixture] + class ProjectSettingsTests + { + public static ProjectSettings GetMockProjectSettings() + { + var mockSettings = new Mock(); + + return mockSettings.Object; + } + + private Configuration GetDefaultConfig() + { + var userSettings = new UserSettings(null, null, null, null, null, null, null, null, new ProjectSettings()); + return new Configuration(userSettings); + } + + [Category("Settings")] + [Test] + public void Foo() + { + var bar = new ProjectSettings(); + //bar. + } + } +} diff --git a/RubberduckTests/Settings/TodoSettingsTests.cs b/RubberduckTests/Settings/TodoSettingsTests.cs index dc2a2f16dc..813f739e2d 100644 --- a/RubberduckTests/Settings/TodoSettingsTests.cs +++ b/RubberduckTests/Settings/TodoSettingsTests.cs @@ -20,7 +20,7 @@ private Configuration GetDefaultConfig() } }; - var userSettings = new UserSettings(null, null, null, todoSettings, null, null, null, null); + var userSettings = new UserSettings(null, null, null, todoSettings, null, null, null, null, null); return new Configuration(userSettings); } @@ -34,7 +34,7 @@ private Configuration GetNondefaultConfig() } }; - var userSettings = new UserSettings(null, null, null, todoSettings, null, null, null, null); + var userSettings = new UserSettings(null, null, null, todoSettings, null, null, null, null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/Settings/UnitTestSettingsTests.cs b/RubberduckTests/Settings/UnitTestSettingsTests.cs index dcb256e668..2b70abb2f1 100644 --- a/RubberduckTests/Settings/UnitTestSettingsTests.cs +++ b/RubberduckTests/Settings/UnitTestSettingsTests.cs @@ -13,7 +13,7 @@ private Configuration GetDefaultConfig() { var unitTestSettings = new UnitTestSettings(BindingMode.LateBinding, AssertMode.StrictAssert, true, true, false); - var userSettings = new UserSettings(null, null, null, null, null, unitTestSettings, null, null); + var userSettings = new UserSettings(null, null, null, null, null, unitTestSettings, null, null, null); return new Configuration(userSettings); } @@ -21,7 +21,7 @@ private Configuration GetNondefaultConfig() { var unitTestSettings = new UnitTestSettings(BindingMode.EarlyBinding, AssertMode.PermissiveAssert, false, false, true); - var userSettings = new UserSettings(null, null, null, null, null, unitTestSettings, null, null); + var userSettings = new UserSettings(null, null, null, null, null, unitTestSettings, null, null, null); return new Configuration(userSettings); } diff --git a/RubberduckTests/TodoExplorer/TodoExplorerTests.cs b/RubberduckTests/TodoExplorer/TodoExplorerTests.cs index fb9f28e839..dd367bfa01 100644 --- a/RubberduckTests/TodoExplorer/TodoExplorerTests.cs +++ b/RubberduckTests/TodoExplorer/TodoExplorerTests.cs @@ -210,7 +210,7 @@ private Configuration GetTodoConfig(string[] markers) ToDoMarkers = markers.Select(m => new ToDoMarker(m)).ToArray() }; - var userSettings = new UserSettings(null, null, null, todoSettings, null, null, null, null); + var userSettings = new UserSettings(null, null, null, todoSettings, null, null, null, null, null); return new Configuration(userSettings); }