~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CombineDescriptor.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
using System.IO;
23
23
using System.Xml;
24
24
using System.Collections;
 
25
using System.Collections.Generic;
25
26
using System.Collections.Specialized;
26
27
using System.Diagnostics;
27
28
using System.Reflection;
33
34
 
34
35
namespace MonoDevelop.Ide.Templates
35
36
{
36
 
        internal class CombineDescriptor: ICombineEntryDescriptor
 
37
        internal class CombineDescriptor
37
38
        {
38
39
                ArrayList entryDescriptors = new ArrayList();
39
40
                
54
55
                        this.typeName = type;
55
56
                }
56
57
                
57
 
                public ICombineEntryDescriptor[] EntryDescriptors {
58
 
                        get { return (ICombineEntryDescriptor[]) entryDescriptors.ToArray (typeof(ICombineEntryDescriptor)); }
 
58
                public ISolutionItemDescriptor[] EntryDescriptors {
 
59
                        get { return (ISolutionItemDescriptor[]) entryDescriptors.ToArray (typeof(ISolutionItemDescriptor)); }
59
60
                }
60
61
                
61
 
                public string CreateEntry (ProjectCreateInformation projectCreateInformation, string defaultLanguage)
 
62
                public WorkspaceItem CreateEntry (ProjectCreateInformation projectCreateInformation, string defaultLanguage)
62
63
                {
63
 
                        Combine newCombine;
64
 
                        
 
64
                        WorkspaceItem item;
 
65
 
65
66
                        if (typeName != null && typeName.Length > 0) {
66
67
                                Type type = Type.GetType (typeName);
67
 
                                if (type == null) {
68
 
                                        Services.MessageService.ShowError (GettextCatalog.GetString ("Can't create solution with type: {0}", typeName));
69
 
                                        return String.Empty;
 
68
                                if (type == null || !typeof(WorkspaceItem).IsAssignableFrom (type)) {
 
69
                                        MessageService.ShowError (GettextCatalog.GetString ("Can't create solution with type: {0}", typeName));
 
70
                                        return null;
70
71
                                }
71
 
                                newCombine = (Combine) Activator.CreateInstance (type);
 
72
                                item = (WorkspaceItem) Activator.CreateInstance (type);
72
73
                        } else
73
 
                                newCombine = new Combine();
74
 
 
 
74
                                item = new Solution ();
 
75
                        
75
76
                        string  newCombineName = StringParserService.Parse(name, new string[,] { 
76
77
                                {"ProjectName", projectCreateInformation.CombineName}
77
78
                        });
78
79
                        
79
 
                        newCombine.Name = newCombineName;
 
80
                        item.Name = newCombineName;
80
81
                        
81
82
                        string oldCombinePath = projectCreateInformation.CombinePath;
82
83
                        string oldProjectPath = projectCreateInformation.ProjectBasePath;
91
92
                                }
92
93
                        }
93
94
 
94
 
                        // Create sub projects
95
 
                        foreach (ICombineEntryDescriptor entryDescriptor in entryDescriptors) {
96
 
                                newCombine.AddEntry (entryDescriptor.CreateEntry (projectCreateInformation, defaultLanguage), null);
 
95
                        Solution sol = item as Solution;
 
96
                        if (sol != null) {
 
97
                                List<string> configs = new List<string> ();
 
98
                                
 
99
                                // Create sub projects
 
100
                                foreach (ISolutionItemDescriptor entryDescriptor in entryDescriptors) {
 
101
                                        SolutionEntityItem sit = entryDescriptor.CreateItem (projectCreateInformation, defaultLanguage);
 
102
                                        entryDescriptor.InitializeItem (sol.RootFolder, projectCreateInformation, defaultLanguage, sit);
 
103
                                        sol.RootFolder.Items.Add (sit);
 
104
                                        if (sit is IConfigurationTarget) {
 
105
                                                foreach (ItemConfiguration c in ((IConfigurationTarget)sit).Configurations) {
 
106
                                                        if (!configs.Contains (c.Id))
 
107
                                                                configs.Add (c.Id);
 
108
                                                }
 
109
                                        }
 
110
                                }
 
111
                                
 
112
                                // Create configurations
 
113
                                foreach (string conf in configs)
 
114
                                        sol.AddConfiguration (conf, true);
97
115
                        }
98
116
                        
99
117
                        projectCreateInformation.CombinePath = oldCombinePath;
100
118
                        projectCreateInformation.ProjectBasePath = oldProjectPath;
101
 
                        
102
 
                        // Save combine
103
 
                        using (IProgressMonitor monitor = new NullProgressMonitor ()) {
104
 
                                string combineLocation = Path.Combine (projectCreateInformation.CombinePath, newCombineName + ".mds");
105
 
                                if (File.Exists(combineLocation)) {
106
 
                                        if (Services.MessageService.AskQuestion (GettextCatalog.GetString ("Solution file {0} already exists, do you want to overwrite\nthe existing file?", combineLocation))) {
107
 
                                                newCombine.Save (combineLocation, monitor);
108
 
                                        }
109
 
                                } else {
110
 
                                        newCombine.Save (combineLocation, monitor);
111
 
                                }
112
 
                        
113
 
                                newCombine.Dispose();
114
 
                                return combineLocation;
115
 
                        }
 
119
                        item.SetLocation (projectCreateInformation.CombinePath, newCombineName);
 
120
                        
 
121
                        return item;
116
122
                }
117
123
                
118
124
                public static CombineDescriptor CreateCombineDescriptor(XmlElement element)
133
139
                                                case "Project":
134
140
                                                        combineDescriptor.entryDescriptors.Add (ProjectDescriptor.CreateProjectDescriptor((XmlElement)node));
135
141
                                                        break;
 
142
                                                case "Solution":
136
143
                                                case "Combine":
137
144
                                                        combineDescriptor.entryDescriptors.Add (CreateCombineDescriptor((XmlElement)node));
138
145
                                                        break;
139
146
                                                case "CombineEntry":
140
 
                                                        combineDescriptor.entryDescriptors.Add (CombineEntryDescriptor.CreateDescriptor((XmlElement)node));
 
147
                                                case "SolutionItem":
 
148
                                                        combineDescriptor.entryDescriptors.Add (SolutionItemDescriptor.CreateDescriptor((XmlElement)node));
141
149
                                                        break;
142
150
                                        }
143
151
                                }