2
// ProjectNodeBuilder.cs
5
// Mike Krüger <mkrueger@xamarin.com>
7
// Copyright (c) 2012 Xamarin <http://xamarin.com>
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:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
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
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;
41
using MonoDevelop.Projects;
42
using MonoDevelop.Ide.TypeSystem;
44
namespace MonoDevelop.AssemblyBrowser
46
class ProjectNodeBuilder : TypeNodeBuilder
48
internal AssemblyBrowserWidget Widget {
53
public override Type NodeDataType {
54
get { return typeof(Project); }
57
public ProjectNodeBuilder (AssemblyBrowserWidget widget)
62
public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
64
var project = (Project)dataObject;
68
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
70
var project = (Project)dataObject;
73
icon = Context.GetIcon (project.StockIcon);
76
public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
78
var project = (Project)dataObject;
79
var ctx = TypeSystemService.GetProjectContext (project);
83
var namespaces = new Dictionary<string, Namespace> ();
84
bool publicOnly = builder.Options ["PublicApiOnly"];
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);
91
var ns = namespaces [namespaceName];
95
foreach (var ns in namespaces.Values) {
96
builder.AddChild (ns);
100
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
102
var project = (Project)dataObject;
103
var ctx = TypeSystemService.GetProjectContext (project);
106
return ctx.TopLevelTypeDefinitions.Any ();
109
public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
112
if (thisNode == null || otherNode == null)
114
var e1 = thisNode.DataItem as Project;
115
var e2 = otherNode.DataItem as Project;
117
if (e1 == null && e2 == null)
124
return e1.Name.CompareTo (e2.Name);
125
} catch (Exception e) {
126
LoggingService.LogError ("Exception in assembly browser sort function.", e);
2
// ProjectNodeBuilder.cs
5
// Mike Krüger <mkrueger@xamarin.com>
7
// Copyright (c) 2012 Xamarin <http://xamarin.com>
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:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
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
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;
41
using MonoDevelop.Projects;
42
using MonoDevelop.Ide.TypeSystem;
44
namespace MonoDevelop.AssemblyBrowser
46
class ProjectNodeBuilder : TypeNodeBuilder
48
internal AssemblyBrowserWidget Widget {
53
public override Type NodeDataType {
54
get { return typeof(Project); }
57
public ProjectNodeBuilder (AssemblyBrowserWidget widget)
62
public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
64
var project = (Project)dataObject;
68
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
70
var project = (Project)dataObject;
73
icon = Context.GetIcon (project.StockIcon);
76
public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
78
var project = (Project)dataObject;
79
var ctx = TypeSystemService.GetProjectContext (project);
83
var namespaces = new Dictionary<string, Namespace> ();
84
bool publicOnly = Widget.PublicApiOnly;
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);
91
var ns = namespaces [namespaceName];
95
foreach (var ns in namespaces.Values) {
96
builder.AddChild (ns);
100
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
102
var project = (Project)dataObject;
103
var ctx = TypeSystemService.GetProjectContext (project);
106
return ctx.TopLevelTypeDefinitions.Any ();
109
public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
112
if (thisNode == null || otherNode == null)
114
var e1 = thisNode.DataItem as Project;
115
var e2 = otherNode.DataItem as Project;
117
if (e1 == null && e2 == null)
124
return e1.Name.CompareTo (e2.Name);
125
} catch (Exception e) {
126
LoggingService.LogError ("Exception in assembly browser sort function.", e);