Skip to content

Commit 0c493cb

Browse files
authored
Merge pull request #5738 from IvenBach/Issue5631_Add_expand/collapse_all_to_CodeExplorer
Add expand/collapse all nodes to code explorer
2 parents c9c6b92 + 34dc9f4 commit 0c493cb

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/UnreachableCaseEvaluation/UnreachableCaseInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public string SelectExpressionTypeName(
225225
VBAParser.SelectCaseStmtContext selectStmt,
226226
IParseTreeVisitorResults parseTreeValues)
227227
{
228-
var (typeName, value) = SelectExpressionTypeNameAndValue(selectStmt, parseTreeValues);
228+
var (typeName, _) = SelectExpressionTypeNameAndValue(selectStmt, parseTreeValues);
229229
return typeName;
230230
}
231231

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ public enum CodeExplorerSortOrder
3939
public sealed class CodeExplorerViewModel : ViewModelBase
4040
{
4141
// ReSharper disable NotAccessedField.Local - The settings providers aren't used, but several enhancement requests will need them.
42+
#pragma warning disable IDE0052 // Remove unread private members
4243
private readonly RubberduckParserState _state;
4344
private readonly RemoveCommand _externalRemoveCommand;
44-
private readonly IConfigurationService<GeneralSettings> _generalSettingsProvider;
45+
private readonly IConfigurationService<GeneralSettings> _generalSettingsProvider;
4546
private readonly IConfigurationService<WindowSettings> _windowSettingsProvider;
4647
private readonly IUiDispatcher _uiDispatcher;
4748
private readonly IVBE _vbe;
4849
private readonly ITemplateProvider _templateProvider;
50+
#pragma warning restore IDE0052 // Remove unread private members
4951
// ReSharper restore NotAccessedField.Local
5052

5153
public CodeExplorerViewModel(
@@ -77,6 +79,8 @@ public CodeExplorerViewModel(
7779
CollapseAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseNodes, EvaluateCanSwitchNodeState);
7880
ExpandAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandNodes, EvaluateCanSwitchNodeState);
7981
ClearSearchCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteClearSearchCommand);
82+
CollapseAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAllCommand);
83+
ExpandAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAllCommand);
8084
if (_externalRemoveCommand != null)
8185
{
8286
RemoveCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRemoveCommand, _externalRemoveCommand.CanExecute);
@@ -92,7 +96,9 @@ public CodeExplorerViewModel(
9296

9397
public ObservableCollection<ICodeExplorerNode> Projects { get; } = new ObservableCollection<ICodeExplorerNode>();
9498

99+
#pragma warning disable IDE1006 // Naming Styles
95100
private ObservableCollection<Template> templates => _templateProvider.GetTemplates();
101+
#pragma warning restore IDE1006 // Naming Styles
96102

97103
public ObservableCollection<Template> BuiltInTemplates =>
98104
new ObservableCollection<Template>(templates.Where(t => !t.IsUserDefined)
@@ -345,6 +351,22 @@ private void ExecuteClearSearchCommand(object parameter)
345351
}
346352
}
347353

354+
private void ExecuteCollapseAllCommand(object parameter)
355+
{
356+
foreach (var project in Projects)
357+
{
358+
ExecuteCollapseNodes(project);
359+
}
360+
}
361+
362+
private void ExecuteExpandAllCommand(object parameter)
363+
{
364+
foreach (var project in Projects)
365+
{
366+
ExecuteExpandNodes(project);
367+
}
368+
}
369+
348370
private bool EvaluateCanSwitchNodeState(object parameter)
349371
{
350372
return SelectedItem?.Children?.Any() ?? false;
@@ -420,7 +442,10 @@ private void ExecuteRemoveCommand(object param)
420442

421443
public CodeExplorerMoveToFolderDragAndDropCommand MoveToFolderDragAndDropCommand { get; set; }
422444

423-
public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
445+
public CommandBase CollapseAllCommand { get; }
446+
public CommandBase ExpandAllCommand { get; }
447+
448+
public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
424449
{
425450
if (declaration == null)
426451
{

Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ResourceDictionary.MergedDictionaries>
2222

2323
<CollectionViewSource x:Key="BuiltInTemplatesViewSource" x:Name="BuiltInTemplatesView" Source="{Binding BuiltInTemplates}" />
24-
<CollectionViewSource x:Key="UserDefinedTemplatesViewSource" x:Name="BuiltInTemplatesView" Source="{Binding UserDefinedTemplates}" />
24+
<CollectionViewSource x:Key="UserDefinedTemplatesViewSource" x:Name="UserDefinedTemplatesView" Source="{Binding UserDefinedTemplates}" />
2525
<CollectionViewSource x:Key="AnnotationsViewSource" x:Name="AnnotationsView" Source="{Binding Annotations}" />
2626

2727
<BitmapImage x:Key="RefreshImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/arrow-circle-double.png" />
@@ -47,6 +47,8 @@
4747
<BitmapImage x:Key="SyncImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Custom/PNG/SyncArrows.png" />
4848
<BitmapImage x:Key="FontSizeImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/edit-size.png" />
4949
<BitmapImage x:Key="ExtractInterfaceImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Custom/PNG/ExtractInterface.png" />
50+
<BitmapImage x:Key="CollapseAllImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/collapse-all.png" />
51+
<BitmapImage x:Key="ExpandAllImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/expand-all.png" />
5052

5153
<converters:BooleanToNullableDoubleConverter x:Key="BoolToDouble" />
5254
<converters:TemplateCommandParameterToTupleConverter x:Key="TemplateCommandParameterToTuple" />
@@ -381,6 +383,19 @@
381383
</i:Interaction.Behaviors>
382384
</MenuItem>
383385
</Menu>
386+
387+
<Separator />
388+
389+
<Button Name="CollapseAll" Command="{Binding CollapseAllCommand}" Margin="2"
390+
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_CollapseAll}">
391+
<Image Source="{StaticResource CollapseAllImage}" Style="{StaticResource ToolbarImageOpacity}" />
392+
</Button>
393+
394+
<Button Name="ExpandAll" Command="{Binding ExpandAllCommand}" Margin="2"
395+
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_ExpandAll}">
396+
<Image Source="{StaticResource ExpandAllImage}" Style="{StaticResource ToolbarImageOpacity}" />
397+
</Button>
398+
384399
</ToolBar>
385400
</ToolBarTray>
386401

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public TestExplorerViewModel(ISelectionService selectionService,
5454
TestExplorerModel model,
5555
IClipboardWriter clipboard,
5656
// ReSharper disable once UnusedParameter.Local - left in place because it will likely be needed for app wide font settings, etc.
57+
#pragma warning disable IDE0060 // Remove unused parameter
5758
IConfigurationService<Configuration> configService,
59+
#pragma warning restore IDE0060 // Remove unused parameter
5860
ISettingsFormFactory settingsFormFactory,
5961
IRewritingManager rewritingManager,
6062
IAnnotationUpdater annotationUpdater)

0 commit comments

Comments
 (0)