Skip to content

Commit a509c60

Browse files
SLVS-2526 Show rule help panel on double click
1 parent 226ee05 commit a509c60

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/IssueViz.Security/ReportView/ReportViewControl.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<Setter Property="IsExpanded" Value="True" />
5858
<Setter Property="Foreground" Value="{DynamicResource {x:Static vsShell:VsBrushes.BrandedUITextKey}}" />
5959
<EventSetter Event="PreviewMouseUp" Handler="TreeViewItem_OnPreviewMouseUp"/>
60+
<EventSetter Event="MouseDoubleClick" Handler="TreeViewItem_MouseDoubleClick"/>
6061
<Setter Property="Template">
6162
<Setter.Value>
6263
<ControlTemplate TargetType="TreeViewItem">

src/IssueViz.Security/ReportView/ReportViewControl.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,18 @@ private async void ChangeScaStatusMenuItem_OnClick(object sender, RoutedEventArg
147147
private void TreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) => ReportViewModel.SelectedItem = e.NewValue as IIssueViewModel;
148148

149149
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) => browserService.Navigate(e.Uri.AbsoluteUri);
150+
151+
private void TreeViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
152+
{
153+
if ((sender as FrameworkElement)?.DataContext is not IIssueViewModel issueViewModel)
154+
{
155+
return;
156+
}
157+
158+
var commandParam = new NavigateToRuleDescriptionCommandParam { FullRuleKey = issueViewModel.RuleInfo.RuleKey, IssueId = issueViewModel.RuleInfo.IssueId };
159+
if (ReportViewModel.NavigateToRuleDescriptionCommand.CanExecute(commandParam))
160+
{
161+
ReportViewModel.NavigateToRuleDescriptionCommand.Execute(commandParam);
162+
}
163+
}
150164
}

src/IssueViz/IssueVisualizationControl/ViewModels/Commands/NavigateToRuleDescriptionCommand.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
2221
using System.ComponentModel.Composition;
23-
using System.Diagnostics;
2422
using System.Globalization;
2523
using System.Windows.Data;
2624
using System.Windows.Input;
@@ -48,13 +46,13 @@ public NavigateToRuleDescriptionCommand(IEducation educationService)
4846
}
4947
},
5048
parameter => parameter is NavigateToRuleDescriptionCommandParam s &&
51-
!string.IsNullOrEmpty(s.FullRuleKey) &&
52-
SonarCompositeRuleId.TryParse(s.FullRuleKey, out var _))
49+
!string.IsNullOrEmpty(s.FullRuleKey) &&
50+
SonarCompositeRuleId.TryParse(s.FullRuleKey, out var _))
5351
{
5452
}
5553
}
5654

57-
internal class NavigateToRuleDescriptionCommandParam
55+
public class NavigateToRuleDescriptionCommandParam
5856
{
5957
/// <summary>
6058
/// The id of the issue that comes from SlCore
@@ -65,7 +63,11 @@ internal class NavigateToRuleDescriptionCommandParam
6563

6664
public class NavigateToRuleDescriptionCommandConverter : IMultiValueConverter
6765
{
68-
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
66+
public object Convert(
67+
object[] values,
68+
Type targetType,
69+
object parameter,
70+
CultureInfo culture)
6971
{
7072
if (values.Length == 2 && values[0] is string && (values[1] is Guid || values[1] == null))
7173
{
@@ -74,7 +76,11 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
7476
return null;
7577
}
7678

77-
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
79+
public object[] ConvertBack(
80+
object value,
81+
Type[] targetTypes,
82+
object parameter,
83+
CultureInfo culture)
7884
{
7985
Debug.Fail("We should not hit here");
8086
return null;

0 commit comments

Comments
 (0)