diff --git a/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml b/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml
index 854844d4f4..232a05294a 100644
--- a/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml
+++ b/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml
@@ -19,6 +19,6 @@
-
+
diff --git a/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml.cs b/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml.cs
index 245f5bd3dc..99fcc0530d 100644
--- a/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml.cs
+++ b/src/Integration.Vsix/Settings/GeneralOptionsDialogControl.xaml.cs
@@ -21,6 +21,7 @@
using Microsoft.VisualStudio.Shell;
using System.Windows;
using System.Windows.Controls;
+using System;
namespace SonarLint.VisualStudio.Integration.Vsix
{
@@ -29,17 +30,76 @@ namespace SonarLint.VisualStudio.Integration.Vsix
///
public partial class GeneralOptionsDialogControl : UserControl
{
+ private ISonarLintSettings settings;
+ private ISonarLintDaemon daemon;
+
public GeneralOptionsDialogControl()
{
InitializeComponent();
}
- private void OnInstallJavaScriptClicked(object sender, RoutedEventArgs e)
+ protected override void OnInitialized(EventArgs e)
+ {
+ base.OnInitialized(e);
+
+ UpdateActivateMoreButtonText();
+ }
+
+ private void UpdateActivateMoreButtonText()
+ {
+ ActivateMoreButton.Content = Settings.IsActivateMoreEnabled
+ ? "Deactivate JavaScript support"
+ : "Install and activate JavaScript support";
+ }
+
+ private void OnActivateMoreClicked(object sender, RoutedEventArgs e)
{
- var daemon = ServiceProvider.GlobalProvider.GetMefService();
- if (!daemon.IsInstalled)
+ if (Settings.IsActivateMoreEnabled)
+ {
+ if (Daemon.IsRunning)
+ {
+ Daemon.Stop();
+ }
+ }
+ else
{
- new SonarLintDaemonInstaller().Show();
+ if (!Daemon.IsInstalled)
+ {
+ new SonarLintDaemonInstaller().Show();
+ }
+ else if (!Daemon.IsRunning)
+ {
+ Daemon.Start();
+ }
+ }
+
+ Settings.IsActivateMoreEnabled = !Settings.IsActivateMoreEnabled;
+ UpdateActivateMoreButtonText();
+ }
+
+ private ISonarLintSettings Settings
+ {
+ get
+ {
+ if (this.settings == null)
+ {
+ this.settings = ServiceProvider.GlobalProvider.GetMefService();
+ }
+
+ return this.settings;
+ }
+ }
+
+ private ISonarLintDaemon Daemon
+ {
+ get
+ {
+ if (this.daemon == null)
+ {
+ this.daemon = ServiceProvider.GlobalProvider.GetMefService();
+ }
+
+ return this.daemon;
}
}
}
diff --git a/src/Integration.Vsix/Settings/SonarLintSettings.cs b/src/Integration.Vsix/Settings/SonarLintSettings.cs
index f8569fb76f..cc39c072c6 100644
--- a/src/Integration.Vsix/Settings/SonarLintSettings.cs
+++ b/src/Integration.Vsix/Settings/SonarLintSettings.cs
@@ -31,6 +31,7 @@ public interface ISonarLintSettings
{
bool ShowServerNuGetTrustWarning { get; set; }
bool IsAnonymousDataShared { get; set; }
+ bool IsActivateMoreEnabled { get; set; }
bool SkipActivateMoreDialog { get; set; }
}
@@ -114,8 +115,14 @@ public bool IsAnonymousDataShared
public bool SkipActivateMoreDialog
{
- get { return this.GetValueOrDefault(nameof(SkipActivateMoreDialog), true); }
+ get { return this.GetValueOrDefault(nameof(SkipActivateMoreDialog), false); }
set { this.SetValue(nameof(SkipActivateMoreDialog), value); }
}
+
+ public bool IsActivateMoreEnabled
+ {
+ get { return this.GetValueOrDefault(nameof(IsActivateMoreEnabled), false); }
+ set { this.SetValue(nameof(IsActivateMoreEnabled), value); }
+ }
}
}
diff --git a/src/Integration.Vsix/SonarLintDaemon/ISonarLintDaemon.cs b/src/Integration.Vsix/SonarLintDaemon/ISonarLintDaemon.cs
index 34883c30f4..c4adf64c43 100644
--- a/src/Integration.Vsix/SonarLintDaemon/ISonarLintDaemon.cs
+++ b/src/Integration.Vsix/SonarLintDaemon/ISonarLintDaemon.cs
@@ -11,6 +11,7 @@ interface ISonarLintDaemon : IDisposable
void Install();
void Start();
+ void Stop();
void RequestAnalysis(string path, string charset, IIssueConsumer consumer);
}
diff --git a/src/Integration.Vsix/SonarLintDaemonPackage.cs b/src/Integration.Vsix/SonarLintDaemonPackage.cs
index ef002b6a3e..b603bdb000 100644
--- a/src/Integration.Vsix/SonarLintDaemonPackage.cs
+++ b/src/Integration.Vsix/SonarLintDaemonPackage.cs
@@ -52,6 +52,7 @@ public sealed class SonarLintDaemonPackage : Package
{
public const string PackageGuidString = "6f63ab5a-5ab8-4a0d-9914-151911885966";
+ private readonly ISonarLintSettings settings = ServiceProvider.GlobalProvider.GetMefService();
private readonly ISonarLintDaemon daemon = ServiceProvider.GlobalProvider.GetMefService();
///
@@ -75,7 +76,7 @@ protected override void Initialize()
{
base.Initialize();
- if (daemon.IsInstalled)
+ if (settings.IsActivateMoreEnabled && daemon.IsInstalled)
{
if (!daemon.IsRunning)
{
@@ -100,8 +101,10 @@ private void LaunchActivateMoreDialog()
var result = MessageBox.Show(message, title, MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
+ settings.IsActivateMoreEnabled = true;
new SonarLintDaemonInstaller().Show();
}
+ settings.SkipActivateMoreDialog = true;
}
protected override void Dispose(bool disposing)