Skip to content

Commit 484a49e

Browse files
committed
implemented double-click navigation in CodeExplorer
1 parent e5a4b5f commit 484a49e

8 files changed

+34
-3
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Windows.Media.Imaging;
44
using Microsoft.Vbe.Interop;
55
using Rubberduck.Parsing.Symbols;
6+
using Rubberduck.VBEditor;
67
using resx = Rubberduck.UI.CodeExplorer.CodeExplorer;
78

89
namespace Rubberduck.Navigation.CodeExplorer
@@ -54,6 +55,7 @@ public bool IsTestModule
5455

5556
public override string Name { get { return _declaration.IdentifierName; } }
5657

58+
public override QualifiedSelection? QualifiedSelection { get { return _declaration.QualifiedSelection; } }
5759

5860
private vbext_ComponentType ComponentType { get { return _declaration.QualifiedName.QualifiedModuleName.Component.Type; } }
5961

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq;
33
using System.Windows.Media.Imaging;
44
using Rubberduck.Parsing.Symbols;
5+
using Rubberduck.VBEditor;
56
using resx = Rubberduck.Properties.Resources;
67

78
namespace Rubberduck.Navigation.CodeExplorer
@@ -41,6 +42,8 @@ public CodeExplorerCustomFolderViewModel(string name, IEnumerable<Declaration> d
4142

4243
public override string Name { get { return _name; } }
4344

45+
public override QualifiedSelection? QualifiedSelection { get { return null; } }
46+
4447
private readonly BitmapImage _collapsedIcon;
4548
public override BitmapImage CollapsedIcon { get { return _collapsedIcon; } }
4649

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq;
33
using System.Windows.Media.Imaging;
44
using Rubberduck.UI;
5+
using Rubberduck.VBEditor;
56

67
namespace Rubberduck.Navigation.CodeExplorer
78
{
@@ -14,6 +15,8 @@ public abstract class CodeExplorerItemViewModel : ViewModelBase
1415
public abstract BitmapImage CollapsedIcon { get; }
1516
public abstract BitmapImage ExpandedIcon { get; }
1617

18+
public abstract QualifiedSelection? QualifiedSelection { get; }
19+
1720
public CodeExplorerItemViewModel GetChild(string name)
1821
{
1922
foreach (var item in _items)

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Windows.Media.Imaging;
55
using Rubberduck.Parsing.Symbols;
6+
using Rubberduck.VBEditor;
67
using resx = Rubberduck.UI.CodeExplorer.CodeExplorer;
78

89
namespace Rubberduck.Navigation.CodeExplorer
@@ -77,6 +78,8 @@ public CodeExplorerMemberViewModel(Declaration declaration, IEnumerable<Declarat
7778
private readonly string _name;
7879
public override string Name { get { return _name; } }
7980

81+
public override QualifiedSelection? QualifiedSelection { get { return _declaration.QualifiedSelection; } }
82+
8083
private static string DetermineMemberName(Declaration declaration)
8184
{
8285
var type = declaration.DeclarationType;

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
using System.Windows.Media.Imaging;
66
using Microsoft.Vbe.Interop;
77
using Rubberduck.Parsing.Symbols;
8+
using Rubberduck.VBEditor;
89
using resx = Rubberduck.UI.CodeExplorer.CodeExplorer;
910

1011
namespace Rubberduck.Navigation.CodeExplorer
1112
{
1213
public class CodeExplorerProjectViewModel : CodeExplorerItemViewModel
1314
{
1415
private readonly Declaration _declaration;
16+
1517
private static readonly DeclarationType[] ComponentTypes =
1618
{
1719
DeclarationType.Class,
@@ -75,5 +77,6 @@ private static IEnumerable<CodeExplorerItemViewModel> FindFolders(IEnumerable<De
7577
public override BitmapImage ExpandedIcon { get { return _icon; } }
7678

7779
public override string Name { get { return _declaration.CustomFolder; } }
80+
public override QualifiedSelection? QualifiedSelection { get { return _declaration.QualifiedSelection; } }
7881
}
7982
}

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ public class CodeExplorerViewModel : ViewModelBase
1414
{
1515
private readonly RubberduckParserState _state;
1616

17-
public CodeExplorerViewModel(RubberduckParserState state)
17+
public CodeExplorerViewModel(RubberduckParserState state, INavigateCommand navigateCommand)
1818
{
1919
_state = state;
20+
_navigateCommand = navigateCommand;
2021
_state.StateChanged += ParserState_StateChanged;
2122
_state.ModuleStateChanged += ParserState_ModuleStateChanged;
2223

@@ -26,6 +27,9 @@ public CodeExplorerViewModel(RubberduckParserState state)
2627
private readonly ICommand _refreshCommand;
2728
public ICommand RefreshCommand { get { return _refreshCommand; } }
2829

30+
private readonly INavigateCommand _navigateCommand;
31+
public ICommand NavigateCommand { get { return _navigateCommand; } }
32+
2933
private object _selectedItem;
3034
public object SelectedItem
3135
{

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Windows.Navigation;
1414
using System.Windows.Shapes;
1515
using Rubberduck.Navigation.CodeExplorer;
16+
using Rubberduck.VBEditor;
1617

1718
namespace Rubberduck.UI.CodeExplorer
1819
{
@@ -30,7 +31,19 @@ public CodeExplorerControl()
3031

3132
private void TreeView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
3233
{
33-
// todo: execute a NavigateCommand
34+
if (ViewModel == null || ViewModel.SelectedItem == null)
35+
{
36+
return;
37+
}
38+
39+
var selectedResult = ViewModel.SelectedItem as CodeExplorerItemViewModel;
40+
if (selectedResult == null || !selectedResult.QualifiedSelection.HasValue)
41+
{
42+
return;
43+
}
44+
45+
var arg = selectedResult.QualifiedSelection.Value.GetNavitationArgs();
46+
ViewModel.NavigateCommand.Execute(arg);
3447
}
3548
}
3649
}

RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class InspectionResultsViewModel : ViewModelBase
2121
private readonly RubberduckParserState _state;
2222
private readonly IInspector _inspector;
2323
private readonly VBE _vbe;
24-
private readonly INavigateCommand _navigateCommand;
2524
private readonly IClipboardWriter _clipboard;
2625
private readonly IGeneralConfigService _configService;
2726

@@ -107,6 +106,7 @@ public IInspection SelectedInspection
107106
}
108107
}
109108

109+
private readonly INavigateCommand _navigateCommand;
110110
public ICommand NavigateCommand { get { return _navigateCommand; } }
111111

112112
private readonly ICommand _refreshCommand;

0 commit comments

Comments
 (0)