~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/ResourceToolkit/Project/Src/Commands/RefactoringCommands.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using System.Windows.Forms;
 
7
 
 
8
using Hornung.ResourceToolkit.Gui;
 
9
using Hornung.ResourceToolkit.Refactoring;
 
10
using ICSharpCode.Core;
 
11
using ICSharpCode.SharpDevelop.Gui;
 
12
using ICSharpCode.SharpDevelop.Refactoring;
 
13
 
 
14
namespace Hornung.ResourceToolkit.Commands
 
15
{
 
16
        public static class FindMissingResourceKeysHelper
 
17
        {
 
18
                public static void Run(SearchScope scope) {
 
19
                        // Allow the menu to close
 
20
                        Application.DoEvents();
 
21
                        using(AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:Hornung.ResourceToolkit.FindMissingResourceKeys}")) {
 
22
                                FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:Hornung.ResourceToolkit.ReferencesToMissingKeys}"),
 
23
                                                                                  ResourceRefactoringService.FindReferencesToMissingKeys(monitor, scope));
 
24
                        }
 
25
                }
 
26
        }
 
27
        
 
28
        /// <summary>
 
29
        /// Find missing resource keys in the whole solution.
 
30
        /// </summary>
 
31
        public class FindMissingResourceKeysWholeSolutionCommand : AbstractMenuCommand
 
32
        {
 
33
                public override void Run()
 
34
                {
 
35
                        FindMissingResourceKeysHelper.Run(SearchScope.WholeSolution);
 
36
                }
 
37
        }
 
38
        
 
39
        /// <summary>
 
40
        /// Find missing resource keys in the current project.
 
41
        /// </summary>
 
42
        public class FindMissingResourceKeysCurrentProjectCommand : AbstractMenuCommand
 
43
        {
 
44
                public override void Run()
 
45
                {
 
46
                        FindMissingResourceKeysHelper.Run(SearchScope.CurrentProject);
 
47
                }
 
48
        }
 
49
        
 
50
        /// <summary>
 
51
        /// Find missing resource keys in the current file.
 
52
        /// </summary>
 
53
        public class FindMissingResourceKeysCurrentFileCommand : AbstractMenuCommand
 
54
        {
 
55
                public override void Run()
 
56
                {
 
57
                        FindMissingResourceKeysHelper.Run(SearchScope.CurrentFile);
 
58
                }
 
59
        }
 
60
        
 
61
        /// <summary>
 
62
        /// Find missing resource keys in all open files.
 
63
        /// </summary>
 
64
        public class FindMissingResourceKeysOpenFilesCommand : AbstractMenuCommand
 
65
        {
 
66
                public override void Run()
 
67
                {
 
68
                        FindMissingResourceKeysHelper.Run(SearchScope.OpenFiles);
 
69
                }
 
70
        }
 
71
        
 
72
        /// <summary>
 
73
        /// Find unused resource keys in the whole solution.
 
74
        /// </summary>
 
75
        public class FindUnusedResourceKeysCommand : AbstractMenuCommand
 
76
        {
 
77
                public override void Run()
 
78
                {
 
79
                        ICollection<ResourceItem> unusedKeys;
 
80
                        
 
81
                        // Allow the menu to close
 
82
                        Application.DoEvents();
 
83
                        using(AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:Hornung.ResourceToolkit.FindUnusedResourceKeys}")) {
 
84
                                unusedKeys = ResourceRefactoringService.FindUnusedKeys(monitor);
 
85
                        }
 
86
                        
 
87
                        if (unusedKeys == null) {
 
88
                                return;
 
89
                        }
 
90
                        
 
91
                        if (unusedKeys.Count == 0) {
 
92
                                MessageService.ShowMessage("${res:Hornung.ResourceToolkit.UnusedResourceKeys.NotFound}");
 
93
                                return;
 
94
                        }
 
95
                        
 
96
                        IWorkbench workbench = WorkbenchSingleton.Workbench;
 
97
                        if (workbench != null) {
 
98
                                UnusedResourceKeysViewContent vc = new UnusedResourceKeysViewContent(unusedKeys);
 
99
                                workbench.ShowView(vc);
 
100
                        }
 
101
                }
 
102
        }
 
103
}