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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid/DefaultPropertyTab.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 /*
 
2
 * DefaultPropertyTab.cs - The default PropertyTab
 
3
 * 
 
4
 * Part of PropertyGrid - A Gtk# widget that displays and allows 
 
5
 * editing of all of an object's public properties 
 
6
 * 
 
7
 * Authors: 
 
8
 *      Michael Hutchinson <m.j.hutchinson@gmail.com>
 
9
 *  
 
10
 * Copyright (C) 2005 Michael Hutchinson
 
11
 *
 
12
 * This sourcecode is licenced under The MIT License:
 
13
 * 
 
14
 * Permission is hereby granted, free of charge, to any person obtaining
 
15
 * a copy of this software and associated documentation files (the
 
16
 * "Software"), to deal in the Software without restriction, including
 
17
 * without limitation the rights to use, copy, modify, merge, publish,
 
18
 * distribute, sublicense, and/or sell copies of the Software, and to permit
 
19
 * persons to whom the Software is furnished to do so, subject to the
 
20
 * following conditions:
 
21
 * 
 
22
 * The above copyright notice and this permission notice shall be included in
 
23
 * all copies or substantial portions of the Software.
 
24
 *
 
25
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
26
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
27
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
 
28
 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 
29
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 
30
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 
31
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 
32
 */
 
33
 
 
34
using Gtk;
 
35
using System;
 
36
using System.ComponentModel;
 
37
using MonoDevelop.Core;
 
38
 
 
39
namespace MonoDevelop.Components.PropertyGrid
 
40
{
 
41
        public class DefaultPropertyTab : PropertyTab
 
42
        {
 
43
                public DefaultPropertyTab ()
 
44
                        : base ()
 
45
                {
 
46
                }
 
47
                
 
48
                public override string TabName {
 
49
                        get {return GettextCatalog.GetString ("Properties"); }
 
50
                }
 
51
                
 
52
                public override bool CanExtend (object extendee)
 
53
                {
 
54
                        return true;
 
55
                }
 
56
                
 
57
                public override PropertyDescriptor GetDefaultProperty (object component)
 
58
                {
 
59
                        if (component == null)
 
60
                                return null;
 
61
                        return TypeDescriptor.GetDefaultProperty (component);                   
 
62
                }
 
63
                
 
64
                public override PropertyDescriptorCollection GetProperties (object component, Attribute[] attributes)
 
65
                {
 
66
                        if (component == null)
 
67
                                return new PropertyDescriptorCollection (new PropertyDescriptor[] {});
 
68
                        return TypeDescriptor.GetProperties (component);
 
69
                }
 
70
        }
 
71
        
 
72
        public abstract class PropertyTab
 
73
        {
 
74
                public abstract string TabName { get; }
 
75
                public abstract bool CanExtend (object extendee);
 
76
                public abstract PropertyDescriptor GetDefaultProperty (object component);
 
77
                public abstract PropertyDescriptorCollection GetProperties (object component, Attribute[] attributes);
 
78
                
 
79
                public PropertyDescriptorCollection GetProperties (object component)
 
80
                {
 
81
                        return GetProperties (component, null);
 
82
                }
 
83
                
 
84
                public Gdk.Pixbuf GetIcon ()
 
85
                {
 
86
                        using (var stream = GetType ().Assembly.GetManifestResourceStream (GetType ().FullName + ".bmp")) {
 
87
                                if (stream != null) {
 
88
                                        try {
 
89
                                                return new Gdk.Pixbuf (stream);
 
90
                                        } catch (Exception e) {
 
91
                                                LoggingService.LogError ("Can't create pixbuf from resource:" + GetType ().FullName + ".bmp", e);
 
92
                                        }
 
93
                                }
 
94
                        }
 
95
                        return null;
 
96
                }
 
97
        }
 
98
}