Skip to content

Commit b50294a

Browse files
committed
Respond to comments. Still one bug when adding item and editing at the same time.
1 parent 56ff99d commit b50294a

16 files changed

+124
-67
lines changed

RetailCoder.VBE/Inspections/UseMeaningfulNameInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3131

3232
try
3333
{
34-
whitelistedNames = _settings.Load(new CodeInspectionSettings()).WhitelistedNames.Select(s => s.Name).ToList();
34+
whitelistedNames = _settings.Load(new CodeInspectionSettings()).WhitelistedIdentifiers.Select(s => s.Identifier).ToList();
3535
}
3636
catch (IOException) { }
3737

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404
<Compile Include="Settings\RubberduckHotkey.cs" />
405405
<Compile Include="Settings\ToDoListConfigProvider.cs" />
406406
<Compile Include="Settings\UnitTestConfigProvider.cs" />
407-
<Compile Include="Settings\WhitelistedNameSetting.cs" />
407+
<Compile Include="Settings\WhitelistedIdentifierSetting.cs" />
408408
<Compile Include="Sinks.cs" />
409409
<Compile Include="UI\About\AboutControl.xaml.cs">
410410
<DependentUpon>AboutControl.xaml</DependentUpon>

RetailCoder.VBE/Settings/CodeInspectionConfigProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public CodeInspectionSettings Create(IEnumerable<IInspection> inspections)
2727
if (inspections == null) return null;
2828

2929
_inspections = inspections;
30-
var prototype = new CodeInspectionSettings(GetDefaultCodeInspections(), new WhitelistedNameSetting[] {});
30+
var prototype = new CodeInspectionSettings(GetDefaultCodeInspections(), new WhitelistedIdentifierSetting[] {});
3131
return _persister.Load(prototype) ?? prototype;
3232
}
3333

3434
public CodeInspectionSettings CreateDefaults()
3535
{
3636
//This sucks.
3737
return _inspections != null
38-
? new CodeInspectionSettings(GetDefaultCodeInspections(), new WhitelistedNameSetting[] {})
38+
? new CodeInspectionSettings(GetDefaultCodeInspections(), new WhitelistedIdentifierSetting[] {})
3939
: null;
4040
}
4141

RetailCoder.VBE/Settings/CodeInspectionSettings.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Rubberduck.Settings
1010
public interface ICodeInspectionSettings
1111
{
1212
HashSet<CodeInspectionSetting> CodeInspections { get; set; }
13-
WhitelistedNameSetting[] WhitelistedNames { get; set; }
13+
WhitelistedIdentifierSetting[] WhitelistedIdentifiers { get; set; }
1414
}
1515

1616
[XmlType(AnonymousType = true)]
@@ -19,17 +19,17 @@ public class CodeInspectionSettings : ICodeInspectionSettings
1919
[XmlArrayItem("CodeInspection", IsNullable = false)]
2020
public HashSet<CodeInspectionSetting> CodeInspections { get; set; }
2121

22-
[XmlArrayItem("WhitelistedName", IsNullable = false)]
23-
public WhitelistedNameSetting[] WhitelistedNames { get; set; }
22+
[XmlArrayItem("WhitelistedIdentifier", IsNullable = false)]
23+
public WhitelistedIdentifierSetting[] WhitelistedIdentifiers { get; set; }
2424

25-
public CodeInspectionSettings() : this(new HashSet<CodeInspectionSetting>(), new WhitelistedNameSetting[] {})
25+
public CodeInspectionSettings() : this(new HashSet<CodeInspectionSetting>(), new WhitelistedIdentifierSetting[] {})
2626
{
2727
}
2828

29-
public CodeInspectionSettings(HashSet<CodeInspectionSetting> inspections, WhitelistedNameSetting[] whitelistedNames)
29+
public CodeInspectionSettings(HashSet<CodeInspectionSetting> inspections, WhitelistedIdentifierSetting[] whitelistedNames)
3030
{
3131
CodeInspections = inspections;
32-
WhitelistedNames = whitelistedNames;
32+
WhitelistedIdentifiers = whitelistedNames;
3333
}
3434

