Browse Source

Fixed SD2-525: Changing the output Window font changes the text editor window font.

Fixed SD2-526: Output Window Word Wrap does nothing.
Improved performance of output window and error list when there are many errors/warnings. (previously 3000 warnings caused the SharpDevelop to freeze for 30 seconds and then crash with an OutOfMemoryException, consuming 2 GB of memory; now the speed is much better and the memory usage is fixed)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@875 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
ea52117d70
  1. 5
      data/options/SharpDevelopProperties.xml
  2. 7
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 25
      src/Main/Base/Project/Src/Commands/BuildCommands.cs
  4. 3
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs
  5. 126
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs
  6. 22
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/MessageViewCategory.cs
  7. 18
      src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs
  8. 28
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs
  9. 20
      src/Main/Base/Project/Src/Services/Tasks/TaskService.cs

5
data/options/SharpDevelopProperties.xml

@ -1,3 +1,8 @@
<SharpDevelopProperties> <SharpDevelopProperties>
<ShowTipsAtStartup value="True" /> <ShowTipsAtStartup value="True" />
<Properties name="WorkbenchMemento">
<bounds value="10,10,780,560" />
<windowstate value="Maximized" />
<defaultstate value="Maximized" />
</Properties>
</SharpDevelopProperties> </SharpDevelopProperties>

7
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -13,6 +13,13 @@
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>Resources\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>Resources\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Optimize>False</Optimize> <Optimize>False</Optimize>

25
src/Main/Base/Project/Src/Commands/BuildCommands.cs

@ -20,7 +20,9 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public static void BeforeBuild() public static void BeforeBuild()
{ {
TaskService.BuildMessageViewCategory.ClearText(); TaskService.BuildMessageViewCategory.ClearText();
TaskService.InUpdate = true;
TaskService.ClearExceptCommentTasks(); TaskService.ClearExceptCommentTasks();
TaskService.InUpdate = false;
ICSharpCode.SharpDevelop.Commands.SaveAllFiles.SaveAll(); ICSharpCode.SharpDevelop.Commands.SaveAllFiles.SaveAll();
} }
@ -32,6 +34,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
if (results != null) { if (results != null) {
LastErrorCount = 0; LastErrorCount = 0;
LastWarningCount = 0; LastWarningCount = 0;
TaskService.InUpdate = true;
foreach (CompilerError error in results.Errors) { foreach (CompilerError error in results.Errors) {
TaskService.Add(new Task(error)); TaskService.Add(new Task(error));
if (error.IsWarning) if (error.IsWarning)
@ -39,6 +42,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
else else
LastErrorCount++; LastErrorCount++;
} }
TaskService.InUpdate = false;
if (results.Errors.Count > 0) { if (results.Errors.Count > 0) {
WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
} }
@ -112,26 +116,13 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public class BuildProject : AbstractMenuCommand public class BuildProject : AbstractMenuCommand
{ {
public static void ShowResults(CompilerResults results)
{
if (results != null) {
foreach (CompilerError error in results.Errors) {
TaskService.Add(new Task(error));
}
if (results.Errors.Count > 0) {
WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
}
}
}
public override void Run() public override void Run()
{ {
Build.BeforeBuild(); Build.BeforeBuild();
if (ProjectService.OpenSolution == null) { if (ProjectService.OpenSolution == null) {
Build.AddNoSingleFileCompilationError(); Build.AddNoSingleFileCompilationError();
} else { } else {
BuildProject.ShowResults(ProjectService.CurrentProject.Build()); Build.ShowResults(ProjectService.CurrentProject.Build());
} }
Build.AfterBuild(); Build.AfterBuild();
} }
@ -145,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
if (ProjectService.OpenSolution == null) { if (ProjectService.OpenSolution == null) {
Build.AddNoSingleFileCompilationError(); Build.AddNoSingleFileCompilationError();
} else { } else {
BuildProject.ShowResults(ProjectService.CurrentProject.Rebuild()); Build.ShowResults(ProjectService.CurrentProject.Rebuild());
} }
Build.AfterBuild(); Build.AfterBuild();
} }
@ -159,7 +150,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
if (ProjectService.OpenSolution == null) { if (ProjectService.OpenSolution == null) {
Build.AddNoSingleFileCompilationError(); Build.AddNoSingleFileCompilationError();
} else { } else {
BuildProject.ShowResults(ProjectService.CurrentProject.Clean()); Build.ShowResults(ProjectService.CurrentProject.Clean());
} }
} }
} }
@ -172,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
if (ProjectService.OpenSolution == null) { if (ProjectService.OpenSolution == null) {
Build.AddNoSingleFileCompilationError(); Build.AddNoSingleFileCompilationError();
} else { } else {
BuildProject.ShowResults(ProjectService.CurrentProject.Publish()); Build.ShowResults(ProjectService.CurrentProject.Publish());
} }
} }
} }

