|
|
|
@ -2,7 +2,9 @@
@@ -2,7 +2,9 @@
|
|
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using ICSharpCode.Core; |
|
|
|
|
using ICSharpCode.NRefactory.Utils; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.SharpDevelop.Templates |
|
|
|
|
{ |
|
|
|
@ -12,6 +14,10 @@ namespace ICSharpCode.SharpDevelop.Templates
@@ -12,6 +14,10 @@ namespace ICSharpCode.SharpDevelop.Templates
|
|
|
|
|
/// <attribute name="displayName" use="optional">
|
|
|
|
|
/// The display name to use. If not specified, the codon id is used instead.
|
|
|
|
|
/// </attribute>
|
|
|
|
|
/// <attribute name="sortOrder" use="optional">
|
|
|
|
|
/// An integer that is used for sorting; categories with higher values are listed first.
|
|
|
|
|
/// For equal values, the categories will be sorted by the display name.
|
|
|
|
|
/// </attribute>
|
|
|
|
|
/// <children childTypes="TemplateBase">
|
|
|
|
|
/// The <TemplateCategory> may have templates and subcategories as children.
|
|
|
|
|
/// </children>
|
|
|
|
@ -31,18 +37,26 @@ namespace ICSharpCode.SharpDevelop.Templates
@@ -31,18 +37,26 @@ namespace ICSharpCode.SharpDevelop.Templates
|
|
|
|
|
if (args.Codon.Properties.Contains("icon")) |
|
|
|
|
icon = SD.ResourceService.GetImage(args.Codon.Properties["icon"]); |
|
|
|
|
TemplateCategory category = new TemplateCategory( |
|
|
|
|
args.Codon.Id, |
|
|
|
|
args.Codon.Id, |
|
|
|
|
args.Codon.Properties["displayName"], |
|
|
|
|
args.Codon.Properties["description"], |
|
|
|
|
icon |
|
|
|
|
); |
|
|
|
|
int sortOrder; |
|
|
|
|
if (int.TryParse(args.Codon.Properties["sortOrder"], out sortOrder)) |
|
|
|
|
category.SortOrder = sortOrder; |
|
|
|
|
LoadSubItems(category, args); |
|
|
|
|
return category; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void LoadSubItems(TemplateCategory category, BuildItemArgs args) |
|
|
|
|
{ |
|
|
|
|
foreach (TemplateBase item in args.BuildSubItems<TemplateBase>()) { |
|
|
|
|
if (item is TemplateCategory) |
|
|
|
|
category.Subcategories.Add((TemplateCategory)item); |
|
|
|
|
else |
|
|
|
|
category.Templates.Add(item); |
|
|
|
|
} |
|
|
|
|
return category; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|