Merge pull request #5714 from alexischr/update_bockbuild
[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 using System.Collections;
32 using System.Collections.Specialized;
33 using System.ComponentModel;
34 using System.Text;
35
36 namespace System.Web.UI {
37
38         [DesignerAttribute ("System.Web.UI.Design.DataSourceDesigner, " + Consts.AssemblySystem_Design,
39                             "System.ComponentModel.Design.IDesigner")]
40         [ControlBuilderAttribute (typeof (DataSourceControlBuilder))]
41         [NonVisualControlAttribute]
42         [BindableAttribute (false)]
43         public abstract class DataSourceControl : Control, IDataSource, System.ComponentModel.IListSource {
44
45
46                 protected DataSourceControl()
47                 {
48                 }
49                 
50                 [MonoTODO ("Not implemented")]
51                 [EditorBrowsable (EditorBrowsableState.Never)]
52                 public override void ApplyStyleSheetSkin (Page page)
53                 {
54                         throw new NotImplementedException ();
55                 }
56
57                 protected override ControlCollection CreateControlCollection ()
58                 {
59                         return new EmptyControlCollection (this);
60                 }
61
62                 [MonoTODO ("why override?")]
63                 [EditorBrowsable (EditorBrowsableState.Never)]
64                 public override Control FindControl (string id)
65                 {
66                         return base.FindControl (id);
67                 }
68
69                 [EditorBrowsable (EditorBrowsableState.Never)]
70                 public override void Focus ()
71                 {
72                         throw new NotSupportedException ();
73                 }
74
75                 protected abstract DataSourceView GetView (string viewName);
76                 
77                 DataSourceView IDataSource.GetView (string viewName)
78                 {
79                         return GetView (viewName);
80                 }
81                 
82                 protected virtual ICollection GetViewNames ()
83                 {
84                         return null;
85                 }
86                 
87                 ICollection IDataSource.GetViewNames ()
88                 {
89                         return GetViewNames ();
90                 }
91
92                 IList System.ComponentModel.IListSource.GetList ()
93                 {
94                         return ListSourceHelper.GetList (this);
95                 }
96                 
97                 [EditorBrowsable (EditorBrowsableState.Never)]
98                 public override bool HasControls ()
99                 {
100                         return base.HasControls ();
101                 }
102
103                 protected virtual void RaiseDataSourceChangedEvent (EventArgs e)
104                 {
105                         EventHandler eh = Events [dataSourceChanged] as EventHandler;
106                         if (eh != null)
107                                 eh (this, e);
108                 }
109
110                 [EditorBrowsable (EditorBrowsableState.Never)]
111                 public override void RenderControl (HtmlTextWriter writer)
112                 {
113                         base.RenderControl (writer);
114                 }
115
116                 [EditorBrowsable (EditorBrowsableState.Never)]
117                 public override string ClientID {
118                         get { return base.ClientID; }
119                 }
120
121                 [EditorBrowsable (EditorBrowsableState.Never)]
122                 public override ControlCollection Controls {
123                         get { return base.Controls; }
124                 }
125
126                 [DefaultValue (false)]
127                 [Browsable (false)]
128                 [EditorBrowsable (EditorBrowsableState.Never)]
129                 public override bool EnableTheming {
130                         get { return false; }
131                         set { throw new NotSupportedException (); }
132                 }
133
134                 [DefaultValue ("")]
135                 [Browsable (false)]
136                 [EditorBrowsable (EditorBrowsableState.Never)]
137                 public override string SkinID {
138                         get { return base.SkinID; }
139                         set { base.SkinID = value; }
140                 }
141
142                 bool System.ComponentModel.IListSource.ContainsListCollection {
143                         get { return ListSourceHelper.ContainsListCollection (this); }
144                 }
145
146                 [Browsable (false)]
147                 [EditorBrowsable (EditorBrowsableState.Never)]
148                 [DefaultValue (false)]
149                 public override bool Visible { 
150                         get { return false; }
151                         set { throw new NotSupportedException (); }
152                 }
153
154                 static object dataSourceChanged = new object ();
155                 event EventHandler System.Web.UI.IDataSource.DataSourceChanged {
156                         add { Events.AddHandler (dataSourceChanged, value); }
157                         remove { Events.RemoveHandler (dataSourceChanged, value); }
158                 }
159
160         }
161 }
162