3
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs

@ -51,8 +51,5 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
PropertyService.Set(OutputWindowsProperty, properties); PropertyService.Set(OutputWindowsProperty, properties);
return true; return true;
} }
} }
} }

126
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs

@ -37,8 +37,10 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
TextEditorControl textEditorControl = new TextEditorControl(); //TextEditorControl textEditorControl = new TextEditorControl();
Panel myPanel = new Panel(); RichTextBox textEditorControl = new RichTextBox();
Panel myPanel = new Panel();
ToolStrip toolStrip;
List<MessageViewCategory> messageCategories = new List<MessageViewCategory>(); List<MessageViewCategory> messageCategories = new List<MessageViewCategory>();
@ -51,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (selectedCategory != value) { if (selectedCategory != value) {
selectedCategory = value; selectedCategory = value;
textEditorControl.Text = (value < 0) ? "" : messageCategories[value].Text; textEditorControl.Text = (value < 0) ? "" : messageCategories[value].Text;
textEditorControl.Refresh(); //textEditorControl.Refresh();
OnSelectedCategoryIndexChanged(EventArgs.Empty); OnSelectedCategoryIndexChanged(EventArgs.Empty);
} }
} }
@ -76,7 +78,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
// The compiler message view properties. // The compiler message view properties.
Properties properties = null; Properties properties = null;
public List<MessageViewCategory> MessageCategories { public List<MessageViewCategory> MessageCategories {
get { get {
@ -97,8 +99,10 @@ namespace ICSharpCode.SharpDevelop.Gui
AddCategory(TaskService.BuildMessageViewCategory); AddCategory(TaskService.BuildMessageViewCategory);
myPanel.SuspendLayout(); myPanel.SuspendLayout();
textEditorControl.Dock = DockStyle.Fill; textEditorControl.Dock = DockStyle.Fill;
textEditorControl.ShowLineNumbers = false; textEditorControl.BorderStyle = BorderStyle.FixedSingle;
textEditorControl.BackColor = SystemColors.Window;
/*textEditorControl.ShowLineNumbers = false;
textEditorControl.ShowInvalidLines = false; textEditorControl.ShowInvalidLines = false;
textEditorControl.EnableFolding = false; textEditorControl.EnableFolding = false;
textEditorControl.IsIconBarVisible = false; textEditorControl.IsIconBarVisible = false;
@ -107,18 +111,20 @@ namespace ICSharpCode.SharpDevelop.Gui
textEditorControl.ShowVRuler = false; textEditorControl.ShowVRuler = false;
textEditorControl.ShowSpaces = false; textEditorControl.ShowSpaces = false;
textEditorControl.ShowTabs = false; textEditorControl.ShowTabs = false;
textEditorControl.ShowEOLMarkers = false; textEditorControl.ShowEOLMarkers = false;*/
textEditorControl.ReadOnly = true;
textEditorControl.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/CompilerMessageView/ContextMenu"); textEditorControl.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/CompilerMessageView/ContextMenu");
properties = (Properties)PropertyService.Get(OutputWindowOptionsPanel.OutputWindowsProperty, new Properties()); properties = (Properties)PropertyService.Get(OutputWindowOptionsPanel.OutputWindowsProperty, new Properties());
textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString()); textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString());
properties.PropertyChanged += new PropertyChangedEventHandler(PropertyChanged); properties.PropertyChanged += new PropertyChangedEventHandler(PropertyChanged);
textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick; //textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick;
textEditorControl.DoubleClick += TextEditorControlDoubleClick;
ToolStrip toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/CompilerMessageView/Toolbar"); toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/CompilerMessageView/Toolbar");
toolStrip.Stretch = true; toolStrip.Stretch = true;
toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
@ -131,13 +137,13 @@ namespace ICSharpCode.SharpDevelop.Gui
void SetWordWrap() void SetWordWrap()
{ {
// bool wordWrap = properties.Get("WordWrap", true); bool wordWrap = this.WordWrap;
// textEditorControl.WordWrap = wordWrap; textEditorControl.WordWrap = wordWrap;
// if (wordWrap) { if (wordWrap) {
// textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedBoth; textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedBoth;
// } else { } else {
// textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedVertical; textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
// } }
} }
public override void RedrawContent() public override void RedrawContent()
@ -167,7 +173,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
if (messageCategories[SelectedCategoryIndex] == category) { if (messageCategories[SelectedCategoryIndex] == category) {
textEditorControl.Text = String.Empty; textEditorControl.Text = String.Empty;
textEditorControl.Refresh(); //textEditorControl.Refresh();
} }
} }
@ -176,25 +182,67 @@ namespace ICSharpCode.SharpDevelop.Gui
WorkbenchSingleton.SafeThreadAsyncCall(this, "SetText", (MessageViewCategory)sender, e.Text); WorkbenchSingleton.SafeThreadAsyncCall(this, "SetText", (MessageViewCategory)sender, e.Text);
} }
object appendCallLock = new object();
volatile int pendingAppendCalls = 0;
void CategoryTextAppended(object sender, TextEventArgs e) void CategoryTextAppended(object sender, TextEventArgs e)
{ {
WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendText", (MessageViewCategory)sender, ((MessageViewCategory)sender).Text, e.Text); lock (appendCallLock) {
pendingAppendCalls += 1;
if (pendingAppendCalls < 5) {
WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendText", sender, ((MessageViewCategory)sender).Text, e.Text);
} else if (pendingAppendCalls == 5) {
WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendTextCombined", sender);
}
}
}
const int WM_SETREDRAW = 0x00B;
[System.Security.SuppressUnmanagedCodeSecurityAttribute]
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam);
void SetUpdate(bool update)
{
SendMessage(textEditorControl.Handle, WM_SETREDRAW, update ? 1 : 0, IntPtr.Zero);
}
void AppendTextCombined(MessageViewCategory category)
{
Application.DoEvents();
Thread.Sleep(50);
Application.DoEvents();
lock (appendCallLock) {
SetUpdate(false);
SetText(category, category.Text);
SetUpdate(true);
textEditorControl.SelectionStart = textEditorControl.TextLength;
LoggingService.Debug("Replaced " + pendingAppendCalls + " appends with one set call");
pendingAppendCalls = 0;
}
} }
void AppendText(MessageViewCategory category, string fullText, string text) void AppendText(MessageViewCategory category, string fullText, string text)
{ {
lock (appendCallLock) {
if (pendingAppendCalls >= 5) {
return;
}
}
if (messageCategories[SelectedCategoryIndex] != category) { if (messageCategories[SelectedCategoryIndex] != category) {
SelectCategory(category.Category, fullText); SelectCategory(category.Category, fullText);
return; return;
} }
if (text != null) { if (text != null) {
text = StringParser.Parse(text); text = StringParser.Parse(text);
textEditorControl.Document.ReadOnly = false; textEditorControl.AppendText(text);
textEditorControl.SelectionStart = textEditorControl.TextLength;
/*textEditorControl.Document.ReadOnly = false;
textEditorControl.Document.Insert(textEditorControl.Document.TextLength, text); textEditorControl.Document.Insert(textEditorControl.Document.TextLength, text);
textEditorControl.Document.ReadOnly = true; textEditorControl.Document.ReadOnly = true;
textEditorControl.ActiveTextAreaControl.Caret.Position = new Point(0, textEditorControl.Document.TotalNumberOfLines); textEditorControl.ActiveTextAreaControl.Caret.Position = new Point(0, textEditorControl.Document.TotalNumberOfLines);
textEditorControl.ActiveTextAreaControl.ScrollTo(textEditorControl.Document.TotalNumberOfLines); textEditorControl.ActiveTextAreaControl.ScrollTo(textEditorControl.Document.TotalNumberOfLines);*/
} }
} }
@ -210,7 +258,7 @@ namespace ICSharpCode.SharpDevelop.Gui
text = StringParser.Parse(text); text = StringParser.Parse(text);
} }
textEditorControl.Text = text; textEditorControl.Text = text;
textEditorControl.Refresh(); //textEditorControl.Refresh();
} }
public void SelectCategory(string categoryName) public void SelectCategory(string categoryName)
@ -234,7 +282,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (category.Category == categoryName) { if (category.Category == categoryName) {
selectedCategory = i; selectedCategory = i;
textEditorControl.Text = text; textEditorControl.Text = text;
textEditorControl.Refresh(); //textEditorControl.Refresh();
OnSelectedCategoryIndexChanged(EventArgs.Empty); OnSelectedCategoryIndexChanged(EventArgs.Empty);
break; break;
} }
@ -268,10 +316,20 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
void TextEditorControlDoubleClick(object sender, EventArgs e) void TextEditorControlDoubleClick(object sender, EventArgs e)
{ {
string fullText = textEditorControl.Text;
// Any text? // Any text?
if (textEditorControl.Text.Length > 0) { if (fullText.Length > 0) {
int line = textEditorControl.ActiveTextAreaControl.Caret.Line; //int line = textEditorControl.ActiveTextAreaControl.Caret.Line;
string textLine = TextUtilities.GetLineAsString(textEditorControl.Document, line); //string textLine = TextUtilities.GetLineAsString(textEditorControl.Document, line);
Point clickPos = textEditorControl.PointToClient(Control.MousePosition);
int index = textEditorControl.GetCharIndexFromPosition(clickPos);
int start = index;
// find start of current line
while (--start > 0 && fullText[start - 1] != '\n');
// find end of current line
while (++index < fullText.Length && fullText[index] != '\r');
string textLine = fullText.Substring(start, index - start);
FileLineReference lineReference = OutputTextLineParser.GetFileLineReference(textLine); FileLineReference lineReference = OutputTextLineParser.GetFileLineReference(textLine);
if (lineReference != null) { if (lineReference != null) {
@ -288,6 +346,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
if (e.Key == "WordWrap") { if (e.Key == "WordWrap") {
SetWordWrap(); SetWordWrap();
ToolbarService.UpdateToolbar(toolStrip);
} }
if (e.Key == "DefaultFont") { if (e.Key == "DefaultFont") {
textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString()); textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString());
@ -320,7 +379,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public bool EnableCopy { public bool EnableCopy {
get { get {
return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy; //return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy;
return textEditorControl.SelectionLength > 0;
} }
} }
@ -338,7 +398,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public bool EnableSelectAll { public bool EnableSelectAll {
get { get {
return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll; //return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll;
return textEditorControl.TextLength > 0;
} }
} }
@ -348,7 +409,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public void Copy() public void Copy()
{ {
textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null); //textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null);
textEditorControl.Copy();
} }
public void Paste() public void Paste()
@ -361,9 +423,9 @@ namespace ICSharpCode.SharpDevelop.Gui
public void SelectAll() public void SelectAll()
{ {
textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null); //textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null);
textEditorControl.SelectAll();
} }
#endregion #endregion
} }
} }

