Skip to content

Commit 9082102

Browse files
authored
Merge pull request #4288 from mansellan/3997
Code explorer Add menu VB6 component types
2 parents ae2ef6c + 088082c commit 9082102

34 files changed

+998
-118
lines changed

Rubberduck.Core/App.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ public void Startup()
116116

117117
CheckForLegacyIndenterSettings();
118118
_appMenus.Initialize();
119-
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
119+
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
120120
_appMenus.Localize();
121121

122122
if (_config.UserSettings.GeneralSettings.CanCheckVersion)
123123
{
124124
_checkVersionCommand.Execute(null);
125-
}
125+
}
126126
}
127127

128128
public void Shutdown()

Rubberduck.Core/AppMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Threading;
54
using NLog;
65
using Rubberduck.Parsing;
76
using Rubberduck.Parsing.VBA;
@@ -63,6 +62,7 @@ public void Localize()
6362
{
6463
_stateBar.Localize();
6564
_stateBar.SetStatusLabelCaption(_parser.State.Status);
65+
6666
foreach (var menu in _menus)
6767
{
6868
menu.Localize();

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public bool IsTestModule
164164
{ ComponentType.VBForm, DeclarationType.VbForm },
165165
{ ComponentType.MDIForm, DeclarationType.MdiForm},
166166
{ ComponentType.UserControl, DeclarationType.UserControl},
167+
{ ComponentType.DocObject, DeclarationType.DocObject},
167168
{ ComponentType.ResFile, DeclarationType.ResFile},
168169
{ ComponentType.RelatedDocument, DeclarationType.RelatedDocument},
169170
{ ComponentType.PropPage, DeclarationType.PropPage},

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Rubberduck.VBEditor.SafeComWrappers;
2020
using System.Windows;
2121
using Rubberduck.Parsing.UIContext;
22+
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
2223

2324
// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
2425
// ReSharper disable ExplicitCallerInfoArgument
@@ -33,6 +34,7 @@ public sealed class CodeExplorerViewModel : ViewModelBase, IDisposable
3334
private readonly GeneralSettings _generalSettings;
3435
private readonly WindowSettings _windowSettings;
3536
private readonly IUiDispatcher _uiDispatcher;
37+
private readonly VBEKind _vbeKind;
3638

3739
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3840

@@ -42,14 +44,16 @@ public CodeExplorerViewModel(
4244
List<CommandBase> commands,
4345
IConfigProvider<GeneralSettings> generalSettingsProvider,
4446
IConfigProvider<WindowSettings> windowSettingsProvider,
45-
IUiDispatcher uiDispatcher)
47+
IUiDispatcher uiDispatcher,
48+
IVBE vbe)
4649
{
4750
_folderHelper = folderHelper;
4851
_state = state;
4952
_state.StateChanged += HandleStateChanged;
5053
_state.ModuleStateChanged += ParserState_ModuleStateChanged;
5154
_windowSettingsProvider = windowSettingsProvider;
5255
_uiDispatcher = uiDispatcher;
56+
_vbeKind = vbe.Kind;
5357

5458
if (generalSettingsProvider != null)
5559
{
@@ -68,15 +72,19 @@ public CodeExplorerViewModel(
6872
o => reparseCommand.Execute(o),
6973
o => !IsBusy && reparseCommand != null && reparseCommand.CanExecute(o));
7074

71-
OpenCommand = commands.OfType<UI.CodeExplorer.Commands.OpenCommand>().SingleOrDefault();
75+
OpenCommand = commands.OfType<OpenCommand>().SingleOrDefault();
7276
OpenDesignerCommand = commands.OfType<OpenDesignerCommand>().SingleOrDefault();
7377

74-
AddTestModuleCommand = commands.OfType<UI.CodeExplorer.Commands.AddTestModuleCommand>().SingleOrDefault();
75-
AddTestModuleWithStubsCommand = commands.OfType<AddTestModuleWithStubsCommand>().SingleOrDefault();
76-
78+
AddVBFormCommand = commands.OfType<AddVBFormCommand>().SingleOrDefault();
79+
AddMDIFormCommand = commands.OfType<AddMDIFormCommand>().SingleOrDefault();
80+
AddUserFormCommand = commands.OfType<AddUserFormCommand>().SingleOrDefault();
7781
AddStdModuleCommand = commands.OfType<AddStdModuleCommand>().SingleOrDefault();
7882
AddClassModuleCommand = commands.OfType<AddClassModuleCommand>().SingleOrDefault();
79-
AddUserFormCommand = commands.OfType<AddUserFormCommand>().SingleOrDefault();
83+
AddUserControlCommand = commands.OfType<AddUserControlCommand>().SingleOrDefault();
84+
AddPropertyPageCommand = commands.OfType<AddPropertyPageCommand>().SingleOrDefault();
85+
AddUserDocumentCommand = commands.OfType<AddUserDocumentCommand>().SingleOrDefault();
86+
AddTestModuleCommand = commands.OfType<UI.CodeExplorer.Commands.AddTestModuleCommand>().SingleOrDefault();
87+
AddTestModuleWithStubsCommand = commands.OfType<AddTestModuleWithStubsCommand>().SingleOrDefault();
8088

8189
OpenProjectPropertiesCommand = commands.OfType<OpenProjectPropertiesCommand>().SingleOrDefault();
8290
RenameCommand = commands.OfType<RenameCommand>().SingleOrDefault();
@@ -90,7 +98,7 @@ public CodeExplorerViewModel(
9098

9199
ImportCommand = commands.OfType<ImportCommand>().SingleOrDefault();
92100
ExportCommand = commands.OfType<ExportCommand>().SingleOrDefault();
93-
ExportAllCommand = commands.OfType<Rubberduck.UI.Command.ExportAllCommand>().SingleOrDefault();
101+
ExportAllCommand = commands.OfType<ExportAllCommand>().SingleOrDefault();
94102

95103
_externalRemoveCommand = commands.OfType<RemoveCommand>().SingleOrDefault();
96104
if (_externalRemoveCommand != null)
@@ -511,11 +519,17 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
511519

512520
public CommandBase OpenCommand { get; }
513521

522+
523+
public CommandBase AddVBFormCommand { get; }
524+
public CommandBase AddMDIFormCommand { get; }
525+
public CommandBase AddUserFormCommand { get; }
526+
public CommandBase AddStdModuleCommand { get; }
527+
public CommandBase AddClassModuleCommand { get; }
528+
public CommandBase AddUserControlCommand { get; }
529+
public CommandBase AddPropertyPageCommand { get; }
530+
public CommandBase AddUserDocumentCommand { get; }
514531
public CommandBase AddTestModuleCommand { get; }
515532
public CommandBase AddTestModuleWithStubsCommand { get; }
516-
public CommandBase AddStdModuleCommand { get; }
517-
public CommandBase AddClassModuleCommand { get; }
518-
public CommandBase AddUserFormCommand { get; }
519533

520534
public CommandBase OpenDesignerCommand { get; }
521535
public CommandBase OpenProjectPropertiesCommand { get; }
@@ -552,14 +566,18 @@ private void ExecuteRemoveComand(object param)
552566

553567
private bool CanExecuteExportAllCommand => ExportAllCommand.CanExecute(SelectedItem);
554568

555-
public Visibility ExportVisibility => CanExecuteExportAllCommand ? Visibility.Collapsed : Visibility.Visible;
569+
public Visibility ExportVisibility => _vbeKind == VBEKind.Standalone || CanExecuteExportAllCommand ? Visibility.Collapsed : Visibility.Visible;
556570

557571
public Visibility ExportAllVisibility => CanExecuteExportAllCommand ? Visibility.Visible : Visibility.Collapsed;
558572

559573
public Visibility TreeViewVisibility => Projects == null || Projects.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
560574

561575
public Visibility EmptyUIRefreshMessageVisibility => _isBusy ? Visibility.Hidden : Visibility.Visible;
562576

577+
public Visibility VB6Visibility => _vbeKind == VBEKind.Standalone ? Visibility.Visible : Visibility.Collapsed;
578+
579+
public Visibility VBAVisibility => _vbeKind == VBEKind.Hosted ? Visibility.Visible : Visibility.Collapsed;
580+
563581
public void FilterByName(IEnumerable<CodeExplorerItemViewModel> nodes, string searchString)
564582
{
565583
foreach (var item in nodes)

Rubberduck.Core/Rubberduck.Core.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@
382382
<Compile Include="AutoComplete\AutoCompleteClosingParenthese.cs" />
383383
<Compile Include="AutoComplete\AutoCompleteClosingString.cs" />
384384
<Compile Include="AutoComplete\AutoCompleteService.cs" />
385+
<Compile Include="UI\CodeExplorer\Commands\AddPropertyPageCommand.cs" />
386+
<Compile Include="UI\CodeExplorer\Commands\AddUserDocumentCommand.cs" />
387+
<Compile Include="UI\CodeExplorer\Commands\AddUserControlCommand.cs" />
388+
<Compile Include="UI\CodeExplorer\Commands\AddMDIFormCommand.cs" />
389+
<Compile Include="UI\CodeExplorer\Commands\AddVBFormCommand.cs" />
385390
<Compile Include="UI\CodeExplorer\Commands\AddTestModuleWithStubsCommand.cs" />
386391
<Compile Include="UI\CodeExplorer\Commands\CodeExplorerCommandAttribute.cs" />
387392
<Compile Include="UI\CodeExplorer\Commands\AddUserFormCommand.cs" />

0 commit comments

Comments
 (0)