Merge pull request #439 from mono-soc-2012/garyb/iconfix
[mono.git] / mcs / class / System.Web.DynamicData / System.Web.DynamicData / FieldTemplateUserControl.cs
1 //
2 // FieldTemplateUserControl.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //      Marek Habersack <mhabersack@novell.com>
7 //
8 // Copyright (C) 2008-2009 Novell Inc. http://novell.com
9 //
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31 using System;
32 using System.Collections;
33 using System.Collections.Generic;
34 using System.Collections.Specialized;
35 using System.Globalization;
36 using System.Security.Permissions;
37 using System.Security.Principal;
38 using System.Web.Caching;
39 using System.Web.UI;
40 using System.Web.UI.WebControls;
41
42 namespace System.Web.DynamicData
43 {
44         [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
45         [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
46         public class FieldTemplateUserControl : UserControl, IBindableControl, IFieldTemplate
47         {
48                 public MetaChildrenColumn ChildrenColumn {
49                         get {
50                                 MetaColumn column = Column;
51                                 var ret = column as MetaChildrenColumn;
52                                 if (ret == null) {
53                                         string name = column == null ? null : column.Name;
54                                         throw new Exception ("'" + name + "' is not a children column and cannot be used here.");
55                                 }
56                                 
57                                 return ret;
58                         }
59                 }               
60
61                 [MonoTODO]
62                 protected string ChildrenPath {
63                         get { return ChildrenColumn.GetChildrenListPath (Row); }
64                         
65                 }
66
67                 public MetaColumn Column {
68                         get {
69                                 IFieldTemplateHost host = Host;
70                                 if (host != null)
71                                         return host.Column;
72
73                                 return null;
74                         }
75                 }
76                 
77                 [MonoTODO]
78                 public virtual Control DataControl { get; private set; }
79                 [MonoTODO]
80                 public virtual object FieldValue { get; set; }
81                 [MonoTODO]
82                 public virtual string FieldValueEditString { get; private set; }
83                 [MonoTODO]
84                 public virtual string FieldValueString { get; private set; }
85
86                 [MonoTODO]
87                 public MetaForeignKeyColumn ForeignKeyColumn {
88                         get {
89                                 MetaColumn column = Column;
90                                 var ret = column as MetaForeignKeyColumn;
91                                 if (ret == null) {
92                                         string name = column == null ? null : column.Name;
93                                         throw new Exception ("'" + name + "' is not a foreign key column and cannot be used here.");
94                                 }
95                                 
96                                 return ret;
97                         }
98                 }
99                 
100                 [MonoTODO]
101                 protected string ForeignKeyPath {
102                         get { return ForeignKeyColumn.GetForeignKeyDetailsPath (Row); }
103                 }
104                 
105                 [MonoTODO]
106                 public IFieldFormattingOptions FormattingOptions { get; private set; }
107
108                 public IFieldTemplateHost Host { get; private set; }
109
110                 [MonoTODO]
111                 public System.ComponentModel.AttributeCollection MetadataAttributes {
112                         get {
113                                 MetaColumn column = Column;
114                                 if (column == null)
115                                         return null;
116
117                                 return column.Attributes;
118                         }
119                 }
120                 
121                 [MonoTODO]
122                 public DataBoundControlMode Mode {
123                         get {
124                                 IFieldTemplateHost host = Host;                 
125                                 return host == null ? DataBoundControlMode.ReadOnly : host.Mode;
126                         }
127                 }
128                 
129                 [MonoTODO]
130                 public virtual object Row {
131                         get {
132                                 Page page = Page;
133                                 return page == null ? null : page.GetDataItem ();
134                         }
135                 }
136                 
137                 [MonoTODO]
138                 public MetaTable Table {
139                         get {
140                                 MetaColumn column = Column;
141                                 return column == null ? null : column.Table;
142                         }
143                 }
144
145                 [MonoTODO]
146                 protected string BuildChildrenPath (string path)
147                 {
148                         throw new NotImplementedException ();
149                 }
150
151                 [MonoTODO]
152                 protected string BuildForeignKeyPath (string path)
153                 {
154                         throw new NotImplementedException ();
155                 }
156
157                 [MonoTODO]
158                 protected virtual object ConvertEditedValue (string value)
159                 {
160                         throw new NotImplementedException ();
161                 }
162
163                 [MonoTODO]
164                 protected virtual void ExtractForeignKey (IDictionary dictionary, string selectedValue)
165                 {
166                         throw new NotImplementedException ();
167                 }
168
169                 [MonoTODO]
170                 protected virtual void ExtractValues (IOrderedDictionary dictionary)
171                 {
172                         throw new NotImplementedException ();
173                 }
174
175                 [MonoTODO]
176                 protected FieldTemplateUserControl FindOtherFieldTemplate (string columnName)
177                 {
178                         throw new NotImplementedException ();
179                 }
180
181                 [MonoTODO]
182                 public virtual string FormatFieldValue (object fieldValue)
183                 {
184                         throw new NotImplementedException ();
185                 }
186
187                 [MonoTODO]
188                 protected virtual object GetColumnValue (MetaColumn column)
189                 {
190                         throw new NotImplementedException ();
191                 }
192
193                 [MonoTODO]
194                 void IBindableControl.ExtractValues (IOrderedDictionary dictionary)
195                 {
196                         ExtractValues (dictionary);
197                 }
198
199                 void IFieldTemplate.SetHost (IFieldTemplateHost host)
200                 {
201                         Host = host;
202                 }
203
204                 [MonoTODO]
205                 protected void IgnoreModelValidationAttribute (Type attributeType)
206                 {
207                         throw new NotImplementedException ();
208                 }
209
210                 [MonoTODO]
211                 protected void PopulateListControl (ListControl listControl)
212                 {
213                         throw new NotImplementedException ();
214                 }
215
216                 [MonoTODO]
217                 protected virtual void SetUpValidator (BaseValidator validator)
218                 {
219                 }
220
221                 [MonoTODO]
222                 protected virtual void SetUpValidator (BaseValidator validator, MetaColumn column)
223                 {
224                         throw new NotImplementedException ();
225                 }
226         }
227 }