WebPart.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. [WebSysDescriptionAttribute ("")]
  89. [WebCategoryAttribute ("Behavior")]
  90. public virtual bool AllowClose
  91. {
  92. get {
  93. return (allow & Allow.Close) != 0;
  94. }
  95. set {
  96. if (value)
  97. allow |= Allow.Close;
  98. else
  99. allow &= ~Allow.Close;
  100. }
  101. }
  102. [WebSysDescriptionAttribute ("")]
  103. [WebCategoryAttribute ("Behavior")]
  104. public virtual bool AllowConnect
  105. {
  106. get {
  107. return (allow & Allow.Connect) != 0;
  108. }
  109. set {
  110. if (value)
  111. allow |= Allow.Connect;
  112. else
  113. allow &= ~Allow.Connect;
  114. }
  115. }
  116. [WebSysDescriptionAttribute ("")]
  117. [WebCategoryAttribute ("Behavior")]
  118. public virtual bool AllowEdit
  119. {
  120. get {
  121. return (allow & Allow.Edit) != 0;
  122. }
  123. set {
  124. if (value)
  125. allow |= Allow.Edit;
  126. else
  127. allow &= ~Allow.Edit;
  128. }
  129. }
  130. [WebSysDescriptionAttribute ("")]
  131. [WebCategoryAttribute ("Behavior")]
  132. public virtual bool AllowHide
  133. {
  134. get {
  135. return (allow & Allow.Hide) != 0;
  136. }
  137. set {
  138. if (value)
  139. allow |= Allow.Hide;
  140. else
  141. allow &= ~Allow.Hide;
  142. }
  143. }
  144. [WebSysDescriptionAttribute ("")]
  145. [WebCategoryAttribute ("Behavior")]
  146. public virtual bool AllowMinimize
  147. {
  148. get {
  149. return (allow & Allow.Minimize) != 0;
  150. }
  151. set {
  152. if (value)
  153. allow |= Allow.Minimize;
  154. else
  155. allow &= ~Allow.Minimize;
  156. }
  157. }
  158. [WebSysDescriptionAttribute ("")]
  159. [WebCategoryAttribute ("Behavior")]
  160. public virtual bool AllowZoneChange
  161. {
  162. get {
  163. return (allow & Allow.ZoneChange) != 0;
  164. }
  165. set {
  166. if (value)
  167. allow |= Allow.ZoneChange;
  168. else
  169. allow &= ~Allow.ZoneChange;
  170. }
  171. }
  172. [MonoTODO]
  173. public virtual string AuthorizationFilter
  174. {
  175. get {
  176. return auth_filter;
  177. }
  178. set {
  179. auth_filter = value;
  180. }
  181. }
  182. [MonoTODO]
  183. public virtual string CatalogIconImageUrl
  184. {
  185. get {
  186. return catalog_icon_url;
  187. }
  188. set {
  189. catalog_icon_url = value;
  190. }
  191. }
  192. [MonoTODO ("why override?")]
  193. public override PartChromeState ChromeState
  194. {
  195. get {
  196. return base.ChromeState;
  197. }
  198. set {
  199. base.ChromeState = value;
  200. }
  201. }
  202. [MonoTODO ("why override?")]
  203. public override PartChromeType ChromeType
  204. {
  205. get {
  206. return base.ChromeType;
  207. }
  208. set {
  209. base.ChromeType = value;
  210. }
  211. }
  212. [MonoTODO]
  213. public string ConnectErrorMessage
  214. {
  215. get {
  216. return "";
  217. }
  218. }
  219. [MonoTODO ("why override?")]
  220. public override string Description
  221. {
  222. get {
  223. return base.Description;
  224. }
  225. set {
  226. base.Description = value;
  227. }
  228. }
  229. [MonoTODO]
  230. /* msdn2 lists this as an override, but it doesn't appear to work with our implementation */
  231. public /*override*/ ContentDirection Direction
  232. {
  233. get {
  234. throw new NotImplementedException ();
  235. }
  236. set {
  237. throw new NotImplementedException ();
  238. }
  239. }
  240. public string DisplayTitle
  241. {
  242. get {
  243. return "Untitled";
  244. }
  245. }
  246. [MonoTODO]
  247. public virtual WebPartExportMode ExportMode
  248. {
  249. get {
  250. throw new NotImplementedException ();
  251. }
  252. set {
  253. throw new NotImplementedException ();
  254. }
  255. }
  256. [MonoTODO]
  257. public bool HasSharedData
  258. {
  259. get {
  260. throw new NotImplementedException ();
  261. }
  262. }
  263. [MonoTODO]
  264. public bool HasUserData
  265. {
  266. get {
  267. throw new NotImplementedException ();
  268. }
  269. }
  270. [MonoTODO("why override?")]
  271. public override Unit Height
  272. {
  273. get {
  274. return base.Height;
  275. }
  276. set {
  277. base.Height = value;
  278. }
  279. }
  280. [MonoTODO]
  281. public virtual WebPartHelpMode HelpMode
  282. {
  283. get {
  284. throw new NotImplementedException ();
  285. }
  286. set {
  287. throw new NotImplementedException ();
  288. }
  289. }
  290. [MonoTODO]
  291. public virtual string HelpUrl
  292. {
  293. get {
  294. throw new NotImplementedException ();
  295. }
  296. set {
  297. throw new NotImplementedException ();
  298. }
  299. }
  300. [MonoTODO]
  301. public virtual bool Hidden
  302. {
  303. get {
  304. throw new NotImplementedException ();
  305. }
  306. set {
  307. throw new NotImplementedException ();
  308. }
  309. }
  310. public virtual string ImportErrorMessage
  311. {
  312. get {
  313. return ViewState.GetString("ImportErrorMessage", "Cannot import this Web Part.");
  314. }
  315. set {
  316. ViewState ["ImportErrorMessage"] = value;
  317. }
  318. }
  319. [MonoTODO]
  320. public bool IsClosed
  321. {
  322. get {
  323. throw new NotImplementedException ();
  324. }
  325. }
  326. [MonoTODO("not virtual and no setter..")]
  327. public bool IsShared
  328. {
  329. get {
  330. return false;
  331. }
  332. }
  333. [MonoTODO("not virtual and no setter..")]
  334. public bool IsStandalone
  335. {
  336. get {
  337. return true;
  338. }
  339. }
  340. [MonoTODO]
  341. public bool IsStatic
  342. {
  343. get {
  344. throw new NotImplementedException ();
  345. }
  346. }
  347. [MonoTODO]
  348. public virtual string Subtitle
  349. {
  350. get {
  351. throw new NotImplementedException ();
  352. }
  353. }
  354. [MonoTODO ("why override?")]
  355. public override string Title
  356. {
  357. get {
  358. return base.Title;
  359. }
  360. set {
  361. base.Title = value;
  362. }
  363. }
  364. [MonoTODO]
  365. public virtual string TitleIconImageUrl
  366. {
  367. get {
  368. throw new NotImplementedException ();
  369. }
  370. set {
  371. throw new NotImplementedException ();
  372. }
  373. }
  374. [MonoTODO]
  375. public virtual string TitleUrl
  376. {
  377. get {
  378. throw new NotImplementedException ();
  379. }
  380. set {
  381. throw new NotImplementedException ();
  382. }
  383. }
  384. public virtual WebPartVerbCollection Verbs
  385. {
  386. get {
  387. return verbs;
  388. }
  389. }
  390. #if IWebEditableInterface
  391. [MonoTODO]
  392. public virtual object WebBrowsableObject
  393. {
  394. get {
  395. throw new NotImplementedException ();
  396. }
  397. }
  398. #endif
  399. #if notyet
  400. [MonoTODO]
  401. protected WebPartManager WebPartManager
  402. {
  403. get {
  404. throw new NotImplementedException ();
  405. }
  406. }
  407. #endif
  408. [MonoTODO ("why override?")]
  409. public override Unit Width
  410. {
  411. get {
  412. return base.Width;
  413. }
  414. set {
  415. base.Width = value;
  416. }
  417. }
  418. #if notyet
  419. [MonoTODO]
  420. public WebPartZoneBase Zone
  421. {
  422. get {
  423. throw new NotImplementedException ();
  424. }
  425. }
  426. #endif
  427. [MonoTODO]
  428. public int ZoneIndex
  429. {
  430. get {
  431. throw new NotImplementedException ();
  432. }
  433. }
  434. }
  435. }
  436. #endif