Author: mhutch
Date: 2007-09-05 11:32:42 -0400 (Wed, 05 Sep 2007)
New Revision: 85366

Added:
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs
Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
   trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
   trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
   trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
Log:
* MonoDevelop.Ide.Templates/FileTemplate.cs: Add GetTemplateByID
  internal method. Convert to generic collections.
* MonoDevelop.Ide.Templates/FileTemplateReference.cs: New file template
  class which allows project and file templates to reference existing
  file templates by ID.
* MonoDevelop.Ide.addin.xml, MonoDevelop.Ide.mdp, Makefile.am: Updated.

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-09-05 
14:48:28 UTC (rev 85365)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-09-05 
15:32:42 UTC (rev 85366)
@@ -1,5 +1,14 @@
 2007-09-05  Michael Hutchinson <[EMAIL PROTECTED]> 
 
+       * MonoDevelop.Ide.Templates/FileTemplate.cs: Add GetTemplateByID 
internal
+         method. Convert to generic collections.
+       * MonoDevelop.Ide.Templates/FileTemplateReference.cs: New file template
+         class which allows project and file templates to reference existing 
file
+         templates by ID.
+       * MonoDevelop.Ide.addin.xml, MonoDevelop.Ide.mdp, Makefile.am: Updated.
+
+2007-09-05  Michael Hutchinson <[EMAIL PROTECTED]> 
+
        * MonoDevelop.Ide.Gui.Pads/NodeState.cs: Fix build.
 
 2007-09-05  Mike Krüger <[EMAIL PROTECTED]> 

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am      2007-09-05 
14:48:28 UTC (rev 85365)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am      2007-09-05 
15:32:42 UTC (rev 85366)
@@ -305,6 +305,7 @@
        MonoDevelop.Ide.Templates/CombineEntryDescriptor.cs \
        MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs \
        MonoDevelop.Ide.Templates/FileTemplate.cs \
+       MonoDevelop.Ide.Templates/FileTemplateReference.cs \
        MonoDevelop.Ide.Templates/ICombineEntryDescriptor.cs \
        MonoDevelop.Ide.Templates/ICombineEntryFeature.cs \
        MonoDevelop.Ide.Templates/INewFileCreator.cs \

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
        2007-09-05 14:48:28 UTC (rev 85365)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
        2007-09-05 15:32:42 UTC (rev 85366)
@@ -9,6 +9,7 @@
 using System.IO;
 using System.Xml;
 using System.Collections;
+using System.Collections.Generic;
 using System.Collections.Specialized;
 using System.Diagnostics;
 using System.Reflection;
@@ -30,7 +31,7 @@
        /// </summary>
        public class FileTemplate
        {
-               public static ArrayList fileTemplates = new ArrayList();
+               public static List<FileTemplate> fileTemplates = new 
List<FileTemplate> ();
                
                string    id;
                string    originator   = null;
@@ -45,7 +46,7 @@
                
                string    wizardpath   = null;
                
-               ArrayList files        = new ArrayList(); // contains 
FileDescriptionTemplate classes
+               List<FileDescriptionTemplate> files = new 
List<FileDescriptionTemplate> ();
                
                XmlElement fileoptions = null;
                
@@ -121,7 +122,7 @@
                        }
                }
                
-               public ArrayList Files {
+               public List<FileDescriptionTemplate> Files {
                        get {
                                return files;
                        }
@@ -230,6 +231,15 @@
                        return list;
                }
                
+               internal static FileTemplate GetFileTemplateByID (string 
templateID)
+               {
+                       foreach (FileTemplate t in fileTemplates)
+                               if (t.Id == templateID)
+                                       return t;
+                       
+                       return null;
+               }
+               
                public virtual bool Create (Project project, string directory, 
string language, string name)
                {
                        if (WizardPath != null) {

Added: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs
       2007-09-05 14:48:28 UTC (rev 85365)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs
       2007-09-05 15:32:42 UTC (rev 85366)
@@ -0,0 +1,79 @@
+//
+// FileTemplateReference.cs: Allows project templates to reference file 
+//     templates rather than including full file templates.
+//
+// Author:
+//     Michael Hutchinson <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// 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.Xml;
+
+using MonoDevelop.Projects;
+
+namespace MonoDevelop.Ide.Templates
+{
+       
+       
+       public class FileTemplateReference : FileDescriptionTemplate
+       {
+               
+               FileTemplate innerTemplate;             
+               string name;
+               
+               public override void Load (XmlElement filenode)
+               {
+                       name = filenode.GetAttribute ("name");
+                       string templateID = filenode.GetAttribute 
("TemplateID");
+                       if (templateID == null || templateID.Length == 0)
+                               throw new InvalidOperationException 
("TemplateID not set");
+                       innerTemplate = FileTemplate.GetFileTemplateByID 
(templateID);
+                       if (innerTemplate == null)
+                               throw new InvalidOperationException ("Could not 
find template with ID " + templateID);
+               }
+
+               public override string Name {
+                       get { return name;}
+               }
+               
+               public override void AddToProject (Project project, string 
language, string directory, string nameNotUsed)
+               {
+                       innerTemplate.Create (project, directory, language, 
this.name);
+               }
+               
+               public override void Show ()
+               {
+                       foreach (FileDescriptionTemplate fdt in 
innerTemplate.Files) {
+                               fdt.Show ();
+                       }
+               }
+               
+               public override bool IsValidName (string name, string language)
+               {
+                       return innerTemplate.IsValidName (name, language);
+               }
+               
+       }
+}

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml        
2007-09-05 14:48:28 UTC (rev 85365)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml        
2007-09-05 15:32:42 UTC (rev 85366)
@@ -1307,6 +1307,7 @@
                <FileTemplateType name = "CodeDomFile" class = 
"MonoDevelop.Ide.Templates.CodeDomFileDescriptionTemplate"/>
                <FileTemplateType name = "ProjectResource" class = 
"MonoDevelop.Ide.Templates.ResourceFileDescriptionTemplate"/>
                <FileTemplateType name = "CodeTranslationFile" class = 
"MonoDevelop.Ide.Templates.CodeTranslationFileDescriptionTemplate"/>
+               <FileTemplateType name = "FileTemplateReference" class = 
"MonoDevelop.Ide.Templates.FileTemplateReference"/>
        </Extension>
 
        <Extension path = "/MonoDevelop/Ide/ProjectTemplates">

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp      
2007-09-05 14:48:28 UTC (rev 85365)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp      
2007-09-05 15:32:42 UTC (rev 85366)
@@ -328,6 +328,7 @@
     <File name="./options/KeyBindingSchemeVisualStudio.xml" subtype="Code" 
buildaction="EmbedAsResource" />
     <File name="./MonoDevelop.Ide.Codons/FileFilterCodon.cs" subtype="Code" 
buildaction="Compile" />
     <File name="./MonoDevelop.Ide.ExternalTools/ExternalToolService.cs" 
subtype="Code" buildaction="Compile" />
+    <File name="./MonoDevelop.Ide.Templates/FileTemplateReference.cs" 
subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="False" refto="gecko-sharp, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=ccf7d78a55e9f021" />
@@ -387,4 +388,4 @@
   <DeploymentInformation strategy="File">
     <excludeFiles />
   </DeploymentInformation>
-</Project>
\ No newline at end of file
+</Project>

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to