|
|
|
@ -21,6 +21,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring
@@ -21,6 +21,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring
|
|
|
|
|
{ |
|
|
|
|
private static ContextActionsService instance = new ContextActionsService(); |
|
|
|
|
|
|
|
|
|
const string PropertyServiceKey = "DisabledContextActionProviders"; |
|
|
|
|
|
|
|
|
|
public static ContextActionsService Instance { |
|
|
|
|
get { |
|
|
|
|
return instance; |
|
|
|
@ -32,9 +34,10 @@ namespace ICSharpCode.SharpDevelop.Refactoring
@@ -32,9 +34,10 @@ namespace ICSharpCode.SharpDevelop.Refactoring
|
|
|
|
|
private ContextActionsService() |
|
|
|
|
{ |
|
|
|
|
this.providers = AddInTree.BuildItems<IContextActionsProvider>("/SharpDevelop/ViewContent/AvalonEdit/ContextActions", null, false); |
|
|
|
|
var disabledActions = LoadProviderVisibilities().ToLookup(s => s); |
|
|
|
|
foreach (var provider in providers) { |
|
|
|
|
// load from configuration
|
|
|
|
|
provider.IsVisible = true; |
|
|
|
|
provider.IsVisible = !disabledActions.Contains(provider.GetType().FullName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -42,6 +45,17 @@ namespace ICSharpCode.SharpDevelop.Refactoring
@@ -42,6 +45,17 @@ namespace ICSharpCode.SharpDevelop.Refactoring
|
|
|
|
|
{ |
|
|
|
|
return new EditorActionsProvider(editor, this.providers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static List<string> LoadProviderVisibilities() |
|
|
|
|
{ |
|
|
|
|
return PropertyService.Get(PropertyServiceKey, new List<string>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void SaveProviderVisibilities() |
|
|
|
|
{ |
|
|
|
|
List<string> disabledProviders = this.providers.Where(p => !p.IsVisible).Select(p => p.GetType().FullName).ToList(); |
|
|
|
|
PropertyService.Set(PropertyServiceKey, disabledProviders); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -79,8 +93,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring
@@ -79,8 +93,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring
|
|
|
|
|
if (providerForAction.TryGetValue(action, out provider)) { |
|
|
|
|
provider.IsVisible = isVisible; |
|
|
|
|
} |
|
|
|
|
ContextActionsService.Instance.SaveProviderVisibilities(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// For every returned action remembers its provider for so that SetVisible can work.
|
|
|
|
|
/// </summary>
|
|
|
|
|
Dictionary<IContextAction, IContextActionsProvider> providerForAction = new Dictionary<IContextAction, IContextActionsProvider>(); |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|