WebPart.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. //
  2. // System.Web.UI.WebControls.WebParts.Part
  3. //
  4. // Authors: Chris Toshok <[email protected]>
  5. //
  6. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. #if NET_2_0
  28. using System;
  29. namespace System.Web.UI.WebControls.WebParts
  30. {
  31. public abstract class WebPart : Part, IWebPart, IWebActionable
  32. #if IWebEditableInterface
  33. , IWebEditable
  34. #endif
  35. {
  36. [Flags]
  37. enum Allow {
  38. Close = 0x01,
  39. Connect = 0x02,
  40. Edit = 0x04,
  41. Hide = 0x08,
  42. Minimize = 0x10,
  43. ZoneChange = 0x20
  44. }
  45. WebPartVerbCollection verbs;
  46. Allow allow;
  47. string auth_filter;
  48. string catalog_icon_url;
  49. protected WebPart ()
  50. {
  51. verbs = new WebPartVerbCollection();
  52. allow = Allow.Close | Allow.Connect | Allow.Edit | Allow.Hide | Allow.Minimize | Allow.ZoneChange;
  53. auth_filter = "";
  54. catalog_icon_url = "";
  55. }
  56. #if IWebEditableInterface
  57. [MonoTODO]
  58. public virtual EditorPartCollection CreateEditorParts ()
  59. {
  60. throw new NotImplementedException ();
  61. }
  62. #endif
  63. [MonoTODO]
  64. protected void SetPersonalizationDirty ()
  65. {
  66. throw new NotImplementedException ();
  67. }
  68. [MonoTODO]
  69. public static void SetPersonalizationDirty (Control control)
  70. {
  71. throw new NotImplementedException ();
  72. }
  73. protected override void TrackViewState ()
  74. {
  75. base.TrackViewState();
  76. foreach (IStateManager verb in verbs) {
  77. verb.TrackViewState();
  78. }
  79. }
  80. protected internal virtual void OnClosing (EventArgs e)
  81. { /* no base class implementation */ }
  82. protected internal virtual void OnConnectModeChanged (EventArgs e)
  83. { /* no base class implementation */ }
  84. protected internal virtual void OnDeleting (EventArgs e)
  85. { /* no base class implementation */ }
  86. protected internal virtual void OnEditModeChanged (EventArgs e)
  87. { /* no base class implementation */ }
  88. public virtual bool AllowClose
  89. {
  90. get {
  91. return (allow & Allow.Close) != 0;
  92. }
  93. set {
  94. if (value)
  95. allow |= Allow.Close;
  96. else
  97. allow &= ~Allow.Close;
  98. }
  99. }
  100. public virtual bool AllowConnect
  101. {
  102. get {
  103. return (allow & Allow.Connect) != 0;
  104. }
  105. set {
  106. if (value)
  107. allow |= Allow.Connect;
  108. else
  109. allow &= ~Allow.Connect;
  110. }
  111. }
  112. public virtual bool AllowEdit
  113. {
  114. get {
  115. return (allow & Allow.Edit) != 0;
  116. }
  117. set {
  118. if (value)
  119. allow |= Allow.Edit;
  120. else
  121. allow &= ~Allow.Edit;
  122. }
  123. }
  124. public virtual bool AllowHide
  125. {
  126. get {
  127. return (allow & Allow.Hide) != 0;
  128. }
  129. set {
  130. if (value)
  131. allow |= Allow.Hide;
  132. else
  133. allow &= ~Allow.Hide;
  134. }
  135. }
  136. public virtual bool AllowMinimize
  137. {
  138. get {
  139. return (allow & Allow.Minimize) != 0;
  140. }
  141. set {
  142. if (value)
  143. allow |= Allow.Minimize;
  144. else
  145. allow &= ~Allow.Minimize;
  146. }
  147. }
  148. public virtual bool AllowZoneChange
  149. {
  150. get {
  151. return (allow & Allow.ZoneChange) != 0;
  152. }
  153. set {
  154. if (value)
  155. allow |= Allow.ZoneChange;
  156. else
  157. allow &= ~Allow.ZoneChange;
  158. }
  159. }
  160. [MonoTODO]
  161. public virtual string AuthorizationFilter
  162. {
  163. get {
  164. return auth_filter;
  165. }
  166. set {
  167. auth_filter = value;
  168. }
  169. }
  170. [MonoTODO]
  171. public virtual string CatalogIconImageUrl
  172. {
  173. get {
  174. return catalog_icon_url;
  175. }
  176. set {
  177. catalog_icon_url = value;
  178. }
  179. }
  180. [MonoTODO ("why override?")]
  181. public override PartChromeState ChromeState
  182. {
  183. get {
  184. return base.ChromeState;
  185. }
  186. set {
  187. base.ChromeState = value;
  188. }
  189. }
  190. [MonoTODO ("why override?")]
  191. public override PartChromeType ChromeType
  192. {
  193. get {
  194. return base.ChromeType;
  195. }
  196. set {
  197. base.ChromeType = value;
  198. }
  199. }
  200. [MonoTODO]
  201. public string ConnectErrorMessage
  202. {
  203. get {
  204. return "";
  205. }
  206. }
  207. [MonoTODO ("why override?")]
  208. public override string Description
  209. {
  210. get {
  211. return base.Description;
  212. }
  213. set {
  214. base.Description = value;
  215. }
  216. }
  217. [MonoTODO]
  218. /* msdn2 lists this as an override, but it doesn't appear to work with our implementation */
  219. public /*override*/ ContentDirection Direction
  220. {
  221. get {
  222. throw new NotImplementedException ();
  223. }
  224. set {
  225. throw new NotImplementedException ();
  226. }
  227. }
  228. public string DisplayTitle
  229. {
  230. get {
  231. return "Untitled";
  232. }
  233. }
  234. [MonoTODO]
  235. public virtual WebPartExportMode ExportMode
  236. {
  237. get {
  238. throw new NotImplementedException ();
  239. }
  240. set {
  241. throw new NotImplementedException ();
  242. }
  243. }
  244. [MonoTODO]
  245. public bool HasSharedData
  246. {
  247. get {
  248. throw new NotImplementedException ();
  249. }
  250. }
  251. [MonoTODO]
  252. public bool HasUserData
  253. {
  254. get {
  255. throw new NotImplementedException ();
  256. }
  257. }
  258. [MonoTODO("why override?")]
  259. public override Unit Height
  260. {
  261. get {
  262. return base.Height;
  263. }
  264. set {
  265. base.Height = value;
  266. }
  267. }
  268. [MonoTODO]
  269. public virtual WebPartHelpMode HelpMode
  270. {
  271. get {
  272. throw new NotImplementedException ();
  273. }
  274. set {
  275. throw new NotImplementedException ();
  276. }
  277. }
  278. [MonoTODO]
  279. public virtual string HelpUrl
  280. {
  281. get {
  282. throw new NotImplementedException ();
  283. }
  284. set {
  285. throw new NotImplementedException ();
  286. }
  287. }
  288. [MonoTODO]
  289. public virtual bool Hidden
  290. {
  291. get {
  292. throw new NotImplementedException ();
  293. }
  294. set {
  295. throw new NotImplementedException ();
  296. }
  297. }
  298. public virtual string ImportErrorMessage
  299. {
  300. get {
  301. return ViewState.GetString("ImportErrorMessage", "Cannot import this Web Part.");
  302. }
  303. set {
  304. ViewState ["ImportErrorMessage"] = value;
  305. }
  306. }
  307. [MonoTODO]
  308. public bool IsClosed
  309. {
  310. get {
  311. throw new NotImplementedException ();
  312. }
  313. }
  314. [MonoTODO("not virtual and no setter..")]
  315. public bool IsShared
  316. {
  317. get {
  318. return false;
  319. }
  320. }
  321. [MonoTODO("not virtual and no setter..")]
  322. public bool IsStandalone
  323. {
  324. get {
  325. return true;
  326. }
  327. }
  328. [MonoTODO]
  329. public bool IsStatic
  330. {
  331. get {
  332. throw new NotImplementedException ();
  333. }
  334. }
  335. [MonoTODO]
  336. public virtual string Subtitle
  337. {
  338. get {
  339. throw new NotImplementedException ();
  340. }
  341. }
  342. [MonoTODO ("why override?")]
  343. public override string Title
  344. {
  345. get {
  346. return base.Title;
  347. }
  348. set {
  349. base.Title = value;
  350. }
  351. }
  352. [MonoTODO]
  353. public virtual string TitleIconImageUrl
  354. {
  355. get {
  356. throw new NotImplementedException ();
  357. }
  358. set {
  359. throw new NotImplementedException ();
  360. }
  361. }
  362. [MonoTODO]
  363. public virtual string TitleUrl
  364. {
  365. get {
  366. throw new NotImplementedException ();
  367. }
  368. set {
  369. throw new NotImplementedException ();
  370. }
  371. }
  372. public virtual WebPartVerbCollection Verbs
  373. {
  374. get {
  375. return verbs;
  376. }
  377. }
  378. #if IWebEditableInterface
  379. [MonoTODO]
  380. public virtual object WebBrowsableObject
  381. {
  382. get {
  383. throw new NotImplementedException ();
  384. }
  385. }
  386. #endif
  387. #if notyet
  388. [MonoTODO]
  389. protected WebPartManager WebPartManager
  390. {
  391. get {
  392. throw new NotImplementedException ();
  393. }
  394. }
  395. #endif
  396. [MonoTODO ("why override?")]
  397. public override Unit Width
  398. {
  399. get {
  400. return base.Width;
  401. }
  402. set {
  403. base.Width = value;
  404. }
  405. }
  406. #if notyet
  407. [MonoTODO]
  408. public WebPartZoneBase Zone
  409. {
  410. get {
  411. throw new NotImplementedException ();
  412. }
  413. }
  414. #endif
  415. [MonoTODO]
  416. public int ZoneIndex
  417. {
  418. get {
  419. throw new NotImplementedException ();
  420. }
  421. }
  422. }
  423. }
  424. #endif