Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 032f01c

Browse files
committed
Add IOutputPad.GetOrCreateCategory()
1 parent 37cf805 commit 032f01c

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ IOutputCategory IOutputPad.CreateCategory(string displayName)
5656
return cat;
5757
}
5858

59+
IOutputCategory IOutputPad.GetOrCreateCategory(string displayName)
60+
{
61+
return SD.MainThread.InvokeIfRequired(() => GetOrCreateCategory(displayName));
62+
}
63+
64+
IOutputCategory GetOrCreateCategory(string displayName)
65+
{
66+
foreach (var cat in messageCategories) {
67+
if (cat.DisplayCategory == displayName)
68+
return cat;
69+
}
70+
var newcat = new MessageViewCategory(displayName, displayName);
71+
AddCategory(newcat);
72+
return newcat;
73+
}
74+
5975
void IOutputPad.RemoveCategory(IOutputCategory category)
6076
{
6177
throw new NotImplementedException();

src/Main/Base/Project/Workbench/IOutputPad.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ public interface IOutputPad
3838
/// <summary>
3939
/// Creates a new output category.
4040
/// </summary>
41+
/// <param name="displayName">The title of the category. This is parsed using StringParser and shown to the user.</param>
4142
IOutputCategory CreateCategory(string displayName);
4243

44+
/// <summary>
45+
/// Gets an output category, or creates a new output category if no category with the given
46+
/// title already exists.
47+
/// </summary>
48+
/// <param name="displayName">The title of the category. This is parsed using StringParser and shown to the user.</param>
49+
IOutputCategory GetOrCreateCategory(string displayName);
50+
4351
/// <summary>
4452
/// Removes an existing output category.
4553
/// </summary>
@@ -65,6 +73,8 @@ public interface IOutputCategory
6573
{
6674
/// <summary>
6775
/// Gets the display name of this category.
76+
/// May contain StringParser-tags ($res) for localization; these will be replaced
77+
/// by the UI showing the display name.
6878
/// </summary>
6979
string DisplayName { get; }
7080

0 commit comments

Comments
 (0)