| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<00000141d93fd05e-d8669df1-8ba5-480b-aecf-6425ad36f88f-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/26c94b2b3d68...1d7cd9b1ba35
Commit: 1d7cd9b1ba357217a5bc3da55735ae9e6abfe34a
Author: Mike Krüger <[email protected]> (mkrueger)
Date: 2013-10-21 04:20:45 GMT
URL: https://github.com/mono/monodevelop/commit/1d7cd9b1ba357217a5bc3da55735ae9e6abfe34a
[Ide] Implemented search in solution category.
Changed paths:
M main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs
M main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs
M main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
Added paths:
A main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs
Added: main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs
===================================================================
@@ -0,0 +1,118 @@
+//
+// SearchInSolutionSearchCategory.cs
+//
+// Author:
+// Mike Krüger <[email protected]>
+//
+// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using ICSharpCode.NRefactory.TypeSystem;
+using MonoDevelop.Ide.FindInFiles;
+using System.Linq;
+using MonoDevelop.Ide.Gui;
+
+namespace MonoDevelop.Components.MainToolbar
+{
+ class SearchInSolutionSearchCategory : SearchCategory
+ {
+ public SearchInSolutionSearchCategory () : base (GettextCatalog.GetString("Search"))
+ {
+ }
+
+ public override Task<ISearchDataSource> GetResults (SearchPopupSearchPattern searchPattern, int resultsCount, CancellationToken token)
+ {
+ return Task.Factory.StartNew (delegate {
+ return (ISearchDataSource)new SearchInSolutionDataSource (searchPattern);
+ });
+ }
+
+ public override bool IsValidTag (string tag)
+ {
+ return tag == "search";
+ }
+
+ class SearchInSolutionDataSource : ISearchDataSource
+ {
+ readonly SearchPopupSearchPattern searchPattern;
+
+ public SearchInSolutionDataSource (SearchPopupSearchPattern searchPattern)
+ {
+ this.searchPattern = searchPattern;
+ }
+
+ #region ISearchDataSource implementation
+
+ Gdk.Pixbuf ISearchDataSource.GetIcon (int item)
+ {
+ return null;
+ }
+
+ string ISearchDataSource.GetMarkup (int item, bool isSelected)
+ {
+ return GettextCatalog.GetString ("Search in solution");
+ }
+
+ string ISearchDataSource.GetDescriptionMarkup (int item, bool isSelected)
+ {
+ return null;
+ }
+
+ MonoDevelop.Ide.CodeCompletion.TooltipInformation ISearchDataSource.GetTooltip (int item)
+ {
+ return null;
+ }
+
+ double ISearchDataSource.GetWeight (int item)
+ {
+ return 0;
+ }
+
+ DomRegion ISearchDataSource.GetRegion (int item)
+ {
+ return DomRegion.Empty;
+ }
+
+ bool ISearchDataSource.CanActivate (int item)
+ {
+ return true;
+ }
+
+ void ISearchDataSource.Activate (int item)
+ {
+ var options = new FilterOptions ();
+ if (PropertyService.Get ("AutoSetPatternCasing", true))
+ options.CaseSensitive = searchPattern.Pattern.Any (c => char.IsUpper (c));
+ FindInFilesDialog.SearchReplace (searchPattern.Pattern, null, new WholeSolutionScope (), options, null);
+ }
+
+ int ISearchDataSource.ItemCount {
+ get {
+ return 1;
+ }
+ }
+ #endregion
+ }
+ }
+}
+
Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs
===================================================================
@@ -119,6 +119,7 @@ public SearchPopupWindow ()
categories.Add (new ProjectSearchCategory (this));
categories.Add (new FileSearchCategory (this));
categories.Add (new CommandSearchCategory (this));
+ categories.Add (new SearchInSolutionSearchCategory ());
layout = new Pango.Layout (PangoContext);
headerLayout = new Pango.Layout (PangoContext);
Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs
===================================================================
@@ -25,8 +25,8 @@
// THE SOFTWARE.
using System;
-using System.Linq;
-using System.Threading;
+using System.Linq;
+using System.Threading;
using System.Text;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
@@ -38,7 +38,7 @@
namespace MonoDevelop.Ide.FindInFiles
{
public partial class FindInFilesDialog : Gtk.Dialog
- {
+ {
readonly bool writeScope = true;
enum SearchScope {
@@ -48,15 +48,15 @@ enum SearchScope {
Directories,
CurrentDocument,
Selection
- }
+ }
- CheckButton checkbuttonRecursively;
+ CheckButton checkbuttonRecursively;
ComboBoxEntry comboboxentryReplace;
ComboBoxEntry comboboxentryPath;
SearchEntry searchentryFileMask;
Button buttonBrowsePaths;
Button buttonReplace;
- Label labelFileMask;
+ Label labelFileMask;
Label labelReplace;
Label labelPath;
HBox hboxPath;
@@ -509,8 +509,8 @@ protected override void OnSizeRequested (ref Requisition requisition)
{
base.OnSizeRequested (ref requisition);
requisition.Width = Math.Max (480, requisition.Width);
- }
-
+ }
+
static void ComboboxentryPathDestroyed (object sender, EventArgs e)
{
StoreHistory ("MonoDevelop.FindReplaceDialogs.PathHistory", (ComboBoxEntry)sender);
@@ -530,8 +530,8 @@ void ButtonBrowsePathsClicked (object sender, EventArgs e)
if (dlg.Run ())
comboboxentryPath.Entry.Text = dlg.SelectedFile;
- }
-
+ }
+
void CheckbuttonRecursivelyDestroyed (object sender, EventArgs e)
{
properties.Set ("SearchPathRecursively", ((CheckButton)sender).Active);
@@ -675,10 +675,10 @@ Scope GetScope ()
break;
case SearchScope.CurrentProject:
var currentSelectedProject = IdeApp.ProjectOperations.CurrentSelectedProject;
- if (currentSelectedProject != null) {
+ if (currentSelectedProject != null) {
scope = new WholeProjectScope (currentSelectedProject);
break;
- }
+ }
if (IdeApp.Workspace.IsOpen && IdeApp.ProjectOperations.CurrentSelectedSolution != null) {
var question = GettextCatalog.GetString (
"Currently there is no project selected. Search in the solution instead ?");
@@ -720,21 +720,21 @@ FilterOptions GetFilterOptions ()
CaseSensitive = checkbuttonCaseSensitive.Active,
RegexSearch = checkbuttonRegexSearch.Active,
WholeWordsOnly = checkbuttonWholeWordsOnly.Active
- };
+ };
}
static FindReplace find;
void HandleReplaceClicked (object sender, EventArgs e)
{
- SearchReplace (comboboxentryReplace.Entry.Text ?? "");
+ SearchReplace (comboboxentryFind.Entry.Text, comboboxentryReplace.Entry.Text ?? "", GetScope (), GetFilterOptions (), () => UpdateStopButton ());
}
void HandleSearchClicked (object sender, EventArgs e)
{
- SearchReplace (null);
- }
-
- readonly List<ISearchProgressMonitor> searchesInProgress = new List<ISearchProgressMonitor> ();
+ SearchReplace (comboboxentryFind.Entry.Text, null, GetScope (), GetFilterOptions (), () => UpdateStopButton ());
+ }
+
+ readonly static List<ISearchProgressMonitor> searchesInProgress = new List<ISearchProgressMonitor> ();
void UpdateStopButton ()
{
buttonStop.Sensitive = searchesInProgress.Count > 0;
@@ -750,7 +750,7 @@ void ButtonStopClicked (object sender, EventArgs e)
}
}
- void SearchReplace (string replacePattern)
+ internal static void SearchReplace (string findPattern, string replacePattern, Scope scope, FilterOptions options, System.Action UpdateStopButton)
{
if (find != null && find.IsRunning) {
if (!MessageService.Confirm (GettextCatalog.GetString ("There is a search already in progress. Do you want to stop it?"), AlertButton.Stop))
@@ -762,14 +762,12 @@ void SearchReplace (string replacePattern)
}
}
- Scope scope = GetScope ();
if (scope == null)
return;
find = new FindReplace ();
- string pattern = comboboxentryFind.Entry.Text;
- FilterOptions options = GetFilterOptions ();
+ string pattern = findPattern;
if (!find.ValidatePattern (options, pattern)) {
MessageService.ShowError (GettextCatalog.GetString ("Search pattern is invalid"));
return;
@@ -786,7 +784,11 @@ void SearchReplace (string replacePattern)
lock (searchesInProgress)
searchesInProgress.Add (searchMonitor);
- UpdateStopButton ();
+ if (UpdateStopButton != null) {
+ Application.Invoke (delegate {
+ UpdateStopButton ();
+ });
+ }
DateTime timer = DateTime.Now;
string errorMessage = null;
@@ -797,7 +799,7 @@ void SearchReplace (string replacePattern)
if (searchMonitor.IsCancelRequested)
return;
results.Add (result);
- }
+ }
searchMonitor.ReportResults (results);
} catch (Exception ex) {
errorMessage = ex.Message;
@@ -821,9 +823,11 @@ void SearchReplace (string replacePattern)
searchMonitor.Log.WriteLine (GettextCatalog.GetString ("Search time: {0} seconds."), (DateTime.Now - timer).TotalSeconds);
searchesInProgress.Remove (searchMonitor);
}
- Application.Invoke (delegate {
- UpdateStopButton ();
- });
+ if (UpdateStopButton != null) {
+ Application.Invoke (delegate {
+ UpdateStopButton ();
+ });
+ }
});
}
}
Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
===================================================================
@@ -22,8 +22,8 @@
</Execution>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DefineConstants>DEBUG</DefineConstants>
- <GenerateDocumentation>true</GenerateDocumentation>
<NoWarn>1591;1573</NoWarn>
+ <DocumentationFile>..\..\..\build\bin\MonoDevelop.Ide.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -36,8 +36,8 @@
</Execution>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DebugSymbols>true</DebugSymbols>
- <GenerateDocumentation>true</GenerateDocumentation>
<NoWarn>1591;1573</NoWarn>
+ <DocumentationFile>..\..\..\build\AddIns\MonoDevelop.Ide.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -1901,6 +1901,7 @@
<Compile Include="MonoDevelop.Ide.TypeSystem\IRefactoringContext.cs" />
<Compile Include="MonoDevelop.Ide.Gui.Pads.ProjectPad\ImplicitFrameworkAssemblyReferenceNodeBuilder.cs" />
<Compile Include="MonoDevelop.Ide.Gui.Pads.ProjectPad\PortableFrameworkSubsetNodeBuilder.cs" />
+ <Compile Include="MonoDevelop.Components.MainToolbar\SearchInSolutionSearchCategory.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches