Skip to content

Commit 8f12a16

Browse files
committed
Correct filtering behaviour in CodeInspection Settings
Additionally add i18n for the filtering feature and slightly change the UI
1 parent 4022c06 commit 8f12a16

File tree

4 files changed

+58
-51
lines changed

4 files changed

+58
-51
lines changed

Rubberduck.Core/UI/RubberduckUI.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Core/UI/RubberduckUI.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,4 +1812,7 @@ NOTE: Restart is required for the setting to take effect.</value>
18121812
<data name="Command_AddTestModule_Error" xml:space="preserve">
18131813
<value>Unable to create test module. The host application may not allow for creation of new modules or the project may be locked. For details, check the log.</value>
18141814
</data>
1815+
<data name="InspectionSettings_FilterDescription" xml:space="preserve">
1816+
<value>Filter by Description:</value>
1817+
</data>
18151818
</root>

Rubberduck.Core/UI/Settings/InspectionSettings.xaml

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -259,44 +259,40 @@
259259
<Grid>
260260
<ScrollViewer>
261261
<StackPanel Margin="5,5,5,0" ScrollViewer.VerticalScrollBarVisibility="Auto">
262-
<Label Background="DarkGray"
262+
<Label Background="DarkGray"
263263
HorizontalContentAlignment="Stretch"
264264
Margin="0,0,0,3">
265-
<Label.Style>
266-
<Style>
267-
<Style.Resources>
268-
<Style TargetType="{x:Type Border}">
269-
<Setter Property="CornerRadius" Value="5"/>
270-
</Style>
271-
</Style.Resources>
272-
</Style>
273-
</Label.Style>
274-
<DockPanel Background="DarkGray" FlowDirection="LeftToRight">
275-
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
276-
<Label Foreground="White"
277-
FontWeight="SemiBold"
278-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionSettings_InspectionSeveritySettingsLabel}">
279-
</Label>
280-
</StackPanel>
281-
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
282-
<Grid>
283-
<Grid.ColumnDefinitions>
284-
<ColumnDefinition Width="Auto"/>
285-
<ColumnDefinition MaxWidth="75"/>
286-
<ColumnDefinition MaxWidth="75"/>
287-
</Grid.ColumnDefinitions>
288-
<controls:LinkButton Grid.Column="1" Margin="2"
289-
Command="{Binding ImportButtonCommand}"
290-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SettingsCaption_ImportSettings}"/>
291-
<controls:LinkButton Grid.Column="2" Margin="2"
292-
Command="{Binding ExportButtonCommand}"
293-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SettingsCaption_ExportSettings}"/>
294-
</Grid>
295-
</StackPanel>
296-
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
297-
<Label Content="Description Filter"/>
298-
<TextBox MinWidth="75"
299-
Text="{Binding InspectionSettingsFilter, UpdateSourceTrigger=PropertyChanged}"/>
265+
<Label.Style>
266+
<Style>
267+
<Style.Resources>
268+
<Style TargetType="{x:Type Border}">
269+
<Setter Property="CornerRadius" Value="5"/>
270+
</Style>
271+
</Style.Resources>
272+
</Style>
273+
</Label.Style>
274+
<DockPanel Background="DarkGray" FlowDirection="LeftToRight">
275+
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
276+
<Label Foreground="White"
277+
FontWeight="SemiBold"
278+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionSettings_InspectionSeveritySettingsLabel}">
279+
</Label>
280+
</StackPanel>
281+
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Left">
282+
<controls:LinkButton
283+
Margin="2"
284+
Command="{Binding ImportButtonCommand}"
285+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SettingsCaption_ImportSettings}"/>
286+
<controls:LinkButton
287+
Margin="2"
288+
Command="{Binding ExportButtonCommand}"
289+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SettingsCaption_ExportSettings}"/>
290+
</StackPanel>
291+
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Stretch">
292+
<Label Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=InspectionSettings_FilterDescription}" />
293+
<TextBox MinWidth="125"
294+
Text="{Binding InspectionSettingsFilter, UpdateSourceTrigger=PropertyChanged}"
295+
HorizontalAlignment="Stretch" />
300296
</StackPanel>
301297
</DockPanel>
302298
</Label>

Rubberduck.Core/UI/Settings/InspectionSettingsViewModel.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Collections.ObjectModel;
4+
using System.ComponentModel;
35
using System.Linq;
46
using System.Windows.Data;
57
using NLog;
@@ -52,6 +54,17 @@ public string InspectionSettingsFilter
5254
{
5355
_inspectionSettingsFilter = value;
5456
OnPropertyChanged(nameof(InspectionSettings));
57+
58+
if (string.IsNullOrEmpty(value))
59+
{
60+
InspectionSettings.Filter = null;
61+
}
62+
else
63+
{
64+
InspectionSettings.Filter = item => (item as CodeInspectionSetting)?
65+
.Description.ToUpper()
66+
.Contains(value.ToUpper()) ?? true;
67+
}
5568
}
5669
}
5770
}
@@ -61,14 +74,6 @@ public ListCollectionView InspectionSettings
6174
{
6275
get
6376
{
64-
if (string.IsNullOrEmpty(_inspectionSettingsFilter))
65-
{
66-
_inspectionSettings.Filter = null;
67-
}
68-
else
69-
{
70-
_inspectionSettings.Filter = filter => FilterInspectionSettings(filter);
71-
}
7277
return _inspectionSettings;
7378
}
7479

@@ -82,12 +87,6 @@ public ListCollectionView InspectionSettings
8287
}
8388
}
8489

85-
private bool FilterInspectionSettings(object filter)
86-
{
87-
var cis = filter as CodeInspectionSetting;
88-
return cis.Description.ToUpper().Contains(_inspectionSettingsFilter.ToUpper());
89-
}
90-
9190
private bool _runInspectionsOnSuccessfulParse;
9291
public bool RunInspectionsOnSuccessfulParse
9392
{

0 commit comments

Comments
 (0)