3535
public CodeInspectionSetting GetSetting(Type inspection)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Xml.Serialization;
2+
3+
namespace Rubberduck.Settings
4+
{
5+
[XmlType(AnonymousType = true)]
6+
public class WhitelistedIdentifierSetting
7+
{
8+
[XmlAttribute]
9+
public string Identifier { get; set; }
10+
11+
public WhitelistedIdentifierSetting(string identifier)
12+
{
13+
Identifier = identifier;
14+
}
15+
16+
public WhitelistedIdentifierSetting() : this("*") { }
17+
}
18+
}

RetailCoder.VBE/Settings/WhitelistedNameSetting.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

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

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,13 @@ All our stargazers, likers &amp; followers, for the warm fuzzies
17631763
<data name="RegexAssistant_Title" xml:space="preserve">
17641764
<value>Regular Expression Analyzer</value>
17651765
</data>
1766-
<data name="CodeInspectionSettings_WhitelistedNamesLabel" xml:space="preserve">
1767-
<value>Whitelisted Names:</value>
1766+
<data name="CodeInspectionSettings_WhitelistedIdentifiersLabel" xml:space="preserve">
1767+
<value>Whitelisted Identifiers</value>
1768+
</data>
1769+
<data name="CodeInspectionSettings_InspectionSeveritySettingsLabel" xml:space="preserve">
1770+
<value>Inspection Severities</value>
1771+
</data>
1772+
<data name="CodeInspectionSettings_WhitelistedIdentifiersDescription" xml:space="preserve">
1773+
<value>These identifiers will be ignored by the 'Use meaningful names' inspection</value>
17681774
</data>
17691775
</root>

