Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: MonoDevelop.Core.Gui/Makefile.am
- ===================================================================
- --- MonoDevelop.Core.Gui/Makefile.am (revision 153429)
- +++ MonoDevelop.Core.Gui/Makefile.am (working copy)
- -12,8 +12,8 @@
- $(MONO_ADDINS_GUI_LIBS) \
- $(MONO_ADDINS_LIBS) \
- $(MONO_ADDINS_SETUP_LIBS) \
- + $(MONO_CAIRO_LIBS) \
- -r:ICSharpCode.SharpZipLib \
- - -r:Mono.Cairo \
- -r:Mono.Posix \
- -r:System \
- -r:System.Core \
- Index: MonoDevelop.Ide/MonoDevelop.Ide.Templates/AbstractProjectTemplateProvider.cs
- ===================================================================
- --- MonoDevelop.Ide/MonoDevelop.Ide.Templates/AbstractProjectTemplateProvider.cs (revision 0)
- +++ MonoDevelop.Ide/MonoDevelop.Ide.Templates/AbstractProjectTemplateProvider.cs (revision 0)
- -0,0 +1,78 @@
- +//
- +// AbstractProjectTemplateProvider.cs
- +//
- +// Author:
- +// Sanjoy Das <sanjoy@playingwithpointers.com>
- +//
- +// Copyright (c) 2010
- +//
- +// Permission is hereby granted, free of charge, to any person obtaining a copy
- +// of this software and associated documentation files (the "Software"), to deal
- +// in the Software without restriction, including without limitation the rights
- +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- +// copies of the Software, and to permit persons to whom the Software is
- +// furnished to do so, subject to the following conditions:
- +//
- +// The above copyright notice and this permission notice shall be included in
- +// all copies or substantial portions of the Software.
- +//
- +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- +// THE SOFTWARE.
- +using System;
- +using System.Collections.Generic;
- +
- +namespace MonoDevelop.Ide.Templates
- +{
- + /// <summary>
- + /// A project template provider adds another source from which project templates may be fetched. Extend this class
- + /// to add new project providers.
- + /// </summary>
- + public abstract class AbstractProjectTemplateProvider
- + {
- +
- + /* Singleton */
- + private static AbstractProjectTemplateProvider instance = null;
- + private static List<AbstractProjectTemplateProvider> allInstances = null;
- +
- + public static List<AbstractProjectTemplateProvider> AllProviders {
- + get {
- +
- + if (allInstances == null) {
- + allInstances = new List<AbstractProjectTemplateProvider> ();
- + /* Add your providers here. */
- + InternalProjectTemplateProvider.Ping ();
- + allInstances.Add (InternalProjectTemplateProvider.Instance);
- + }
- +
- + return allInstances;
- + }
- + }
- +
- + public abstract String DisplayName {get;}
- +
- + public abstract List <ProjectTemplate> Templates {get;}
- +
- + /// <summary>
- + /// Calls the FetchTemplates method in a non-GUI template if this is true.
- + /// </summary>
- + public abstract bool FetchInAnotherThread {get;}
- +
- + /// <summary>
- + /// Override this to fetch the templates inside this method. In case the method employed is slow (for example
- + /// fetching the templates over a network connection or checking them out of a repository), most of the time
- + /// consuming work must be done inside this method. One must take care to ensure FetchInAnotherThread is true
- + /// in that case as well.
- + /// </summary>
- + /// <returns>
- + /// A <see cref="System.Boolean"/> set to true if the operation was successful and false otherwise.
- + /// </returns>
- + public abstract bool FetchTemplates ();
- +
- + }
- +}
- +
- Index: MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs
- ===================================================================
- --- MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs (revision 153429)
- +++ MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs (working copy)
- -1,24 +1,21 @@
- +//
- // ProjectTemplate.cs
- -//
- +//
- // Author:
- -// Mike Krüger (mkrueger@novell.com)
- -// Lluis Sanchez Gual (lluis@novell.com)
- -// Michael Hutchinson (mhutchinson@novell.com)
- -// Marek Sieradzki (marek.sieradzki@gmail.com)
- -// Viktoria Dudka (viktoriad@remobjects.com)
- -//
- -// Copyright (c) 2009 RemObjects Software
- -//
- +// Sanjoy Das <sanjoy@playingwithpointers.com>
- +//
- +// Copyright (c) 2010
- +//
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- -//
- +//
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- -//
- +//
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- -26,198 +23,85 @@
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- -//
- -//
- -
- using System;
- -using System.IO;
- -using System.Xml;
- -using System.Collections;
- using System.Collections.Generic;
- -using System.Collections.Specialized;
- -using System.Diagnostics;
- -using System.Reflection;
- -using System.CodeDom;
- -using System.CodeDom.Compiler;
- -
- using MonoDevelop.Core;
- -using Mono.Addins;
- -using MonoDevelop.Core.Gui;
- -using MonoDevelop.Ide.Codons;
- using MonoDevelop.Projects;
- using MonoDevelop.Ide.Gui;
- -using MonoDevelop.Projects.CodeGeneration;
- +using System.IO;
- namespace MonoDevelop.Ide.Templates
- {
- - internal class ProjectTemplate
- + public class ProjectTemplate
- {
- - public static List<ProjectTemplate> ProjectTemplates = new List<ProjectTemplate> ();
- -
- - private List<string> actions = new List<string> ();
- -
- +
- + /* Since the class _is_ internal, I guess we need not be so paranoid about setting all the properties to
- + * read-only. */
- +
- private string createdSolutionName;
- - private ProjectCreateInformation createdProjectInformation = null;
- + private MonoDevelop.Projects.ProjectCreateInformation createdProjectInformation = null;
- - private SolutionDescriptor solutionDescriptor = null;
- - public SolutionDescriptor SolutionDescriptor
- - {
- - get { return solutionDescriptor; }
- + internal SolutionDescriptor SolutionDescriptor {
- + get; set;
- }
- - private string languagename;
- - public string LanguageName
- - {
- - get { return languagename; }
- + public string LanguageName {
- + get; set;
- }
- - private string id;
- - public string Id
- - {
- - get { return id; }
- + public string Id {
- + get; set;
- }
- - private string category;
- - public string Category
- - {
- - get { return category; }
- + public string Category {
- + get; set;
- }
- - private string icon;
- - public IconId Icon
- - {
- - get { return icon; }
- + public IconId Icon {
- + get; set;
- }
- - private string description;
- - public string Description
- - {
- - get { return description; }
- + public string Description {
- + get; set;
- }
- - private string name;
- - public string Name
- - {
- - get { return name; }
- + public string Name {
- + get; set;
- }
- - private string originator;
- - public string Originator
- - {
- - get { return originator; }
- + public string Originator {
- + get; set;
- }
- - private string created;
- - public string Created
- - {
- - get { return created; }
- + public string Created {
- + get; set;
- }
- - private string lastModified;
- - public string LastModified
- - {
- - get { return lastModified; }
- + public string LastModified {
- + get; set;
- }
- - private string wizardPath;
- - public string WizardPath
- - {
- - get { return wizardPath; }
- + public string WizardPath {
- + get; set;
- }
- -
- -
- -
- - //constructors
- - static ProjectTemplate ()
- - {
- - AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/ProjectTemplates", OnExtensionChanged);
- +
- + public List<string>listLanguages = new List<string> ();
- +
- + public List<string> ListLanguages {
- + get {
- + return listLanguages;
- + }
- }
- -
- - protected ProjectTemplate (RuntimeAddin addin, string id, ProjectTemplateCodon codon, string overrideLanguage)
- - {
- - XmlDocument xmlDocument = codon.GetTemplate ();
- -
- - XmlElement xmlConfiguration = xmlDocument.DocumentElement ["TemplateConfiguration"];
- -
- - if (xmlConfiguration ["_Category"] != null) {
- - category = addin.Localizer.GetString (xmlConfiguration ["_Category"].InnerText);
- +
- + private List<string> actions = new List<string> ();
- +
- + public List<string> Actions {
- + get {
- + return actions;
- }
- - else
- - throw new InvalidOperationException (string.Format ("_Category missing in file template {0}", codon.Id));
- -
- -
- - if (!string.IsNullOrEmpty (overrideLanguage)) {
- - this.languagename = overrideLanguage;
- - this.category = overrideLanguage + "/" + this.category;
- - }
- - else if (xmlConfiguration ["LanguageName"] != null) {
- -
- - List<string> listLanguages = new List<string> ();
- - foreach (string item in xmlConfiguration ["LanguageName"].InnerText.Split (','))
- - listLanguages.Add (item.Trim ());
- -
- - ExpandLanguageWildcards (listLanguages);
- -
- - this.languagename = listLanguages [0];
- -
- - if (listLanguages.Count > 1 && !String.IsNullOrEmpty (languagename) && !category.StartsWith (languagename + "/"))
- - category = languagename + "/" + category;
- -
- - for (int i = 1; i < listLanguages.Count; i++) {
- - string language = listLanguages[i];
- - try {
- - ProjectTemplates.Add (new ProjectTemplate (addin, id, codon, language));
- - } catch (Exception e) {
- - LoggingService.LogError (GettextCatalog.GetString ("Error loading template {0} for language {1}", codon.Id, language), e);
- - }
- - }
- - }
- -
- - this.id = id;
- -
- - this.originator = xmlDocument.DocumentElement.GetAttribute ("originator");
- - this.created = xmlDocument.DocumentElement.GetAttribute ("created");
- - this.lastModified = xmlDocument.DocumentElement.GetAttribute ("lastModified");
- -
- - if (xmlConfiguration ["Wizard"] != null) {
- - this.wizardPath = xmlConfiguration ["Wizard"].InnerText;
- - }
- -
- - if (xmlConfiguration ["_Name"] != null) {
- - this.name = addin.Localizer.GetString (xmlConfiguration ["_Name"].InnerText);
- - }
- -
- - if (xmlConfiguration ["_Description"] != null) {
- - this.description = addin.Localizer.GetString (xmlConfiguration ["_Description"].InnerText);
- - }
- -
- - if (xmlConfiguration ["Icon"] != null) {
- - this.icon = ImageService.GetStockId (addin, xmlConfiguration ["Icon"].InnerText, Gtk.IconSize.Dnd);
- - }
- -
- - if (xmlDocument.DocumentElement ["Combine"] == null) {
- - throw new InvalidOperationException ("Combine element not found");
- - }
- - else {
- - solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor (xmlDocument.DocumentElement ["Combine"]);
- - }
- -
- - if (xmlDocument.DocumentElement ["Actions"] != null) {
- - foreach (XmlNode xmlElement in xmlDocument.DocumentElement ["Actions"]) {
- - if (xmlElement is XmlElement && xmlElement.Attributes ["filename"] != null)
- - actions.Add (xmlElement.Attributes ["filename"].Value);
- - }
- - }
- }
- - protected ProjectTemplate (RuntimeAddin addin, string id, ProjectTemplateCodon codon)
- - : this (addin, id, codon, null)
- - {
- - }
- -
- - //methods
- - public void OpenCreatedSolution ()
- - {
- + public void OpenCreatedSolution () {
- IAsyncOperation asyncOperation = IdeApp.Workspace.OpenWorkspaceItem (createdSolutionName);
- asyncOperation.WaitForCompleted ();
- -228,9 +112,8 @@
- }
- }
- - public WorkspaceItem CreateWorkspaceItem (ProjectCreateInformation cInfo)
- - {
- - WorkspaceItem workspaceItem = solutionDescriptor.CreateEntry (cInfo, this.languagename);
- + public WorkspaceItem CreateWorkspaceItem (ProjectCreateInformation cInfo) {
- + WorkspaceItem workspaceItem = SolutionDescriptor.CreateEntry (cInfo, this.LanguageName);
- this.createdSolutionName = workspaceItem.FileName;
- this.createdProjectInformation = cInfo;
- -238,70 +121,30 @@
- return workspaceItem;
- }
- - public SolutionEntityItem CreateProject (SolutionItem policyParent, ProjectCreateInformation cInfo)
- - {
- - if (solutionDescriptor.EntryDescriptors.Length == 0)
- + public SolutionEntityItem CreateProject (SolutionItem policyParent, ProjectCreateInformation cInfo) {
- +
- + if (SolutionDescriptor.EntryDescriptors.Length == 0)
- throw new InvalidOperationException ("Solution template doesn't have any project templates");
- - SolutionEntityItem solutionEntryItem = solutionDescriptor.EntryDescriptors [0].CreateItem (cInfo, this.languagename);
- - solutionDescriptor.EntryDescriptors [0].InitializeItem (policyParent, cInfo, this.languagename, solutionEntryItem);
- + SolutionEntityItem solutionEntryItem = SolutionDescriptor.EntryDescriptors [0].CreateItem (cInfo, this.LanguageName);
- + SolutionDescriptor.EntryDescriptors [0].InitializeItem (policyParent, cInfo, this.LanguageName, solutionEntryItem);
- -
- this.createdProjectInformation = cInfo;
- -
- return solutionEntryItem;
- - }
- - static void OnExtensionChanged (object s, ExtensionNodeEventArgs args)
- - {
- - if (args.Change == ExtensionChange.Add) {
- - ProjectTemplateCodon codon = (ProjectTemplateCodon) args.ExtensionNode;
- - try {
- - ProjectTemplates.Add (new ProjectTemplate (codon.Addin, codon.Id, codon, null));
- - }
- - catch (Exception e) {
- - string extId = null, addinId = null;
- - if (codon != null) {
- - if (codon.HasId)
- - extId = codon.Id;
- - if (codon.Addin != null)
- - addinId = codon.Addin.Id;
- - }
- - LoggingService.LogError ("Error loading template id {0} in addin {1}:\n{2}",
- - extId ?? "(null)", addinId ?? "(null)", e.ToString ());
- - }
- - }
- - else {
- - foreach (ProjectTemplate pt in ProjectTemplates) {
- - ProjectTemplateCodon codon = (ProjectTemplateCodon) args.ExtensionNode;
- - if (pt.Id == codon.Id) {
- - ProjectTemplates.Remove (pt);
- - break;
- - }
- - }
- - }
- }
- -
- - void ExpandLanguageWildcards (List<string> list)
- - {
- - //Template can match all CodeDom .NET languages with a "*"
- - if (list.Contains ("*")) {
- - foreach (ILanguageBinding lb in LanguageBindingService.LanguageBindings) {
- - IDotNetLanguageBinding dnlang = lb as IDotNetLanguageBinding;
- - if (dnlang != null && dnlang.GetCodeDomProvider () != null)
- - list.Add (dnlang.Language);
- - list.Remove ("*");
- - }
- - }
- +
- + public bool HasItemFeatures (SolutionFolder parentFolder, ProjectCreateInformation cinfo) {
- + ISolutionItemDescriptor sid = SolutionDescriptor.EntryDescriptors [0];
- + SolutionEntityItem sampleItem = sid.CreateItem (cinfo, LanguageName);
- + return (SolutionItemFeatures.GetFeatures (parentFolder, sampleItem).Length > 0);
- }
- - public bool HasItemFeatures (SolutionFolder parentFolder, ProjectCreateInformation cinfo)
- - {
- - ISolutionItemDescriptor sid = solutionDescriptor.EntryDescriptors [0];
- - SolutionEntityItem sampleItem = sid.CreateItem (cinfo, languagename);
- - return (SolutionItemFeatures.GetFeatures (parentFolder, sampleItem).Length > 0);
- + internal bool IsInitialized {
- + get; set;
- }
- }
- }
- +
- Index: MonoDevelop.Ide/MonoDevelop.Ide.Templates/InternalProjectTemplateProvider.cs
- ===================================================================
- --- MonoDevelop.Ide/MonoDevelop.Ide.Templates/InternalProjectTemplateProvider.cs (revision 0)
- +++ MonoDevelop.Ide/MonoDevelop.Ide.Templates/InternalProjectTemplateProvider.cs (revision 0)
- -0,0 +1,209 @@
- +//
- +// InternalProjectTemplateProvider.cs
- +//
- +// Author:
- +// Sanjoy Das <sanjoy@playingwithpointers.com>
- +//
- +// Copyright (c) 2010
- +//
- +// Permission is hereby granted, free of charge, to any person obtaining a copy
- +// of this software and associated documentation files (the "Software"), to deal
- +// in the Software without restriction, including without limitation the rights
- +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- +// copies of the Software, and to permit persons to whom the Software is
- +// furnished to do so, subject to the following conditions:
- +//
- +// The above copyright notice and this permission notice shall be included in
- +// all copies or substantial portions of the Software.
- +//
- +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- +// THE SOFTWARE.
- +using System;
- +using System.Collections.Generic;
- +using Mono.Addins;
- +using MonoDevelop.Ide.Codons;
- +using System.Xml;
- +using MonoDevelop.Core;
- +using MonoDevelop.Core.Gui;
- +using MonoDevelop.Projects;
- +
- +namespace MonoDevelop.Ide.Templates
- +{
- + /// <summary>
- + /// Provides the default project templates which ship with MonoDevelop
- + /// </summary>
- + public class InternalProjectTemplateProvider : AbstractProjectTemplateProvider
- + {
- + #region implemented abstract members of MonoDevelop.Ide.Templates.AbstractProjectTemplateProvider
- + public override string DisplayName {
- + get {
- + return "Local Templates";
- + }
- + }
- +
- + private List<ProjectTemplate> templates = new List<ProjectTemplate> ();
- + public override System.Collections.Generic.List<ProjectTemplate> Templates {
- + get {
- + return templates;
- + }
- + }
- +
- + public override bool FetchInAnotherThread {
- + get {
- + return false;
- + }
- + }
- +
- + private static InternalProjectTemplateProvider instance = null;
- +
- + public static InternalProjectTemplateProvider Instance {
- + get {
- + return instance;
- + }
- + }
- +
- + private InternalProjectTemplateProvider () {
- + }
- +
- + public static void Ping () {
- + if (instance != null) {
- + throw new Exception ("Cannot create more than one InternalProjectTemplateProvider");
- + }
- + instance = new InternalProjectTemplateProvider ();
- + AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/ProjectTemplates", OnExtensionChanged);
- + }
- +
- + static ProjectTemplate CreateTemplate (RuntimeAddin addin, string id, ProjectTemplateCodon codon,
- + string overrideLanguage) {
- + XmlDocument xmlDocument = codon.GetTemplate ();
- + ProjectTemplate template = new ProjectTemplate();
- +
- + XmlElement xmlConfiguration = xmlDocument.DocumentElement ["TemplateConfiguration"];
- +
- + if (xmlConfiguration ["_Category"] != null) {
- + template.Category = addin.Localizer.GetString (xmlConfiguration ["_Category"].InnerText);
- + }
- + else
- + throw new InvalidOperationException (string.Format ("_Category missing in file template {0}", codon.Id));
- +
- + if (!string.IsNullOrEmpty (overrideLanguage)) {
- + template.LanguageName = overrideLanguage;
- + template.Category = overrideLanguage + "/" + template.Category;
- + } else if (xmlConfiguration ["LanguageName"] != null) {
- +
- + List<string> listLanguages = new List<string> ();
- + foreach (string item in xmlConfiguration ["LanguageName"].InnerText.Split (','))
- + template.ListLanguages.Add (item.Trim ());
- +
- + ExpandLanguageWildcards (template.ListLanguages);
- +
- + template.LanguageName = template.ListLanguages [0];
- +
- + if (template.ListLanguages.Count > 1 && !String.IsNullOrEmpty (template.LanguageName) &&
- + !template.Category.StartsWith (template.LanguageName + "/"))
- + template.Category = template.LanguageName + "/" + template.Category;
- +
- + for (int i = 1; i < template.ListLanguages.Count; i++) {
- + string language = template.ListLanguages[i];
- + try {
- + instance.templates.Add (CreateTemplate (addin, id, codon, language));
- + } catch (Exception e) {
- + LoggingService.LogError (GettextCatalog.GetString ("Error loading template {0} for language {1}", codon.Id, language), e);
- + }
- + }
- + }
- +
- + template.Id = id;
- +
- + template.Originator = xmlDocument.DocumentElement.GetAttribute ("originator");
- + template.Created = xmlDocument.DocumentElement.GetAttribute ("created");
- + template.LastModified = xmlDocument.DocumentElement.GetAttribute ("lastModified");
- +
- + if (xmlConfiguration ["Wizard"] != null) {
- + template.WizardPath = xmlConfiguration ["Wizard"].InnerText;
- + }
- +
- + if (xmlConfiguration ["_Name"] != null) {
- + template.Name = addin.Localizer.GetString (xmlConfiguration ["_Name"].InnerText);
- + }
- +
- + if (xmlConfiguration ["_Description"] != null) {
- + template.Description = addin.Localizer.GetString (xmlConfiguration ["_Description"].InnerText);
- + }
- +
- + if (xmlConfiguration ["Icon"] != null) {
- + template.Icon = ImageService.GetStockId (addin, xmlConfiguration ["Icon"].InnerText, Gtk.IconSize.Dnd);
- + }
- +
- + if (xmlDocument.DocumentElement ["Combine"] == null) {
- + throw new InvalidOperationException ("Combine element not found");
- + }
- + else {
- + template.SolutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor (xmlDocument.DocumentElement ["Combine"]);
- + }
- +
- + if (xmlDocument.DocumentElement ["Actions"] != null) {
- + foreach (XmlNode xmlElement in xmlDocument.DocumentElement ["Actions"]) {
- + if (xmlElement is XmlElement && xmlElement.Attributes ["filename"] != null)
- + template.Actions.Add (xmlElement.Attributes ["filename"].Value);
- + }
- + }
- + return template;
- + }
- +
- + static void OnExtensionChanged (object s, ExtensionNodeEventArgs args) {
- + if (args.Change == ExtensionChange.Add) {
- + ProjectTemplateCodon codon = (ProjectTemplateCodon) args.ExtensionNode;
- + try {
- + lock (Instance) {
- + Instance.Templates.Add (CreateTemplate (codon.Addin, codon.Id, codon, null));
- + }
- + }
- + catch (Exception e) {
- + string extId = null, addinId = null;
- + if (codon != null) {
- + if (codon.HasId)
- + extId = codon.Id;
- + if (codon.Addin != null)
- + addinId = codon.Addin.Id;
- + }
- + LoggingService.LogError ("Error loading template id {0} in addin {1}:\n{2}",
- + extId ?? "(null)", addinId ?? "(null)", e.ToString ());
- + }
- + } else {
- + foreach (ProjectTemplate pt in Instance.Templates) {
- + ProjectTemplateCodon codon = (ProjectTemplateCodon) args.ExtensionNode;
- + if (pt.Id == codon.Id) {
- + Instance.Templates.Remove (pt);
- + break;
- + }
- + }
- + }
- + }
- +
- +
- + public override bool FetchTemplates () {
- + return true;
- + }
- +
- + protected static void ExpandLanguageWildcards (List<string> list) {
- + //Template can match all CodeDom .NET languages with a "*"
- + if (list.Contains ("*")) {
- + foreach (ILanguageBinding lb in LanguageBindingService.LanguageBindings) {
- + IDotNetLanguageBinding dnlang = lb as IDotNetLanguageBinding;
- + if (dnlang != null && dnlang.GetCodeDomProvider () != null)
- + list.Add (dnlang.Language);
- + list.Remove ("*");
- + }
- + }
- + }
- +
- +
- + #endregion
- + }
- +}
- Index: MonoDevelop.Ide/MonoDevelop.Ide.csproj
- ===================================================================
- --- MonoDevelop.Ide/MonoDevelop.Ide.csproj (revision 153429)
- +++ MonoDevelop.Ide/MonoDevelop.Ide.csproj (working copy)
- -44,28 +44,36 @@
- <Reference Include="System.Runtime.Remoting" />
- <Reference Include="Mono.Addins.Setup, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <SpecificVersion>False</SpecificVersion>
- + <Package>mono-addins-setup</Package>
- </Reference>
- <Reference Include="monodoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
- <Reference Include="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <SpecificVersion>False</SpecificVersion>
- + <Package>mono-addins-gui</Package>
- </Reference>
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- + <Package>gtk-sharp-2.0</Package>
- </Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- + <Package>gtk-sharp-2.0</Package>
- </Reference>
- <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- + <Package>gtk-sharp-2.0</Package>
- </Reference>
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- + <Package>glib-sharp-2.0</Package>
- </Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <SpecificVersion>False</SpecificVersion>
- + <Package>gtk-sharp-2.0</Package>
- </Reference>
- <Reference Include="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
- <SpecificVersion>False</SpecificVersion>
- + <Package>mono-addins</Package>
- </Reference>
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- -588,6 +596,8 @@
- <Compile Include="MonoDevelop.Ide.Gui\DockItemToolbarLoader.cs" />
- <Compile Include="MonoDevelop.Ide.Gui.Components\LogView.cs" />
- <Compile Include="MonoDevelop.Ide.Gui\WorkbenchContext.cs" />
- + <Compile Include="MonoDevelop.Ide.Templates\AbstractProjectTemplateProvider.cs" />
- + <Compile Include="MonoDevelop.Ide.Templates\InternalProjectTemplateProvider.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="ChangeLog" />
- Index: MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewProjectDialog.cs
- ===================================================================
- --- MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewProjectDialog.cs (revision 153429)
- +++ MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewProjectDialog.cs (working copy)
- -32,6 +32,7 @@
- using System.Collections;
- using System.IO;
- using System.Text;
- +using System.Threading;
- using Mono.Addins;
- using MonoDevelop.Core;
- -53,7 +54,6 @@
- /// </summary>
- public partial class NewProjectDialog: Gtk.Dialog
- {
- - ArrayList alltemplates = new ArrayList();
- List<Category> categories = new List<Category> ();
- TemplateView templateView;
- -104,22 +104,25 @@
- SelectTemplate (iter, id);
- }
- - ProjectTemplate GetTemplate (string id)
- - {
- - foreach (ProjectTemplate template in ProjectTemplate.ProjectTemplates) {
- - if (template.Id == id)
- - return template;
- + ProjectTemplate GetTemplate (string id) {
- + foreach (AbstractProjectTemplateProvider aptp in AbstractProjectTemplateProvider.AllProviders) {
- + lock (aptp) {
- + foreach (ProjectTemplate pt in aptp.Templates) {
- + if (pt.Id == id)
- + return pt;
- + }
- + }
- }
- return null;
- }
- -
- +
- bool SelectTemplate (TreeIter iter, string id)
- {
- do {
- - foreach (TemplateItem item in ((Category)catStore.GetValue (iter, 1)).Templates) {
- - if (item.Template.Id == id) {
- + foreach (ProjectTemplate item in ((Category)catStore.GetValue (iter, 1)).Templates) {
- + if (item.Id == id) {
- lst_template_types.Selection.SelectIter (iter);
- - templateView.CurrentlySelected = item.Template;
- + templateView.CurrentlySelected = item;
- return true;
- }
- }
- -175,11 +178,8 @@
- void InitializeView()
- {
- - InsertCategories (TreeIter.Zero, categories);
- - if (recentCategory.Templates.Count == 0)
- - SelectCategory (PropertyService.Get<string> ("Dialogs.NewProjectDialog.LastSelectedCategory", "C#"));
- - else
- - SelectTemplate (recentCategory.Templates [0].Template.Id);
- +
- + InsertCategories ();
- ShowAll ();
- }
- -204,11 +204,6 @@
- - Category GetCategory (string categoryname)
- - {
- - return GetCategory (categories, categoryname);
- - }
- -
- Category GetCategory (List<Category> catList, string categoryname)
- {
- int i = categoryname.IndexOf ('/');
- -554,68 +549,51 @@
- }
- - /// <summary>
- - /// Holds a new file template
- - /// </summary>
- - internal class TemplateItem
- - {
- - ProjectTemplate template;
- - string name;
- -
- - public TemplateItem (ProjectTemplate template)
- - {
- - name = StringParserService.Parse(template.Name);
- - this.template = template;
- - }
- -
- - public string Name {
- - get { return name; }
- - }
- -
- - public ProjectTemplate Template {
- - get {
- - return template;
- + private void InitializeTemplates () {
- + InitializeComponents ();
- + }
- +
- + private void ProcessCategories (List <Category> categories, Gtk.TreeIter parent) {
- + foreach (Category category in categories) {
- + Gtk.TreeIter categoryIter = catStore.AppendValues (parent, category.Name, category);
- + if (category.Categories != null) {
- + ProcessCategories (category.Categories, categoryIter);
- }
- }
- }
- -
- - private void InitializeTemplates ()
- - {
- - foreach (ProjectTemplate projectTemplate in ProjectTemplate.ProjectTemplates) {
- - if (!newSolution && projectTemplate.SolutionDescriptor.EntryDescriptors.Length == 0)
- - continue;
- - TemplateItem templateItem = new TemplateItem (projectTemplate);
- -
- - Category category = GetCategory(templateItem.Template.Category);
- - if (category != null )
- - category.Templates.Add (templateItem);
- -
- - alltemplates.Add(templateItem);
- +
- + private void ProcessProvider (AbstractProjectTemplateProvider aptp, Gtk.TreeIter parent) {
- + List<Category> categories = new List<Category> ();
- + foreach (ProjectTemplate template in aptp.Templates) {
- + GetCategory (categories, template.Category).Templates.Add(template);
- }
- -
- - recentCategory = new Category (GettextCatalog.GetString ("Recent"));
- - string strRecent = PropertyService.Get<string> ("Dialogs.NewProjectDialog.RecentTemplates", "");
- - recentIds = new List<string> (strRecent.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries));
- -
- - foreach (string id in recentIds) {
- - ProjectTemplate pt = GetTemplate (id);
- - if (pt != null)
- - recentCategory.Templates.Add (new TemplateItem (pt));
- - }
- -
- - InitializeComponents ();
- + ProcessCategories (categories, parent);
- }
- - private void InsertCategories (TreeIter node, List<Category> listCategories)
- - {
- - listCategories.Sort ();
- - if (TreeIter.Zero.Equals (node))
- - listCategories.Insert (0, recentCategory);
- - foreach (Category category in listCategories) {
- - if (TreeIter.Zero.Equals (node))
- - InsertCategories (catStore.AppendValues (category.Name, category), category.Categories);
- - else {
- - InsertCategories (catStore.AppendValues (node, category.Name, category), category.Categories);
- + private void InsertCategories () {
- + List<AbstractProjectTemplateProvider> providers = AbstractProjectTemplateProvider.AllProviders;
- + Console.WriteLine (providers.Count);
- + foreach (AbstractProjectTemplateProvider aptp in providers) {
- + if (aptp.FetchInAnotherThread) {
- + Gtk.TreeIter providerIterator = catStore.AppendValues (aptp.DisplayName);
- + Gtk.TreeIter waitIterator = catStore.AppendValues (providerIterator, "Please Wait");
- + Thread t = new Thread (new ThreadStart (delegate {
- + if (aptp.FetchTemplates ()) {
- + Application.Invoke (delegate {
- + catStore.Remove(ref waitIterator);
- + ProcessProvider (aptp, providerIterator);
- + });
- + } else {
- + Application.Invoke (delegate {
- + catStore.Remove(ref waitIterator);
- + catStore.Remove(ref providerIterator);
- + });
- + }
- + }));
- + } else {
- + if (aptp.FetchTemplates ()) {
- + ProcessProvider (aptp, catStore.AppendValues (aptp.DisplayName));
- + }
- }
- }
- }
- -626,13 +604,16 @@
- TreeIter treeIter;
- if (lst_template_types.Selection.GetSelected(out treeModel, out treeIter)) {
- - templateView.Clear();
- -
- - foreach ( TemplateItem templateItem in (catStore.GetValue(treeIter, 1) as Category).Templates) {
- - templateView.Add (templateItem);
- + if (catStore.GetValue (treeIter, 1) is Category) {
- + templateView.Clear();
- + foreach (ProjectTemplate templateItem in (catStore.GetValue(treeIter, 1) as Category).Templates) {
- + templateView.Add (templateItem);
- + }
- + btn_new.Sensitive = false;
- }
- - btn_new.Sensitive = false;
- + // TODO Figure out a nice way to display the templates otherwise.
- +
- }
- }
- -662,8 +643,8 @@
- this.name = name;
- }
- - private List<TemplateItem> templates = new List<TemplateItem>();
- - public List<TemplateItem> Templates
- + private List<ProjectTemplate> templates = new List<ProjectTemplate> ();
- + public List<ProjectTemplate> Templates
- {
- get { return templates; }
- }
- -707,8 +688,7 @@
- set { tree.CurrentlySelected = value; }
- }
- - public void Add (TemplateItem templateItem)
- - {
- + public void Add (ProjectTemplate templateItem) {
- tree.Add (templateItem);
- }
- -767,12 +747,12 @@
- }
- }
- - public void Add (TemplateItem templateItem)
- + public void Add (ProjectTemplate templateItem)
- {
- string name = GLib.Markup.EscapeText (templateItem.Name);
- - if (!string.IsNullOrEmpty (templateItem.Template.LanguageName))
- - name += "\n<span foreground='darkgrey'><small>" + templateItem.Template.LanguageName + "</small></span>";
- - templateStore.AppendValues (templateItem.Template.Icon.IsNull ? "md-project" : templateItem.Template.Icon.ToString (), name, templateItem.Template);
- + if (!string.IsNullOrEmpty (templateItem.LanguageName))
- + name += "\n<span foreground='darkgrey'><small>" + templateItem.LanguageName + "</small></span>";
- + templateStore.AppendValues (templateItem.Icon.IsNull ? "md-project" : templateItem.Icon.ToString (), name, templateItem);
- }
- public void Clear ()
- Index: MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewProjectDialog.cs
- ===================================================================
- --- MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewProjectDialog.cs (revision 153429)
- +++ MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewProjectDialog.cs (working copy)
- -88,7 +88,7 @@
- this.notebook = new global::Gtk.Notebook ();
- this.notebook.CanFocus = true;
- this.notebook.Name = "notebook";
- - this.notebook.CurrentPage = 0;
- + this.notebook.CurrentPage = 1;
- this.notebook.ShowBorder = false;
- this.notebook.BorderWidth = ((uint)(6));
- // Container child notebook.Gtk.Notebook+NotebookChild
- Index: MonoDevelop.Ide/Makefile.am
- ===================================================================
- --- MonoDevelop.Ide/Makefile.am (revision 153429)
- +++ MonoDevelop.Ide/Makefile.am (working copy)
- -14,9 +14,9 @@
- $(MONO_ADDINS_GUI_LIBS) \
- $(MONO_ADDINS_LIBS) \
- $(MONO_ADDINS_SETUP_LIBS) \
- + $(MONO_CAIRO_LIBS) \
- $(MONODOC_LIBS) \
- -r:ICSharpCode.SharpZipLib \
- - -r:Mono.Cairo \
- -r:Mono.Posix \
- -r:System \
- -r:System.Core \
- -338,6 +338,7 @@
- MonoDevelop.Ide.Tasks/TaskService.cs \
- MonoDevelop.Ide.Tasks/TaskStore.cs \
- MonoDevelop.Ide.Tasks/UserTasksView.cs \
- + MonoDevelop.Ide.Templates/AbstractProjectTemplateProvider.cs \
- MonoDevelop.Ide.Templates/ClrVersionFileTemplateCondition.cs \
- MonoDevelop.Ide.Templates/CodeDomFileDescriptionTemplate.cs \
- MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs \
- -347,6 +348,7 @@
- MonoDevelop.Ide.Templates/FileTemplateCondition.cs \
- MonoDevelop.Ide.Templates/FileTemplateReference.cs \
- MonoDevelop.Ide.Templates/INewFileCreator.cs \
- + MonoDevelop.Ide.Templates/InternalProjectTemplateProvider.cs \
- MonoDevelop.Ide.Templates/ISolutionItemDescriptor.cs \
- MonoDevelop.Ide.Templates/ISolutionItemFeature.cs \
- MonoDevelop.Ide.Templates/ParentProjectFileTemplateCondition.cs \
- Index: MonoDevelop.Components/Makefile.am
- ===================================================================
- --- MonoDevelop.Components/Makefile.am (revision 153429)
- +++ MonoDevelop.Components/Makefile.am (working copy)
- -6,8 +6,8 @@
- $(GLIB_SHARP_LIBS) \
- $(GTK_SHARP_LIBS) \
- $(MONO_ADDINS_LIBS) \
- + $(MONO_CAIRO_LIBS) \
- -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \
- - -r:Mono.Cairo \
- -r:Mono.Posix \
- -r:System \
- -r:System.Core \
- Index: Mono.Texteditor/Makefile.am
- ===================================================================
- --- Mono.Texteditor/Makefile.am (revision 153429)
- +++ Mono.Texteditor/Makefile.am (working copy)
- -4,7 +4,7 @@
- REFS = \
- $(GLIB_SHARP_LIBS) \
- $(GTK_SHARP_LIBS) \
- - -r:Mono.Cairo \
- + $(MONO_CAIRO_LIBS) \
- -r:Mono.Posix \
- -r:System \
- -r:System.Core \
- Index: MonoDevelop.Core.Gui/ChangeLog
- ===================================================================
- --- MonoDevelop.Core.Gui/ChangeLog (revision 153429)
- +++ MonoDevelop.Core.Gui/ChangeLog (working copy)
- -1,3 +1,7 @@
- +2010-03-13 Sanjoy Das <sanjoy@playingwithpointers.com>
- +
- + * Makefile.am:
- +
- 2010-03-08 Mike Krüger <mkrueger@novell.com>
- * MonoDevelop.Core.Gui.addin.xml: Added jay mime type.
- Index: MonoDevelop.Ide/ChangeLog
- ===================================================================
- --- MonoDevelop.Ide/ChangeLog (revision 153429)
- +++ MonoDevelop.Ide/ChangeLog (working copy)
- -1,3 +1,14 @@
- +2010-03-13 Sanjoy Das <sanjoy@playingwithpointers.com>
- +
- + * Makefile.am:
- + * MonoDevelop.Ide.csproj:
- + * MonoDevelop.Ide.Templates/ProjectTemplate.cs:
- + * MonoDevelop.Ide.Gui.Dialogs/NewProjectDialog.cs:
- + * gtk-gui/MonoDevelop.Ide.Gui.Dialogs.NewProjectDialog.cs:
- + * MonoDevelop.Ide.Templates/AbstractProjectTemplateProvider.cs:
- + * MonoDevelop.Ide.Templates/InternalProjectTemplateProvider.cs:
- +
- +
- 2010-03-09 Lluis Sanchez Gual <lluis@novell.com>
- * MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs:
- Index: MonoDevelop.Components/ChangeLog
- ===================================================================
- --- MonoDevelop.Components/ChangeLog (revision 153429)
- +++ MonoDevelop.Components/ChangeLog (working copy)
- -1,3 +1,7 @@
- +2010-03-13 Sanjoy Das <sanjoy@playingwithpointers.com>
- +
- + * Makefile.am:
- +
- 2010-03-09 Mike Krüger <mkrueger@novell.com>
- * MonoDevelop.Components/SearchEntry.cs:
- Index: Mono.Texteditor/ChangeLog
- ===================================================================
- --- Mono.Texteditor/ChangeLog (revision 153429)
- +++ Mono.Texteditor/ChangeLog (working copy)
- -1,3 +1,7 @@
- +2010-03-13 Sanjoy Das <sanjoy@playingwithpointers.com>
- +
- + * Makefile.am:
- +
- 2010-03-09 Mike Krüger <mkrueger@novell.com>
- * Mono.TextEditor.Highlighting/SyntaxMode.cs: Fixed failing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement