[Monodevelop-patches-list] r2059 - in trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor: . Gui/Pads Search
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Tue Dec 7 15:38:11 EST 2004
Author: lluis
Date: 2004-12-07 15:38:11 -0500 (Tue, 07 Dec 2004)
New Revision: 2059
Modified:
trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/Pads/CompilerMessageView.cs
trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceInFilesManager.cs
Log:
2004-12-07 Lluis Sanchez Gual <lluis at novell.com>
* Gui/Pads/CompilerMessageView.cs: Subscribe to service events using
gui-thread aware delegates. Use Runtime class to access services.
* Search/SearchReplaceInFilesManager.cs: TaskService is now gui-thread
safe, so this class can be simplified.
Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog 2004-12-07 20:36:29 UTC (rev 2058)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog 2004-12-07 20:38:11 UTC (rev 2059)
@@ -1,3 +1,10 @@
+2004-12-07 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Gui/Pads/CompilerMessageView.cs: Subscribe to service events using
+ gui-thread aware delegates. Use Runtime class to access services.
+ * Search/SearchReplaceInFilesManager.cs: TaskService is now gui-thread
+ safe, so this class can be simplified.
+
2004-12-06 Lluis Sanchez Gual <lluis at novell.com>
* InsightWindow/MethodInsightDataProvider.cs:
Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/Pads/CompilerMessageView.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/Pads/CompilerMessageView.cs 2004-12-07 20:36:29 UTC (rev 2058)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/Pads/CompilerMessageView.cs 2004-12-07 20:38:11 UTC (rev 2059)
@@ -70,13 +70,10 @@
scroller.ShadowType = ShadowType.In;
scroller.Add (textEditorControl);
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
- IProjectService projectService = (IProjectService) ServiceManager.GetService (typeof(IProjectService));
-
- taskService.CompilerOutputChanged += new EventHandler(SetOutput);
- projectService.StartBuild += new EventHandler (SelectMessageView);
- projectService.CombineClosed += new CombineEventHandler (OnCombineClosed);
- projectService.CombineOpened += new CombineEventHandler (OnCombineOpen);
+ Runtime.TaskService.CompilerOutputChanged += (EventHandler) Runtime.DispatchService.GuiDispatch (new EventHandler(SetOutput));
+ Runtime.ProjectService.StartBuild += (EventHandler) Runtime.DispatchService.GuiDispatch (new EventHandler (SelectMessageView));
+ Runtime.ProjectService.CombineClosed += (CombineEventHandler) Runtime.DispatchService.GuiDispatch (new CombineEventHandler (OnCombineClosed));
+ Runtime.ProjectService.CombineOpened += (CombineEventHandler) Runtime.DispatchService.GuiDispatch (new CombineEventHandler (OnCombineOpen));
}
void OnCombineOpen(object sender, CombineEventArgs e)
@@ -91,12 +88,10 @@
void SelectMessageView(object sender, EventArgs e)
{
- PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
-
if (WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(this)) {
WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this);
} else {
- if ((bool)propertyService.GetProperty("SharpDevelop.ShowOutputWindowAtBuild", true)) {
+ if ((bool)Runtime.Properties.GetProperty("SharpDevelop.ShowOutputWindowAtBuild", true)) {
WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(this);
WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this);
}
@@ -106,9 +101,8 @@
void SetOutput2()
{
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
try {
- buffer.Text = taskService.CompilerOutput;
+ buffer.Text = Runtime.TaskService.CompilerOutput;
UpdateTextArea();
} catch (Exception) {}
@@ -130,8 +124,7 @@
SetOutput2();
outputText = null;
} else {
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
- outputText = taskService.CompilerOutput;
+ outputText = Runtime.TaskService.CompilerOutput;
UpdateTextArea();
}
}
Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceInFilesManager.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceInFilesManager.cs 2004-12-07 20:36:29 UTC (rev 2058)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Search/SearchReplaceInFilesManager.cs 2004-12-07 20:38:11 UTC (rev 2059)
@@ -30,8 +30,6 @@
static IFind find = new DefaultFind();
static SearchOptions searchOptions = new SearchOptions("SharpDevelop.SearchAndReplace.SearchAndReplaceInFilesProperties");
- static PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
-
static string currentFileName = String.Empty;
static SourceEditorBuffer currentDocument = null;
static DateTime timer;
@@ -68,8 +66,6 @@
/// </remarks>
static void DisplaySearchResult(ISearchResult result)
{
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
-
// check if the current document is up to date
if (currentFileName != result.FileName || currentDocument == null) {
// if not, create new document
@@ -80,7 +76,7 @@
catch
{
string msg = string.Format (GettextCatalog.GetString ("Match at offset {0}"), result.Offset);
- taskService.AddTask (new Task(result.FileName, msg, -1, -1));
+ Runtime.TaskService.AddTask (new Task(result.FileName, msg, -1, -1));
return;
}
}
@@ -92,20 +88,14 @@
TextIter start_line = resultIter, end_line = resultIter;
start_line.LineOffset = 0;
end_line.ForwardToLineEnd ();
- taskService.AddTask (new Task(result.FileName, currentDocument.GetText(start_line.Offset, end_line.Offset - start_line.Offset), resultIter.LineOffset, lineNumber));
+ Runtime.TaskService.AddTask (new Task (result.FileName, currentDocument.GetText(start_line.Offset, end_line.Offset - start_line.Offset), resultIter.LineOffset, lineNumber));
}
- static void DisplaySearchResultCallback (object data)
- {
- DisplaySearchResult ((ISearchResult) data);
- }
-
static bool InitializeSearchInFiles()
{
Debug.Assert(searchOptions != null);
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
- taskService.ClearTasks();
+ Runtime.TaskService.ClearTasks();
InitializeDocumentIterator(null, null);
InitializeSearchStrategy(null, null);
@@ -120,7 +110,6 @@
static void FinishSearchInFiles ()
{
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
string msg;
if (searchError != null)
msg = string.Format (GettextCatalog.GetString ("The search could not be finished: {0}"), searchError);
@@ -129,28 +118,21 @@
else
msg = string.Format (GettextCatalog.GetString ("Search completed. {0} matches found in {1} files."), find.MatchCount, find.SearchedFileCount);
- taskService.AddTask (new Task(null, msg, -1, -1));
-
- // present the taskview to show the search results
- OpenTaskView taskView = WorkbenchSingleton.Workbench.GetPad(typeof(OpenTaskView)) as OpenTaskView;
- if (taskView != null) {
- taskView.BringToFront();
- }
-
+ Runtime.TaskService.AddTask (new Task(null, msg, -1, -1));
+ Runtime.TaskService.ShowTasks ();
+
Console.WriteLine ("Search time: " + (DateTime.Now - timer).TotalSeconds);
searching = false;
// tell the user search is done.
-/* MessageService MessageService = (MessageService)ServiceManager.GetService (typeof (MessageService));
- MessageService.ShowMessage (GettextCatalog.GetString ("Search completed"));
+/* Runtime.MessageService.ShowMessage (GettextCatalog.GetString ("Search completed"));
Console.WriteLine ("Done");
*/ }
public static void ReplaceAll()
{
if (searching) {
- MessageService MessageService = (MessageService)ServiceManager.GetService (typeof (MessageService));
- if (!MessageService.AskQuestion (GettextCatalog.GetString ("There is a search already in progress. Do you want to cancel it?")))
+ if (!Runtime.MessageService.AskQuestion (GettextCatalog.GetString ("There is a search already in progress. Do you want to cancel it?")))
return;
CancelSearch ();
}
@@ -159,18 +141,15 @@
return;
}
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
string msg = string.Format (GettextCatalog.GetString ("Replacing '{0}' in {1}."), searchOptions.SearchPattern, searchOptions.SearchDirectory);
- taskService.AddTask (new Task(null, msg, -1, -1));
+ Runtime.TaskService.AddTask (new Task(null, msg, -1, -1));
timer = DateTime.Now;
- DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
- dispatcher.BackgroundDispatch (new MessageHandler(ReplaceAllThread));
+ Runtime.DispatchService.BackgroundDispatch (new MessageHandler(ReplaceAllThread));
}
public static void ReplaceAllThread()
{
- DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
searching = true;
searchError = null;
@@ -184,8 +163,7 @@
}
find.Replace(result, result.TransformReplacePattern(SearchOptions.ReplacePattern));
-
- dispatcher.GuiDispatch (new StatefulMessageHandler (DisplaySearchResultCallback), result);
+ DisplaySearchResult (result);
}
catch (Exception ex)
{
@@ -194,14 +172,13 @@
}
}
- dispatcher.GuiDispatch (new MessageHandler (FinishSearchInFiles));
+ FinishSearchInFiles ();
}
public static void FindAll()
{
if (searching) {
- MessageService MessageService = (MessageService)ServiceManager.GetService (typeof (MessageService));
- if (!MessageService.AskQuestion (GettextCatalog.GetString ("There is a search already in progress. Do you want to cancel it?")))
+ if (!Runtime.MessageService.AskQuestion (GettextCatalog.GetString ("There is a search already in progress. Do you want to cancel it?")))
return;
CancelSearch ();
}
@@ -210,18 +187,15 @@
return;
}
- TaskService taskService = (TaskService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(TaskService));
string msg = string.Format (GettextCatalog.GetString ("Looking for '{0}' in {1}."), searchOptions.SearchPattern, searchOptions.SearchDirectory);
- taskService.AddTask (new Task(null, msg, -1, -1));
+ Runtime.TaskService.AddTask (new Task(null, msg, -1, -1));
timer = DateTime.Now;
- DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
- dispatcher.BackgroundDispatch (new MessageHandler(FindAllThread));
+ Runtime.DispatchService.BackgroundDispatch (new MessageHandler(FindAllThread));
}
public static void FindAllThread()
{
- DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
searching = true;
searchError = null;
@@ -233,8 +207,8 @@
if (result == null) {
break;
}
-
- dispatcher.GuiDispatch (new StatefulMessageHandler (DisplaySearchResultCallback), result);
+
+ DisplaySearchResult (result);
}
catch (Exception ex)
{
@@ -243,7 +217,7 @@
}
}
- dispatcher.GuiDispatch (new MessageHandler (FinishSearchInFiles));
+ FinishSearchInFiles ();
}
static void CancelSearch ()
More information about the Monodevelop-patches-list
mailing list