~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/ProjectNodeBuilder.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-06-22 20:35:35 UTC
  • mfrom: (10.3.2)
  • Revision ID: package-import@ubuntu.com-20120622203535-zrozwvcf6kfk6l6i
Tags: 3.0.3.2+dfsg-1
* [3fd89ae] Imported Upstream version 3.0.3.2+dfsg
* [379a680] Remove old patches we haven't used for ages from git.
* [d71161d] Remove correct_paths_in_monodevelop-core-addins.pc.patch.
  Upstream claim to have fixed this by moving assembly install locations.
* [15dbfb9] Fix install location for MonoDevelop.Gettext.dll.config.
* [26eb434] Fix install location for MonoDevelop.SourceEditor2.dll.config.
* [4169974] Upstream commit 53282c9 which finally reconciles the 
  MonoDevelop.Gettext.dll install location with the 
  monodevelop-core-addins.pc location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// ProjectNodeBuilder.cs
3
 
//  
4
 
// Author:
5
 
//       Mike Krüger <mkrueger@xamarin.com>
6
 
// 
7
 
// Copyright (c) 2012 Xamarin <http://xamarin.com>
8
 
// 
9
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
 
// of this software and associated documentation files (the "Software"), to deal
11
 
// in the Software without restriction, including without limitation the rights
12
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 
// copies of the Software, and to permit persons to whom the Software is
14
 
// furnished to do so, subject to the following conditions:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
19
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using System.Linq;
29
 
using System.Text;
30
 
 
31
 
using Mono.Cecil;
32
 
 
33
 
using MonoDevelop.Core;
34
 
using MonoDevelop.Ide.Gui;
35
 
using MonoDevelop.Ide.Gui.Pads;
36
 
using MonoDevelop.Ide.Gui.Components;
37
 
using Mono.TextEditor;
38
 
using System.Collections.Generic;
39
 
using ICSharpCode.NRefactory.TypeSystem;
40
 
using System.IO;
41
 
using MonoDevelop.Projects;
42
 
using MonoDevelop.Ide.TypeSystem;
43
 
 
44
 
namespace MonoDevelop.AssemblyBrowser
45
 
{
46
 
        class ProjectNodeBuilder : TypeNodeBuilder
47
 
        {
48
 
                internal AssemblyBrowserWidget Widget {
49
 
                        get; 
50
 
                        private set; 
51
 
                }
52
 
                
53
 
                public override Type NodeDataType {
54
 
                        get { return typeof(Project); }
55
 
                }
56
 
                
57
 
                public ProjectNodeBuilder (AssemblyBrowserWidget widget)
58
 
                {
59
 
                        Widget = widget;
60
 
                }
61
 
                
62
 
                public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
63
 
                {
64
 
                        var project = (Project)dataObject;
65
 
                        return project.Name;
66
 
                }
67
 
                
68
 
                public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
69
 
                {
70
 
                        var project = (Project)dataObject;
71
 
                        
72
 
                        label = project.Name;
73
 
                        icon = Context.GetIcon (project.StockIcon);
74
 
                }
75
 
                
76
 
                public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
77
 
                {
78
 
                        var project = (Project)dataObject;
79
 
                        var ctx = TypeSystemService.GetProjectContext (project);
80
 
                        if (ctx == null)
81
 
                                return;
82
 
                        
83
 
                        var namespaces = new Dictionary<string, Namespace> ();
84
 
                        bool publicOnly = builder.Options ["PublicApiOnly"];
85
 
                        
86
 
                        foreach (var type in ctx.TopLevelTypeDefinitions) {
87
 
                                string namespaceName = string.IsNullOrEmpty (type.Namespace) ? "-" : type.Namespace;
88
 
                                if (!namespaces.ContainsKey (namespaceName))
89
 
                                        namespaces [namespaceName] = new Namespace (namespaceName);
90
 
                                
91
 
                                var ns = namespaces [namespaceName];
92
 
                                ns.Types.Add (type);
93
 
                        }
94
 
                        
95
 
                        foreach (var ns in namespaces.Values) {
96
 
                                builder.AddChild (ns);
97
 
                        }
98
 
                }
99
 
                
100
 
                public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
101
 
                {
102
 
                        var project = (Project)dataObject;
103
 
                        var ctx = TypeSystemService.GetProjectContext (project);
104
 
                        if (ctx == null)
105
 
                                return false;
106
 
                        return ctx.TopLevelTypeDefinitions.Any ();
107
 
                }
108
 
                
109
 
                public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
110
 
                {
111
 
                        try {
112
 
                                if (thisNode == null || otherNode == null)
113
 
                                        return -1;
114
 
                                var e1 = thisNode.DataItem as Project;
115
 
                                var e2 = otherNode.DataItem as Project;
116
 
                                
117
 
                                if (e1 == null && e2 == null)
118
 
                                        return 0;
119
 
                                if (e1 == null)
120
 
                                        return -1;
121
 
                                if (e2 == null)
122
 
                                        return 1;
123
 
                                
124
 
                                return e1.Name.CompareTo (e2.Name);
125
 
                        } catch (Exception e) {
126
 
                                LoggingService.LogError ("Exception in assembly browser sort function.", e);
127
 
                                return -1;
128
 
                        }
129
 
                }
130
 
                
131
 
        }
132
 
}
133
 
 
 
