Skip to content

Commit 61087e7

Browse files
authored
Merge pull request #4748 from comintern/next
Show empty UI message in code explorer if no project nodes are found.
2 parents 3442593 + c9e6f29 commit 61087e7

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ private void HandleStateChanged(object sender, ParserStateEventArgs e)
230230
library.UpdateChildren();
231231
}
232232

233+
Unparsed = !Projects.Any();
233234
IsBusy = false;
234235
});
235236
return;

Rubberduck.Core/UI/AddRemoveReferences/AddRemoveReferencesWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@
223223
BorderBrush="{x:Static SystemColors.ControlLightBrush}"
224224
Background="Transparent"
225225
Width="20" Height="20" Padding="0" Margin="0,1">
226-
<Image Margin="2" Width="16" Height="16" Source="{Binding Search, Converter={StaticResource SearchToIcon}, UpdateSourceTrigger=PropertyChanged}" />
226+
<Image VerticalAlignment="Center" HorizontalAlignment="Center"
227+
Width="16" Height="16" Source="{Binding Search, Converter={StaticResource SearchToIcon}, UpdateSourceTrigger=PropertyChanged}" />
227228
<i:Interaction.Behaviors>
228229
<controls:FocusElementAfterClickBehavior FocusElement="{Binding ElementName=SearchBox, Mode=OneWay}"/>
229230
</i:Interaction.Behaviors>

Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
</Style>
219219

220220
<Style x:Key="ToolbarImageOpacity" TargetType="Image" BasedOn="{StaticResource ToolbarIconStyle}">
221+
<Setter Property="Margin" Value="0" />
221222
<Style.Triggers>
222223
<Trigger Property="IsEnabled" Value="False">
223224
<Setter Property="Opacity" Value="0.3" />
@@ -437,7 +438,8 @@
437438
BorderBrush="{x:Static SystemColors.ControlLightBrush}"
438439
Background="Transparent"
439440
Width="20" Height="20" Padding="0" Margin="0,1">
440-
<Image Margin="2" Width="16" Height="16" Source="{Binding Search, Converter={StaticResource SearchToIcon}, UpdateSourceTrigger=PropertyChanged}" />
441+
<Image VerticalAlignment="Center" HorizontalAlignment="Center"
442+
Width="16" Height="16" Source="{Binding Search, Converter={StaticResource SearchToIcon}, UpdateSourceTrigger=PropertyChanged}" />
441443
<i:Interaction.Behaviors>
442444
<controls:FocusElementAfterClickBehavior FocusElement="{Binding ElementName=SearchBox, Mode=OneWay}"/>
443445
</i:Interaction.Behaviors>

RubberduckTests/CodeExplorer/CodeExplorerViewModelTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
4+
using System.Threading;
35
using System.Windows.Forms;
46
using NUnit.Framework;
57
using Moq;
68
using Rubberduck.Navigation.CodeExplorer;
79
using Rubberduck.VBEditor.SafeComWrappers;
810
using Rubberduck.Interaction;
11+
using Rubberduck.Parsing.UIContext;
12+
using Rubberduck.Parsing.VBA;
13+
using Rubberduck.UI.CodeExplorer.Commands;
14+
using Rubberduck.UI.Command;
15+
using RubberduckTests.Mocks;
16+
using MessageBox = System.Windows.MessageBox;
917

1018
namespace RubberduckTests.CodeExplorer
1119
{
@@ -838,5 +846,28 @@ public void CollapseAllNodes_StartingWithSubNode()
838846
Assert.IsFalse(GetNodeExpandedStates(collapsed).All(state => state));
839847
}
840848
}
849+
850+
[Category("Code Explorer")]
851+
[Test]
852+
public void UnparsedSetToTrue_NoProjects()
853+
{
854+
var builder = new MockVbeBuilder();
855+
var vbe = builder.Build();
856+
var parser = MockParser.Create(vbe.Object, null, MockVbeEvents.CreateMockVbeEvents(vbe));
857+
var state = parser.State;
858+
var dispatcher = new Mock<IUiDispatcher>();
859+
860+
dispatcher.Setup(m => m.Invoke(It.IsAny<Action>())).Callback((Action argument) => argument.Invoke());
861+
862+
var viewModel = new CodeExplorerViewModel(state, null, null, null, dispatcher.Object, vbe.Object, null, new CodeExplorerSyncProvider(vbe.Object, state));
863+
864+
parser.Parse(new CancellationTokenSource());
865+
if (parser.State.Status >= ParserState.Error)
866+
{
867+
Assert.Inconclusive("Parser Error");
868+
}
869+
870+
Assert.IsTrue(viewModel.Unparsed);
871+
}
841872
}
842873
}

0 commit comments

Comments
 (0)