2
0

DataControlField.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. //
  2. // System.Web.UI.WebControls.DataControlField.cs
  3. //
  4. // Authors:
  5. // Sanjay Gupta ([email protected])
  6. //
  7. // (C) 2004 Novell, Inc. (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System.Collections;
  31. using System.Collections.Specialized;
  32. using System.Web.UI;
  33. namespace System.Web.UI.WebControls {
  34. public abstract class DataControlField : IStateManager, IDataSourceViewSchemaAccessor
  35. {
  36. bool tracking = false;
  37. StateBag viewState;
  38. object dataSourceViewSchema;
  39. string accessibleHeaderText;
  40. Control control;
  41. Style controlStyle;
  42. bool designMode;
  43. TableItemStyle footerStyle;
  44. string footerText;
  45. string headerImageUrl;
  46. TableItemStyle headerStyle;
  47. string headerText;
  48. TableItemStyle itemStyle;
  49. bool showHeader;
  50. string sortExpression;
  51. bool visible;
  52. protected DataControlField()
  53. {
  54. viewState = new StateBag ();
  55. }
  56. [MonoTODO]
  57. public virtual void ExtractValuesFromCell (IOrderedDictionary dictionary,
  58. DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
  59. {
  60. throw new NotImplementedException ();
  61. }
  62. [MonoTODO]
  63. public virtual bool Initialize (bool sortingEnabled, Control control)
  64. {
  65. throw new NotImplementedException ();
  66. }
  67. [MonoTODO]
  68. public virtual void InitializeCell (DataControlFieldCell cell,
  69. DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
  70. {
  71. throw new NotImplementedException ();
  72. }
  73. [MonoTODO]
  74. protected virtual void OnFieldChanged ()
  75. {
  76. throw new NotImplementedException ();
  77. }
  78. protected virtual void LoadViewState(object savedState)
  79. {
  80. ArrayList items = savedState as ArrayList;
  81. if (items == null)
  82. return;
  83. foreach (Pair p in items) {
  84. if (((string)p.First).Equals("accessibleHeaderText")) {
  85. accessibleHeaderText = (string)p.Second;
  86. continue;
  87. }
  88. if (((string)p.First).Equals("footerText")) {
  89. footerText = (string)p.Second;
  90. continue;
  91. }
  92. if (((string)p.First).Equals("headerImageUrl")) {
  93. headerImageUrl = (string)p.Second;
  94. continue;
  95. }
  96. if (((string)p.First).Equals("headerText")) {
  97. headerText = (string)p.Second;
  98. continue;
  99. }
  100. if (((string)p.First).Equals("showHeader")) {
  101. showHeader = (bool)p.Second;
  102. continue;
  103. }
  104. if (((string)p.First).Equals("sortExpression")) {
  105. sortExpression = (string)p.Second;
  106. continue;
  107. }
  108. if (((string)p.First).Equals("visible")) {
  109. visible = (bool)p.Second;
  110. continue;
  111. }
  112. if (((string)p.First).Equals("dataSourceViewSchema"))
  113. {
  114. dataSourceViewSchema = p.Second;
  115. continue;
  116. }
  117. }
  118. }
  119. protected virtual object SaveViewState()
  120. {
  121. ArrayList items = new ArrayList();
  122. Pair pair = new Pair ();
  123. if (viewState.IsItemDirty("accessibleHeaderText")) {
  124. pair.First = "accessibleHeaderText";
  125. pair.Second = accessibleHeaderText;
  126. items.Add(pair);
  127. }
  128. if (viewState.IsItemDirty("footerText")) {
  129. pair.First = "footerText";
  130. pair.Second = footerText;
  131. items.Add(pair);
  132. }
  133. if (viewState.IsItemDirty("headerImageUrl")) {
  134. pair.First = "headerImageUrl";
  135. pair.Second = headerImageUrl;
  136. items.Add(pair);
  137. }
  138. if (viewState.IsItemDirty("headerText")) {
  139. pair.First = "headerText";
  140. pair.Second = headerText;
  141. items.Add(pair);
  142. }
  143. if (viewState.IsItemDirty("showHeader")) {
  144. pair.First = "showHeader";
  145. pair.Second = showHeader;
  146. items.Add(pair);
  147. }
  148. if (viewState.IsItemDirty("sortExpression")) {
  149. pair.First = "sortExpression";
  150. pair.Second = sortExpression;
  151. items.Add(pair);
  152. }
  153. if (viewState.IsItemDirty("visible")) {
  154. pair.First = "visible";
  155. pair.Second = visible;
  156. items.Add(pair);
  157. }
  158. if (viewState.IsItemDirty("dataSourceViewSchema")) {
  159. pair.First = "dataSourceViewSchema";
  160. pair.Second = dataSourceViewSchema;
  161. items.Add(pair);
  162. }
  163. if (items.Count == 0)
  164. return null;
  165. else
  166. return items;
  167. }
  168. protected virtual void TrackViewState()
  169. {
  170. tracking = true;
  171. }
  172. [MonoTODO]
  173. public virtual void ValidateSupportsCallback ()
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. void IStateManager.LoadViewState(object savedState)
  178. {
  179. LoadViewState(savedState);
  180. }
  181. object IStateManager.SaveViewState()
  182. {
  183. return SaveViewState();
  184. }
  185. void IStateManager.TrackViewState()
  186. {
  187. TrackViewState();
  188. }
  189. public virtual string AccessibleHeaderText {
  190. get { return (string) viewState ["accessibleHeaderText"]; }
  191. set {
  192. accessibleHeaderText = value;
  193. viewState.SetItemDirty ("accessibleHeaderText", true);
  194. }
  195. }
  196. protected Control Control {
  197. get { return control; }
  198. }
  199. public virtual Style ControlStyle {
  200. get { return controlStyle; }
  201. }
  202. protected bool DesignMode {
  203. get { return designMode; }
  204. }
  205. public virtual TableItemStyle FooterStyle {
  206. get { return footerStyle; }
  207. }
  208. public virtual string FooterText {
  209. get { return (string) viewState ["footerText"]; }
  210. set {
  211. footerText = value;
  212. viewState.SetItemDirty ("footerText", true);
  213. }
  214. }
  215. public virtual string HeaderImageUrl {
  216. get { return (string) viewState ["headerImageUrl"]; }
  217. set {
  218. headerImageUrl = value;
  219. viewState.SetItemDirty ("headerImageUrl", true);
  220. }
  221. }
  222. public virtual TableItemStyle HeaderStyle {
  223. get { return headerStyle; }
  224. }
  225. public virtual string HeaderText {
  226. get { return (string) viewState ["headerText"]; }
  227. set {
  228. headerText = value;
  229. viewState.SetItemDirty ("headerText", true);
  230. }
  231. }
  232. public virtual TableItemStyle ItemStyle {
  233. get { return itemStyle; }
  234. }
  235. public virtual bool ShowHeader {
  236. get { return (bool) viewState ["showHeader"]; }
  237. set {
  238. showHeader = value;
  239. viewState.SetItemDirty ("showHeader", true);
  240. }
  241. }
  242. public virtual string SortExpression {
  243. get { return (string) viewState ["sortExpression"]; }
  244. set {
  245. sortExpression = value;
  246. viewState.SetItemDirty ("sortExpression", true);
  247. }
  248. }
  249. public bool Visible {
  250. get { return (bool) viewState ["visible"]; }
  251. set {
  252. visible = value;
  253. viewState.SetItemDirty ("visible", true);
  254. }
  255. }
  256. protected bool IsTrackingViewState
  257. {
  258. get { return tracking; }
  259. }
  260. bool IStateManager.IsTrackingViewState
  261. {
  262. get { return IsTrackingViewState; }
  263. }
  264. object IDataSourceViewSchemaAccessor.DataSourceViewSchema {
  265. get { return viewState ["dataSourceViewSchema"]; }
  266. set {
  267. dataSourceViewSchema = value;
  268. viewState.SetItemDirty ("dataSourceViewSchema", true);
  269. }
  270. }
  271. }
  272. }
  273. #endif