1
// 
 
2
// ProjectNodeBuilder.cs
 
3
//  
 
4
// Author:
 
5
//       Mike Krüger <mkrueger@xamarin.com>
 
6
// 
 
7
// Copyright (c) 2012 Xamarin <http://xamarin.com>
 
8
// 
 
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
// of this software and associated documentation files (the "Software"), to deal
 
11
// in the Software without restriction, including without limitation the rights
 
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
// copies of the Software, and to permit persons to whom the Software is
 
14
// furnished to do so, subject to the following conditions:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
// THE SOFTWARE.
 
26
 
 
27
using System;
 
28
using System.Linq;
 
29
using System.Text;
 
30
 
 
31
using Mono.Cecil;
 
32
 
 
33
using MonoDevelop.Core;
 
34
using MonoDevelop.Ide.Gui;
 
35
using MonoDevelop.Ide.Gui.Pads;
 
36
using MonoDevelop.Ide.Gui.Components;
 
37
using Mono.TextEditor;
 
38
using System.Collections.Generic;
 
39
using ICSharpCode.NRefactory.TypeSystem;
 
40
using System.IO;
 
41
using MonoDevelop.Projects;
 
42
using MonoDevelop.Ide.TypeSystem;
 
43
 
 
44
namespace MonoDevelop.AssemblyBrowser
 
45
{
 
46
        class ProjectNodeBuilder : TypeNodeBuilder
 
47
        {
 
48
                internal AssemblyBrowserWidget Widget {
 
49
                        get; 
 
50
                        private set; 
 
51
                }
 
52
                
 
53
                public override Type NodeDataType {
 
54
                        get { return typeof(Project); }
 
55
                }
 
56
                
 
57
                public ProjectNodeBuilder (AssemblyBrowserWidget widget)
 
58
                {
 
59
                        Widget = widget;
 
60
                }
 
61
                
 
62
                public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
 
63
                {
 
64
                        var project = (Project)dataObject;
 
65
                        return project.Name;
 
66
                }
 
67
                
 
68
                public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
 
69
                {
 
70
                        var project = (Project)dataObject;
 
71
                        
 
72
                        label = project.Name;
 
73
                        icon = Context.GetIcon (project.StockIcon);
 
74
                }
 
75
                
 
76
                public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
 
77
                {
 
78
                        var project = (Project)dataObject;
 
79
                        var ctx = TypeSystemService.GetProjectContext (project);
 
80
                        if (ctx == null)
 
81
                                return;
 
82
                        
 
83
                        var namespaces = new Dictionary<string, Namespace> ();
 
84
                        bool publicOnly = Widget.PublicApiOnly;
 
85
                        
 
86
                        foreach (var type in ctx.TopLevelTypeDefinitions) {
 
87
                                string namespaceName = string.IsNullOrEmpty (type.Namespace) ? "-" : type.Namespace;
 
88
                                if (!namespaces.ContainsKey (namespaceName))
 
89
                                        namespaces [namespaceName] = new Namespace (namespaceName);
 
90
                                
 
91
                                var ns = namespaces [namespaceName];
 
92
                                ns.Types.Add (type);
 
93
                        }
 
94
                        
 
95
                        foreach (var ns in namespaces.Values) {
 
96
                                builder.AddChild (ns);
 
97
                        }
 
98
                }
 
99
                
 
100
                public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
 
101
                {
 
102
                        var project = (Project)dataObject;
 
103
                        var ctx = TypeSystemService.GetProjectContext (project);
 
104
                        if (ctx == null)
 
105
                                return false;
 
106
                        return ctx.TopLevelTypeDefinitions.Any ();
 
107
                }
 
108
                
 
109
                public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
 
110
                {
 
111
                        try {
 
112
                                if (thisNode == null || otherNode == null)
 
113
                                        return -1;
 
114
                                var e1 = thisNode.DataItem as Project;
 
115
                                var e2 = otherNode.DataItem as Project;
 
116
                                
 
117
                                if (e1 == null && e2 == null)
 
118
                                        return 0;
 
119
                                if (e1 == null)
 
120
                                        return -1;
 
121
                                if (e2 == null)
 
122
                                        return 1;
 
123
                                
 
124
                                return e1.Name.CompareTo (e2.Name);
 
125
                        } catch (Exception e) {
 
126
                                LoggingService.LogError ("Exception in assembly browser sort function.", e);
 
127
                                return -1;
 
128
                        }
 
129
                }
 
130
                
 
131
        }
 
132
}
 
133