22
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/MessageViewCategory.cs

@ -20,7 +20,7 @@ using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
{ {
/// <summary> /// <summary>
/// This class represents a category with its text content used in the /// This class represents a category with its text content used in the
/// output pad (CompilerMessageView). /// output pad (CompilerMessageView).
/// </summary> /// </summary>
public class MessageViewCategory public class MessageViewCategory
@ -43,7 +43,9 @@ namespace ICSharpCode.SharpDevelop.Gui
public string Text { public string Text {
get { get {
return textBuilder.ToString(); lock (textBuilder) {
return textBuilder.ToString();
}
} }
} }
@ -59,24 +61,30 @@ namespace ICSharpCode.SharpDevelop.Gui
public void AppendText(string text) public void AppendText(string text)
{ {
textBuilder.Append(text); lock (textBuilder) {
textBuilder.Append(text);
}
OnTextAppended(new TextEventArgs(text)); OnTextAppended(new TextEventArgs(text));
} }
public void SetText(string text) public void SetText(string text)
{ {
textBuilder.Length = 0; lock (textBuilder) {
textBuilder.Append(text); textBuilder.Length = 0;
textBuilder.Append(text);
}
OnTextSet(new TextEventArgs(text)); OnTextSet(new TextEventArgs(text));
} }
public void ClearText() public void ClearText()
{ {
textBuilder.Length = 0; lock (textBuilder) {
textBuilder.Length = 0;
}
OnCleared(EventArgs.Empty); OnCleared(EventArgs.Empty);
} }
protected virtual void OnTextAppended(TextEventArgs e) protected virtual void OnTextAppended(TextEventArgs e)
{ {
if (TextAppended != null) { if (TextAppended != null) {
TextAppended(this, e); TextAppended(this, e);

18
src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs

@ -76,15 +76,19 @@ namespace ICSharpCode.SharpDevelop.Gui
instance = this; instance = this;
RedrawContent(); RedrawContent();
TaskService.Cleared += new EventHandler(TaskServiceCleared); TaskService.Cleared += new EventHandler(TaskServiceCleared);
TaskService.Added += new TaskEventHandler(TaskServiceAdded); TaskService.Added += new TaskEventHandler(TaskServiceAdded);
TaskService.Removed += new TaskEventHandler(TaskServiceRemoved); TaskService.Removed += new TaskEventHandler(TaskServiceRemoved);
TaskService.InUpdateChanged += delegate {
if (!TaskService.InUpdate)
InternalShowResults();
};
ProjectService.EndBuild += ProjectServiceEndBuild; ProjectService.EndBuild += ProjectServiceEndBuild;
ProjectService.SolutionLoaded += OnCombineOpen; ProjectService.SolutionLoaded += OnCombineOpen;
ProjectService.SolutionClosed += OnCombineClosed; ProjectService.SolutionClosed += OnCombineClosed;
taskView.CreateControl(); taskView.CreateControl();
contentPanel.Controls.Add(taskView); contentPanel.Controls.Add(taskView);
@ -125,7 +129,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
UpdateToolstripStatus(); UpdateToolstripStatus();
} }
public CompilerResults CompilerResults = null; public CompilerResults CompilerResults = null;
void AddTask(Task task) void AddTask(Task task)
@ -149,25 +153,31 @@ namespace ICSharpCode.SharpDevelop.Gui
default: default:
return; return;
} }
taskView.AddTask(task); taskView.AddTask(task);
} }
void TaskServiceCleared(object sender, EventArgs e) void TaskServiceCleared(object sender, EventArgs e)
{ {
if (TaskService.InUpdate)
return;
taskView.ClearTasks(); taskView.ClearTasks();
UpdateToolstripStatus(); UpdateToolstripStatus();
} }
void TaskServiceAdded(object sender, TaskEventArgs e) void TaskServiceAdded(object sender, TaskEventArgs e)
{ {
if (TaskService.InUpdate)
return;
AddTask(e.Task); AddTask(e.Task);
UpdateToolstripStatus(); UpdateToolstripStatus();
} }
void TaskServiceRemoved(object sender, TaskEventArgs e) void TaskServiceRemoved(object sender, TaskEventArgs e)
{ {
if (TaskService.InUpdate)
return;
taskView.RemoveTask(e.Task); taskView.RemoveTask(e.Task);
UpdateToolstripStatus(); UpdateToolstripStatus();
} }