RetailCoder.VBE/UI/Settings/InspectionSettings.xaml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,11 @@
258258
</UserControl.Resources>
259259
<Grid>
260260
<ScrollViewer>
261-
<StackPanel Margin="5,5,5,0" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto">
262-
<Label DockPanel.Dock="Top"
263-
Background="DarkGray"
261+
<StackPanel Margin="5,5,5,0" ScrollViewer.VerticalScrollBarVisibility="Auto">
262+
<Label Background="DarkGray"
264263
Foreground="White"
265264
FontWeight="SemiBold"
266-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SettingsCaption_InspectionSettings}"
265+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionSettings_InspectionSeveritySettingsLabel}"
267266
Margin="0,0,0,3">
268267
<Label.Style>
269268
<Style>
@@ -320,9 +319,22 @@
320319
</controls:GroupingGrid.Columns>
321320
</controls:GroupingGrid>
322321
</Border>
323-
<Label Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionSettings_WhitelistedNamesLabel}"
322+
<Label Background="DarkGray"
323+
Foreground="White"
324324
FontWeight="SemiBold"
325-
Margin="0,5,0,0" />
325+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionSettings_WhitelistedIdentifiersLabel}"
326+
Margin="0,5,0,3">
327+
<Label.Style>
328+
<Style>
329+
<Style.Resources>
330+
<Style TargetType="{x:Type Border}">
331+
<Setter Property="CornerRadius" Value="5"/>
332+
</Style>
333+
</Style.Resources>
334+
</Style>
335+
</Label.Style>
336+
</Label>
337+
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionSettings_WhitelistedIdentifiersDescription}" />
326338
<ToolBarTray IsLocked="True"
327339
Background="Transparent">
328340
<ToolBar Style="{DynamicResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}"
@@ -339,10 +351,10 @@
339351
</Button>
340352
<Button ToolTip="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Remove}"
341353
Command="{Binding DeleteWhitelistedNameCommand}"
342-
CommandParameter="{Binding ElementName=WhitelistedNamesGrid, Path=CurrentItem}"
354+
CommandParameter="{Binding ElementName=WhitelistedIdentifiersGrid, Path=CurrentItem}"
343355
BorderThickness="0"
344356
Background="Transparent"
345-
IsEnabled="{Binding ElementName=WhitelistedNamesGrid, Path=SelectedItem, Converter={StaticResource HasSelectedItems}}">
357+
IsEnabled="{Binding ElementName=WhitelistedIdentifiersGrid, Path=SelectedItem, Converter={StaticResource HasSelectedItems}}">
346358
<StackPanel Orientation="Horizontal">
347359
<Image Source="{StaticResource DeleteImage}" />
348360
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Remove}"
@@ -352,8 +364,8 @@
352364
</ToolBar>
353365
</ToolBarTray>
354366
<Border BorderBrush="DarkGray" BorderThickness="1" CornerRadius="2">
355-
<DataGrid Name="WhitelistedNamesGrid"
356-
ItemsSource="{Binding WhitelistedNameSettings}"
367+
<DataGrid Name="WhitelistedIdentifiersGrid"
368+
ItemsSource="{Binding WhitelistedIdentifierSettings}"
357369
AutoGenerateColumns="False"
358370
CanUserReorderColumns="False"
359371
IsReadOnly="False"
@@ -367,11 +379,12 @@
367379
ItemContainerStyle="{StaticResource PrettifyRow}"
368380
ColumnHeaderHeight="22"
369381
BorderThickness="0"
370-
Height="200">
382+
Height="200"
383+
CellEditEnding="WhitelistedIdentifierGrid_CellEditEnding">
371384
<DataGrid.InputBindings>
372385
<KeyBinding Key="Delete"
373386
Command="{Binding DeleteWhitelistedNameCommand}"
374-
CommandParameter="{Binding ElementName=WhitelistedNamesGrid, Path=SelectedItem}" />
387+
CommandParameter="{Binding ElementName=WhitelistedIdentifiersGrid, Path=SelectedItem}" />
375388
</DataGrid.InputBindings>
376389
<DataGrid.CellStyle>
377390
<Style TargetType="{x:Type DataGridCell}">
@@ -382,7 +395,7 @@
382395
</DataGrid.CellStyle>
383396
<DataGrid.Columns>
384397
<DataGridTextColumn Width="*"
385-
Binding="{Binding Name}" />
398+
Binding="{Binding Identifier}" />
386399
</DataGrid.Columns>
387400
</DataGrid>
388401
</Border>

RetailCoder.VBE/UI/Settings/InspectionSettings.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Linq;
33
using System.Windows.Controls;
44
using Rubberduck.Inspections;
5+
using System.Collections.ObjectModel;
6+
using Rubberduck.Settings;
57

68
namespace Rubberduck.UI.Settings
79
{
@@ -33,5 +35,18 @@ private void GroupingGrid_CellEditEnding(object sender, DataGridCellEditEndingEv
3335

3436
((InspectionSettingsViewModel) ViewModel).UpdateCollection(selectedSeverity);
3537
}
38+
39+
private void WhitelistedIdentifierGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
40+
{
41+
if (e.Cancel || e.EditAction == DataGridEditAction.Cancel) { return; }
42+
43+
var identifiers = WhitelistedIdentifiersGrid.ItemsSource.OfType<WhitelistedIdentifierSetting>().ToList();
44+
45+
var editedIndex = e.Row.GetIndex();
46+
identifiers.RemoveAt(editedIndex);
47+
identifiers.Insert(editedIndex, new WhitelistedIdentifierSetting(((TextBox)e.EditingElement).Text));
48+
49+
((InspectionSettingsViewModel)ViewModel).WhitelistedIdentifierSettings = new ObservableCollection<WhitelistedIdentifierSetting>(identifiers);
50+
}
3651
}
3752
}

0 commit comments

Comments
 (0)