2009-02-28 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / DataSourceControl.cs
1 //
2 // System.Web.UI.DataSourceControl
3 //
4 // Authors:
5 //      Ben Maurer (bmaurer@users.sourceforge.net)
6 //
7 // (C) 2003 Ben Maurer
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32 using System.Collections;
33 using System.Collections.Specialized;
34 using System.ComponentModel;
35 using System.Text;
36
37 namespace System.Web.UI {
38
39         [DesignerAttribute ("System.Web.UI.Design.DataSourceDesigner, " + Consts.AssemblySystem_Design,
40                             "System.ComponentModel.Design.IDesigner")]
41         [ControlBuilderAttribute (typeof (DataSourceControlBuilder))]
42         [NonVisualControlAttribute]
43         [BindableAttribute (false)]
44         public abstract class DataSourceControl : Control, IDataSource, System.ComponentModel.IListSource {
45
46
47                 protected DataSourceControl()
48                 {
49                 }
50                 
51                 [MonoTODO ("Not implemented")]
52                 [EditorBrowsable (EditorBrowsableState.Never)]
53                 public override void ApplyStyleSheetSkin (Page page)
54                 {
55                         throw new NotImplementedException ();
56                 }
57
58                 protected override ControlCollection CreateControlCollection ()
59                 {
60                         return new EmptyControlCollection (this);
61                 }
62
63                 [MonoTODO ("why override?")]
64                 [EditorBrowsable (EditorBrowsableState.Never)]
65                 public override Control FindControl (string id)
66                 {
67                         return base.FindControl (id);
68                 }
69
70                 [EditorBrowsable (EditorBrowsableState.Never)]
71                 public override void Focus ()
72                 {
73                         throw new NotSupportedException ();
74                 }
75
76                 protected abstract DataSourceView GetView (string viewName);
77                 
78                 DataSourceView IDataSource.GetView (string viewName)
79                 {
80                         return GetView (viewName);
81                 }
82                 
83                 protected virtual ICollection GetViewNames ()
84                 {
85                         return null;
86                 }
87                 
88                 ICollection IDataSource.GetViewNames ()
89                 {
90                         return GetViewNames ();
91                 }
92
93                 IList System.ComponentModel.IListSource.GetList ()
94                 {
95                         return ListSourceHelper.GetList (this);
96                 }
97                 
98                 [EditorBrowsable (EditorBrowsableState.Never)]
99                 public override bool HasControls ()
100                 {
101                         return base.HasControls ();
102                 }
103
104                 protected virtual void RaiseDataSourceChangedEvent (EventArgs e)
105                 {
106                         EventHandler eh = Events [dataSourceChanged] as EventHandler;
107                         if (eh != null)
108                                 eh (this, e);
109                 }
110
111                 [EditorBrowsable (EditorBrowsableState.Never)]
112                 public override void RenderControl (HtmlTextWriter tw)
113                 {
114                         base.RenderControl (tw);
115                 }
116
117                 [EditorBrowsable (EditorBrowsableState.Never)]
118                 public override string ClientID {
119                         get { return base.ClientID; }
120                 }
121
122                 [EditorBrowsable (EditorBrowsableState.Never)]
123                 public override ControlCollection Controls {
124                         get { return base.Controls; }
125                 }
126
127                 [DefaultValue (false)]
128                 [Browsable (false)]
129                 [EditorBrowsable (EditorBrowsableState.Never)]
130                 public override bool EnableTheming {
131                         get { return false; }
132                         set { throw new NotSupportedException (); }
133                 }
134
135                 [DefaultValue ("")]
136                 [Browsable (false)]
137                 [EditorBrowsable (EditorBrowsableState.Never)]
138                 public override string SkinID {
139                         get { return base.SkinID; }
140                         set { base.SkinID = value; }
141                 }
142
143                 bool System.ComponentModel.IListSource.ContainsListCollection {
144                         get { return ListSourceHelper.ContainsListCollection (this); }
145                 }
146
147                 [Browsable (false)]
148                 [EditorBrowsable (EditorBrowsableState.Never)]
149                 [DefaultValue (false)]
150                 public override bool Visible { 
151                         get { return false; }
152                         set { throw new NotSupportedException (); }
153                 }
154
155                 static object dataSourceChanged = new object ();
156                 event EventHandler System.Web.UI.IDataSource.DataSourceChanged {
157                         add { Events.AddHandler (dataSourceChanged, value); }
158                         remove { Events.RemoveHandler (dataSourceChanged, value); }
159                 }
160
161         }
162 }
163 #endif
164