28
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs

@ -5,7 +5,7 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
// much of TaskView's code has been refactored from // much of TaskView's code has been refactored from
// TaskList.cs (formerly OpenTaskView.cs) & ErrorList.cs // TaskList.cs (formerly OpenTaskView.cs) & ErrorList.cs
using System; using System;
@ -120,7 +120,7 @@ namespace ICSharpCode.Core
} }
protected override void OnColumnClick(ColumnClickEventArgs e) protected override void OnColumnClick(ColumnClickEventArgs e)
{ {
SortBy(e.Column); SortBy(e.Column);
base.OnColumnClick(e); base.OnColumnClick(e);
} }
@ -130,7 +130,7 @@ namespace ICSharpCode.Core
System.Diagnostics.Debug.Assert(SelectedTask != null); System.Diagnostics.Debug.Assert(SelectedTask != null);
SelectedTask.JumpToPosition(); SelectedTask.JumpToPosition();
} }
base.OnItemActivate(e); base.OnItemActivate(e);
} }
ListViewItem currentListViewItem = null; ListViewItem currentListViewItem = null;
@ -199,7 +199,7 @@ namespace ICSharpCode.Core
int right = this.Items.Count - 1; int right = this.Items.Count - 1;
while (left <= right) { while (left <= right) {
int m = left + (right - left) / 2; int m = left + (right - left) / 2;
if (this.ListViewItemSorter.Compare(item, this.Items[m]) > 0) { if (this.mySorter.Compare(item, this.Items[m]) > 0) {
left = m + 1; left = m + 1;
} else { } else {
right = m - 1; right = m - 1;
@ -228,7 +228,7 @@ namespace ICSharpCode.Core
Items.RemoveAt(i); Items.RemoveAt(i);
break; break;
} }
} }
} }
public void UpdateResults(System.Collections.Generic.IEnumerable<ICSharpCode.Core.Task> taskSet) public void UpdateResults(System.Collections.Generic.IEnumerable<ICSharpCode.Core.Task> taskSet)
@ -242,7 +242,6 @@ namespace ICSharpCode.Core
this.EndUpdate(); this.EndUpdate();
} }
#endregion #endregion
#region Custom IComparer for sorting TaskView. #region Custom IComparer for sorting TaskView.
@ -251,8 +250,8 @@ namespace ICSharpCode.Core
SortOrder currentSortOrder = SortOrder.Ascending; SortOrder currentSortOrder = SortOrder.Ascending;
/// <summary> /// <summary>
/// Applies the specified sort request by creating, /// Applies the specified sort request by creating,
/// configuring, and installing a /// configuring, and installing a
/// <see cref="TaskViewSorter"/>. /// <see cref="TaskViewSorter"/>.
/// </summary> /// </summary>
private void SortBy(TaskViewCols col) private void SortBy(TaskViewCols col)
@ -273,10 +272,13 @@ namespace ICSharpCode.Core
currentSortOrder = SortOrder.Ascending; currentSortOrder = SortOrder.Ascending;
} }
this.ListViewItemSorter = this.mySorter = new TaskViewSorter(currentSortColumn, currentSortOrder);
new TaskViewSorter(currentSortColumn, currentSortOrder); this.ListViewItemSorter = mySorter;
this.ListViewItemSorter = null;
} }
TaskViewSorter mySorter;
/// <summary> /// <summary>
/// Custom <see cref="IComparer"/> for TaskView. /// Custom <see cref="IComparer"/> for TaskView.
/// </summary> /// </summary>
@ -290,7 +292,7 @@ namespace ICSharpCode.Core
sortCol = col; sortCol = col;
sortOrder = order; sortOrder = order;
} }
protected int CompareLineNumbers(ListViewItem a, ListViewItem b) protected int CompareLineNumbers(ListViewItem a, ListViewItem b)
{ {
return ((Task)a.Tag).Line.CompareTo(((Task)b.Tag).Line); return ((Task)a.Tag).Line.CompareTo(((Task)b.Tag).Line);
@ -315,8 +317,8 @@ namespace ICSharpCode.Core
/// A signed integer indicating the relative sort ranking /// A signed integer indicating the relative sort ranking
/// of item <paramref name="x"/> relative to item /// of item <paramref name="x"/> relative to item
/// <paramref name="y"/>. /// <paramref name="y"/>.
/// Return value greater than zero: x > y. /// Return value greater than zero: x > y.
/// Return value is zero: x == y. /// Return value is zero: x == y.
/// Return value is less than zero: x \< y. /// Return value is less than zero: x \< y.
/// </returns> /// </returns>
public int Compare(object x, object y) { public int Compare(object x, object y) {

20
src/Main/Base/Project/Src/Services/Tasks/TaskService.cs

@ -228,6 +228,24 @@ namespace ICSharpCode.Core
public static event TaskEventHandler Added; public static event TaskEventHandler Added;
public static event TaskEventHandler Removed; public static event TaskEventHandler Removed;
public static event EventHandler Cleared; public static event EventHandler Cleared;
static bool inUpdate;
public static bool InUpdate {
get {
return inUpdate;
}
set {
if (inUpdate != value) {
inUpdate = value;
if (InUpdateChanged != null) {
InUpdateChanged(null, EventArgs.Empty);
}
}
}
}
public static event EventHandler InUpdateChanged;
} }
} }

Loading…
Cancel
Save