Skip to content

Commit c18c755

Browse files
committed
Allow file format exclude list to be specified when creating template
When the Create Template menu is selected the template information dialog that is displayed has a text box where the file exclusion list can be entered. This information will be added to the template.json file.
1 parent 787dd87 commit c18c755

File tree

7 files changed

+57
-9
lines changed

7 files changed

+57
-9
lines changed

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating.Gui/TemplateInformationDialog.UI.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ partial class TemplateInformationDialog : Dialog
4343
TemplateTextEntry displayNameTextEntry;
4444
TemplateTextEntry categoryTextEntry;
4545
TemplateTextEntry descriptionTextEntry;
46+
TemplateTextEntry fileFormatExcludeTextEntry;
4647
Button selectCategoryButton;
4748
List<Label> allLabels = new List<Label> ();
4849

@@ -83,6 +84,12 @@ void Build ()
8384
GettextCatalog.GetString ("Defines where the project template will be displayed in the New Project dialog."));
8485
allLabels.Add (categoryTextEntry.Label);
8586

87+
fileFormatExcludeTextEntry = CreateTemplateTextEntry (
88+
mainVBox,
89+
GettextCatalog.GetString ("File Format Exclude:"),
90+
GettextCatalog.GetString ("A semi-colon separated list of files (e.g. 'info.plist;*.min.js') which will not be formatted when creating the project."));
91+
allLabels.Add (fileFormatExcludeTextEntry.Label);
92+
8693
selectCategoryButton = new Button ();
8794
selectCategoryButton.Label = "\u2026";
8895
categoryTextEntry.HBox.PackStart (selectCategoryButton);

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating.Gui/TemplateInformationDialog.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public TemplateInformationDialog (TemplateInformation viewModel)
4848
shortNameTextEntry.TextEntry.Text = viewModel.ShortName;
4949
categoryTextEntry.TextEntry.Text = viewModel.Category;
5050
descriptionTextEntry.TextEntry.Text = viewModel.Description;
51+
fileFormatExcludeTextEntry.TextEntry.Text = viewModel.FileFormatExclude;
5152

5253
authorTextEntry.TextEntry.Changed += AuthorTextEntryChanged;
5354
defaultProjectNameTextEntry.TextEntry.Changed += DefaultProjectNameTextEntryChanged;
@@ -57,6 +58,7 @@ public TemplateInformationDialog (TemplateInformation viewModel)
5758
shortNameTextEntry.TextEntry.Changed += ShortNameTextEntryChanged;
5859
categoryTextEntry.TextEntry.Changed += CategoryTextEntryChanged;
5960
descriptionTextEntry.TextEntry.Changed += DescriptionTextChanged;
61+
fileFormatExcludeTextEntry.TextEntry.Changed += FileFormatExcludeTextChanged ;
6062

6163
selectCategoryButton.Clicked += SelectCategoryButtonClicked;
6264
}
@@ -107,6 +109,11 @@ void DescriptionTextChanged (object sender, EventArgs e)
107109
viewModel.Description = descriptionTextEntry.TextEntry.Text;
108110
}
109111

112+
void FileFormatExcludeTextChanged (object sender, EventArgs e)
113+
{
114+
viewModel.FileFormatExclude = fileFormatExcludeTextEntry.TextEntry.Text;
115+
}
116+
110117
void SelectCategoryButtonClicked (object sender, EventArgs e)
111118
{
112119
using (var dialog = new TemplateCategoriesDialog ()) {

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating/FileFormattingExcludeTagProvider.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,28 @@ namespace MonoDevelop.Templating
2828
{
2929
static class FileFormattingExcludeTagProvider
3030
{
31+
public static readonly string MonoDevelopFileFormatExcludeTagName = "md-file-format-exclude";
32+
public static readonly string VSMacFileFormatExcludeTagName = "vsmac-file-format-exclude";
33+
3134
public static readonly string[] TagNames = new string [] {
32-
"md-file-format-exclude",
33-
"vsmac-file-format-exclude"
35+
MonoDevelopFileFormatExcludeTagName,
36+
VSMacFileFormatExcludeTagName
3437
};
38+
39+
public static readonly string DefaultTagName;
40+
41+
static FileFormattingExcludeTagProvider ()
42+
{
43+
DefaultTagName = GetDefaultTagName ();
44+
}
45+
46+
static string GetDefaultTagName ()
47+
{
48+
if (TemplatingServices.IsVisualStudio ()) {
49+
return VSMacFileFormatExcludeTagName;
50+
}
51+
52+
return MonoDevelopFileFormatExcludeTagName;
53+
}
3554
}
3655
}

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating/TemplateCategoryTagNameProvider.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
// THE SOFTWARE.
2626

27-
using System;
28-
using MonoDevelop.Core;
29-
3027
namespace MonoDevelop.Templating
3128
{
3229
class TemplateCategoryTagNameProvider
@@ -48,10 +45,8 @@ static TemplateCategoryTagNameProvider ()
4845

4946
static string GetDefaultCategoryTagName ()
5047
{
51-
if (BrandingService.ApplicationName != null) {
52-
if (BrandingService.ApplicationName.StartsWith ("Visual Studio", StringComparison.OrdinalIgnoreCase)) {
53-
return VSMacCategoryTagName;
54-
}
48+
if (TemplatingServices.IsVisualStudio ()) {
49+
return VSMacCategoryTagName;
5550
}
5651

5752
return MonoDevelopCategoryTagName;

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating/TemplateInformation.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public TemplateInformation (FilePath baseDirectory, IEnumerable<DotNetProject> p
7070
public string CategoryTagName { get; set; }
7171
public string Category { get; set; }
7272
public string Description { get; set; }
73+
public string FileFormatExclude { get; set; }
74+
public string FileFormatExcludeTagName { get; set; }
7375
public string[] ProjectFilePrimaryOutputs { get; set; }
7476
public string[] ProjectGuids { get; set; }
7577

@@ -81,6 +83,8 @@ void GenerateDefaults ()
8183
Language = project.LanguageName;
8284
ShortName = project.Name;
8385
Description = string.Empty;
86+
FileFormatExclude = string.Empty;
87+
FileFormatExcludeTagName = FileFormattingExcludeTagProvider.DefaultTagName;
8488

8589
Category = "other/net/general";
8690
CategoryTagName = TemplateCategoryTagNameProvider.DefaultCategoryTagName;

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating/TemplateJsonFileCreator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ static string AddProjectInfo (TemplateInformation template, string json)
8484
outputs.Add (pathProperty);
8585
}
8686

87+
if (!string.IsNullOrEmpty (template.FileFormatExclude)) {
88+
var tags = jsonObject ["tags"];
89+
tags [template.FileFormatExcludeTagName] = template.FileFormatExclude;
90+
}
91+
8792
return ToString (jsonObject);
8893
}
8994

src/MonoDevelop.TemplateCreator/MonoDevelop.Templating/TemplatingServices.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ public static void LogInfo (string message)
125125
TemplatingOutputPad.WriteText (message);
126126
}
127127

128+
public static bool IsVisualStudio ()
129+
{
130+
if (BrandingService.ApplicationName != null) {
131+
if (BrandingService.ApplicationName.StartsWith ("Visual Studio", StringComparison.OrdinalIgnoreCase)) {
132+
return true;
133+
}
134+
}
135+
136+
return false;
137+
}
138+
128139
static IEnumerable<TemplateCategoryViewModel> AppendCustomCategories (this IEnumerable<TemplateCategoryViewModel> categories)
129140
{
130141
if (!TemplateCreatorAddinXmlFile.IsModified) {

0 commit comments

Comments
 (0)