Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Rubberduck.Navigation.CodeExplorer
{
public class CodeExplorerComponentViewModel : CodeExplorerItemViewModel
public class CodeExplorerComponentViewModel : CodeExplorerItemViewModel, ICodeExplorerDeclarationViewModel
{
private readonly Declaration _declaration;
public Declaration Declaration { get { return _declaration; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Rubberduck.Navigation.CodeExplorer
{
public class CodeExplorerMemberViewModel : CodeExplorerItemViewModel
public class CodeExplorerMemberViewModel : CodeExplorerItemViewModel, ICodeExplorerDeclarationViewModel
{
private readonly Declaration _declaration;
public Declaration Declaration { get { return _declaration; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Rubberduck.Navigation.CodeExplorer
{
public class CodeExplorerProjectViewModel : CodeExplorerItemViewModel
public class CodeExplorerProjectViewModel : CodeExplorerItemViewModel, ICodeExplorerDeclarationViewModel
{
private readonly Declaration _declaration;
public Declaration Declaration { get { return _declaration; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
}

_printCommand = commands.OfType<CodeExplorer_PrintCommand>().FirstOrDefault();

_commitCommand = commands.OfType<CodeExplorer_CommitCommand>().FirstOrDefault();
_undoCommand = commands.OfType<CodeExplorer_UndoCommand>().FirstOrDefault();
}

private CodeExplorerItemViewModel _selectedItem;
Expand Down Expand Up @@ -350,6 +353,12 @@ private void RemoveFailingComponent(CodeExplorerItemViewModel itemNode, string c
private readonly ICommand _printCommand;
public ICommand PrintCommand { get { return _printCommand; } }

private readonly ICommand _commitCommand;
public ICommand CommitCommand { get { return _commitCommand; } }

private readonly ICommand _undoCommand;
public ICommand UndoCommand { get { return _undoCommand; } }

private readonly ICommand _externalRemoveCommand;

// this is a special case--we have to reset SelectedItem to prevent a crash
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Rubberduck.Parsing.Symbols;

namespace Rubberduck.Navigation.CodeExplorer
{
public interface ICodeExplorerDeclarationViewModel
{
Declaration Declaration { get; }
}
}
28 changes: 14 additions & 14 deletions RetailCoder.VBE/Root/RubberduckModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Rubberduck.SourceControl;
using Rubberduck.UI;
using Rubberduck.UI.CodeExplorer;
using Rubberduck.UI.CodeExplorer.Commands;
using Rubberduck.UI.CodeInspections;
using Rubberduck.UI.Command;
using Rubberduck.UI.Command.MenuItems;
Expand Down Expand Up @@ -82,7 +83,6 @@ public override void Load()
ApplyAbstractFactoryConvention(assemblies);

BindCommandsToMenuItems();
BindCommandsToCodeExplorer();

Rebind<IIndenter>().To<Indenter>().InSingletonScope();
Rebind<IIndenterSettings>().To<IndenterSettings>();
Expand All @@ -103,16 +103,6 @@ public override void Load()
.WhenInjectedInto<InspectionResultsCommand>()
.InSingletonScope()
.WithConstructorArgument<IDockableUserControl>(new CodeInspectionsWindow { ViewModel = _kernel.Get<InspectionResultsViewModel>() });

Bind<IPresenter>().To<CodeExplorerDockablePresenter>()
.WhenInjectedInto<CodeExplorerCommand>()
.InSingletonScope()
.WithConstructorArgument<IDockableUserControl>(new CodeExplorerWindow { ViewModel = _kernel.Get<CodeExplorerViewModel>() });

Bind<IPresenter>().To<ToDoExplorerDockablePresenter>()
.WhenInjectedInto<ToDoExplorerCommand>()
.InSingletonScope()
.WithConstructorArgument<IDockableUserControl>(new ToDoExplorerWindow { ViewModel = _kernel.Get<ToDoExplorerViewModel>() });

Bind<IControlView>().To<ChangesView>().Named("changesView");
Bind<IControlView>().To<BranchesView>().Named("branchesView");
Expand All @@ -131,10 +121,20 @@ public override void Load()
Bind<ISourceControlProviderFactory>().To<SourceControlProviderFactory>()
.WhenInjectedInto<SourceControlViewViewModel>();

Bind<IPresenter>().To<SourceControlDockablePresenter>()
.WhenInjectedInto<ShowSourceControlPanelCommand>()
Bind<SourceControlDockablePresenter>().ToSelf()
.InSingletonScope()
.WithConstructorArgument<IDockableUserControl>(new SourceControlPanel { ViewModel = _kernel.Get<SourceControlViewViewModel>() });
.WithConstructorArgument(new SourceControlPanel { ViewModel = _kernel.Get<SourceControlViewViewModel>() });

BindCommandsToCodeExplorer();
Bind<IPresenter>().To<CodeExplorerDockablePresenter>()
.WhenInjectedInto<CodeExplorerCommand>()
.InSingletonScope()
.WithConstructorArgument<IDockableUserControl>(new CodeExplorerWindow { ViewModel = _kernel.Get<CodeExplorerViewModel>() });

Bind<IPresenter>().To<ToDoExplorerDockablePresenter>()
.WhenInjectedInto<ToDoExplorerCommand>()
.InSingletonScope()
.WithConstructorArgument<IDockableUserControl>(new ToDoExplorerWindow { ViewModel = _kernel.Get<ToDoExplorerViewModel>() });

ConfigureRubberduckMenu();
ConfigureCodePaneContextMenu();
Expand Down
7 changes: 7 additions & 0 deletions RetailCoder.VBE/Rubberduck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@
<Reference Include="Infralution.Localization.Wpf">
<HintPath>..\libs\Infralution.Localization.Wpf.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Ninject.Extensions.Conventions">
<HintPath>..\packages\ninject.extensions.conventions.3.2.0.0\lib\net45-full\Ninject.Extensions.Conventions.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -366,6 +370,7 @@
<Compile Include="Inspections\ObjectVariableNotSetInspection.cs" />
<Compile Include="Inspections\RemoveExplicitCallStatmentQuickFix.cs" />
<Compile Include="Navigation\CodeExplorer\CodeExplorerErrorNodeViewModel.cs" />
<Compile Include="Navigation\CodeExplorer\ICodeExplorerDeclarationViewModel.cs" />
<Compile Include="Navigation\Folders\FolderHelper.cs" />
<Compile Include="Settings\RubberduckHotkey.cs" />
<Compile Include="UI\About\AboutControl.xaml.cs">
Expand All @@ -378,6 +383,7 @@
<Compile Include="UI\About\AboutDialog.Designer.cs">
<DependentUpon>AboutDialog.cs</DependentUpon>
</Compile>
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_CommitCommand.cs" />
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_AddUserFormCommand.cs" />
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_RenameCommand.cs" />
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_FindAllReferencesCommand.cs" />
Expand All @@ -393,6 +399,7 @@
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_AddClassModuleCommand.cs" />
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_AddStdModuleCommand.cs" />
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_AddTestModuleCommand.cs" />
<Compile Include="UI\CodeExplorer\Commands\CodeExplorer_UndoCommand.cs" />
<Compile Include="UI\CodeExplorer\Converters\BoolToHiddenVisibility.cs" />
<Compile Include="UI\Command\MenuItems\NoIndentAnnotationCommandMenuItem.cs" />
<Compile Include="UI\Command\MenuItems\IndentCurrentModuleCommandMenuItem.cs" />
Expand Down
110 changes: 59 additions & 51 deletions RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,6 @@
<Setter Property="BorderThickness" Value="1.5"/>
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu DataContext="{Binding DataContext, Source={x:Reference CodeExplorer}}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Navigate}"
FontWeight="Bold"
Command="{Binding NavigateCommand}"
CommandParameter="{Binding SelectedItem}"/>
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Rename}"
Command="{Binding RenameCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Add}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddTestModuleText}"
Command="{Binding AddTestModuleCommand}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddStdModuleText}"
Command="{Binding AddStdModuleCommand}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddClassModuleText}"
Command="{Binding AddClsModuleCommand}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddFormText}"
Command="{Binding AddFormCommand}" />
</MenuItem>
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Find}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_FindAllReferencesText}"
Command="{Binding FindAllReferencesCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_FindAllImplementationsText}"
Command="{Binding FindAllImplementationsCommand}"
CommandParameter="{Binding SelectedItem}" />
</MenuItem>
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SmartIndenterMenu}"
Command="{Binding IndenterCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Import}"
Command="{Binding ImportCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Export}"
Command="{Binding ExportCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Remove}"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Print}"
Command="{Binding PrintCommand}"
CommandParameter="{Binding SelectedItem}" />
</ContextMenu>
</Setter.Value>
</Setter>
<EventSetter Event="PreviewMouseRightButtonDown" Handler="OnPreviewMouseRightButtonDown" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
Expand Down Expand Up @@ -193,6 +142,65 @@
<Style x:Key="CodeExplorerTreeViewStyle" TargetType="TreeView">
<Setter Property="ItemTemplate" Value="{StaticResource CodeExplorerTemplate}" />
<Setter Property="ItemsSource" Value="{Binding Projects, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu DataContext="{Binding DataContext, Source={x:Reference CodeExplorer}}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Navigate}"
FontWeight="Bold"
Command="{Binding NavigateCommand}"
CommandParameter="{Binding SelectedItem}"/>
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Rename}"
Command="{Binding RenameCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Add}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddTestModuleText}"
Command="{Binding AddTestModuleCommand}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddStdModuleText}"
Command="{Binding AddStdModuleCommand}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddClassModuleText}"
Command="{Binding AddClsModuleCommand}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddFormText}"
Command="{Binding AddFormCommand}" />
</MenuItem>
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Find}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_FindAllReferencesText}"
Command="{Binding FindAllReferencesCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_FindAllImplementationsText}"
Command="{Binding FindAllImplementationsCommand}"
CommandParameter="{Binding SelectedItem}" />
</MenuItem>
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SmartIndenterMenu}"
Command="{Binding IndenterCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Import}"
Command="{Binding ImportCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Export}"
Command="{Binding ExportCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Remove}"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Print}"
Command="{Binding PrintCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControlPanel_Caption}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Commit}"
Command="{Binding CommitCommand}"
CommandParameter="{Binding SelectedItem}" />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Undo}"
Command="{Binding UndoCommand}"
CommandParameter="{Binding SelectedItem}" />
</MenuItem>
</ContextMenu>
</Setter.Value>
</Setter>
</Style>

<SolidColorBrush x:Key="ToolBarHorizontalBackground" Color="#FFEEF5FD"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Rubberduck.Navigation.CodeExplorer;
using Rubberduck.UI.Command;
using Rubberduck.UI.SourceControl;

namespace Rubberduck.UI.CodeExplorer.Commands
{
public class CodeExplorer_CommitCommand : CommandBase
{
private readonly SourceControlDockablePresenter _presenter;

public CodeExplorer_CommitCommand(SourceControlDockablePresenter presenter)
{
_presenter = presenter;
}

public override bool CanExecute(object parameter)
{
return parameter is CodeExplorerComponentViewModel;
}

public override void Execute(object parameter)
{
_presenter.Show();

var panel = _presenter.Window() as SourceControlPanel;
if (panel != null)
{
var vm = panel.ViewModel as SourceControlViewViewModel;
if (vm != null)
{
vm.SetTab(SourceControlTab.Changes);
}
}
}
}
}
Loading