2
0

WebPart.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. using System;
  28. namespace System.Web.UI.WebControls.WebParts
  29. {
  30. public abstract class WebPart : Part, IWebPart, IWebActionable
  31. #if IWebEditableInterface
  32. , IWebEditable
  33. #endif
  34. {
  35. [Flags]
  36. enum Allow {
  37. Close = 0x01,
  38. Connect = 0x02,
  39. Edit = 0x04,
  40. Hide = 0x08,
  41. Minimize = 0x10,
  42. ZoneChange = 0x20
  43. }
  44. WebPartVerbCollection verbs = new WebPartVerbCollection();
  45. Allow allow;
  46. string auth_filter;
  47. string catalog_icon_url;
  48. WebPartExportMode exportMode = WebPartExportMode.None;
  49. string titleIconImageUrl,
  50. titleUrl,
  51. helpUrl;
  52. bool isStatic, hidden, isClosed, hasSharedData, hasUserData;
  53. WebPartHelpMode helpMode = WebPartHelpMode.Navigate;
  54. int zoneIndex ;
  55. protected WebPart ()
  56. {
  57. verbs = new WebPartVerbCollection();
  58. allow = Allow.Close | Allow.Connect | Allow.Edit | Allow.Hide | Allow.Minimize | Allow.ZoneChange;
  59. auth_filter = "";
  60. catalog_icon_url = "";
  61. titleIconImageUrl = string.Empty;
  62. titleUrl = string.Empty;
  63. helpUrl = string.Empty;
  64. isStatic = false;
  65. hasUserData = false;
  66. hasSharedData = false;
  67. hidden = false;
  68. isClosed = false;
  69. }
  70. #if IWebEditableInterface
  71. [MonoTODO("Not implemented")]
  72. public virtual EditorPartCollection CreateEditorParts ()
  73. {
  74. throw new NotImplementedException ();
  75. }
  76. #endif
  77. [MonoTODO("Not implemented")]
  78. protected void SetPersonalizationDirty ()
  79. {
  80. throw new NotImplementedException ();
  81. }
  82. [MonoTODO("Not implemented")]
  83. public static void SetPersonalizationDirty (Control control)
  84. {
  85. throw new NotImplementedException ();
  86. }
  87. protected override void TrackViewState ()
  88. {
  89. base.TrackViewState();
  90. foreach (IStateManager verb in verbs) {
  91. verb.TrackViewState();
  92. }
  93. }
  94. internal void SetZoneIndex (int index)
  95. {
  96. zoneIndex = index;
  97. }
  98. protected internal virtual void OnClosing (EventArgs e)
  99. { /* no base class implementation */ }
  100. protected internal virtual void OnConnectModeChanged (EventArgs e)
  101. { /* no base class implementation */ }
  102. protected internal virtual void OnDeleting (EventArgs e)
  103. { /* no base class implementation */ }
  104. protected internal virtual void OnEditModeChanged (EventArgs e)
  105. { /* no base class implementation */ }
  106. [WebSysDescriptionAttribute ("")]
  107. [WebCategoryAttribute ("Behavior")]
  108. public virtual bool AllowClose
  109. {
  110. get {
  111. return (allow & Allow.Close) != 0;
  112. }
  113. set {
  114. if (value)
  115. allow |= Allow.Close;
  116. else
  117. allow &= ~Allow.Close;
  118. }
  119. }
  120. [WebSysDescriptionAttribute ("")]
  121. [WebCategoryAttribute ("Behavior")]
  122. public virtual bool AllowConnect
  123. {
  124. get {
  125. return (allow & Allow.Connect) != 0;
  126. }
  127. set {
  128. if (value)
  129. allow |= Allow.Connect;
  130. else
  131. allow &= ~Allow.Connect;
  132. }
  133. }
  134. [WebSysDescriptionAttribute ("")]
  135. [WebCategoryAttribute ("Behavior")]
  136. public virtual bool AllowEdit
  137. {
  138. get {
  139. return (allow & Allow.Edit) != 0;
  140. }
  141. set {
  142. if (value)
  143. allow |= Allow.Edit;
  144. else
  145. allow &= ~Allow.Edit;
  146. }
  147. }
  148. [WebSysDescriptionAttribute ("")]
  149. [WebCategoryAttribute ("Behavior")]
  150. public virtual bool AllowHide
  151. {
  152. get {
  153. return (allow & Allow.Hide) != 0;
  154. }
  155. set {
  156. if (value)
  157. allow |= Allow.Hide;
  158. else
  159. allow &= ~Allow.Hide;
  160. }
  161. }
  162. [WebSysDescriptionAttribute ("")]
  163. [WebCategoryAttribute ("Behavior")]
  164. public virtual bool AllowMinimize
  165. {
  166. get {
  167. return (allow & Allow.Minimize) != 0;
  168. }
  169. set {
  170. if (value)
  171. allow |= Allow.Minimize;
  172. else
  173. allow &= ~Allow.Minimize;
  174. }
  175. }
  176. [WebSysDescriptionAttribute ("")]
  177. [WebCategoryAttribute ("Behavior")]
  178. public virtual bool AllowZoneChange
  179. {
  180. get {
  181. return (allow & Allow.ZoneChange) != 0;
  182. }
  183. set {
  184. if (value)
  185. allow |= Allow.ZoneChange;
  186. else
  187. allow &= ~Allow.ZoneChange;
  188. }
  189. }
  190. public virtual string AuthorizationFilter
  191. {
  192. get {
  193. return auth_filter;
  194. }
  195. set {
  196. auth_filter = value;
  197. }
  198. }
  199. public virtual string CatalogIconImageUrl
  200. {
  201. get {
  202. return catalog_icon_url;
  203. }
  204. set {
  205. catalog_icon_url = value;
  206. }
  207. }
  208. public override PartChromeState ChromeState
  209. {
  210. get {
  211. return base.ChromeState;
  212. }
  213. set {
  214. base.ChromeState = value;
  215. }
  216. }
  217. public override PartChromeType ChromeType
  218. {
  219. get {
  220. return base.ChromeType;
  221. }
  222. set {
  223. base.ChromeType = value;
  224. }
  225. }
  226. [MonoTODO("Not implemented")]
  227. public string ConnectErrorMessage
  228. {
  229. get {
  230. return "";
  231. }
  232. }
  233. public override string Description
  234. {
  235. get {
  236. return base.Description;
  237. }
  238. set {
  239. base.Description = value;
  240. }
  241. }
  242. [MonoTODO("Not implemented")]
  243. /* msdn2 lists this as an override, but it doesn't appear to work with our implementation */
  244. public override ContentDirection Direction
  245. {
  246. get {
  247. throw new NotImplementedException ();
  248. }
  249. set {
  250. throw new NotImplementedException ();
  251. }
  252. }
  253. public string DisplayTitle
  254. {
  255. get {
  256. return "Untitled";
  257. }
  258. }
  259. public virtual WebPartExportMode ExportMode
  260. {
  261. get {
  262. return exportMode;
  263. }
  264. set {
  265. exportMode = value;
  266. }
  267. }
  268. public bool HasSharedData
  269. {
  270. get {
  271. return hasSharedData;
  272. }
  273. }
  274. public bool HasUserData
  275. {
  276. get {
  277. return hasUserData;
  278. }
  279. }
  280. public override Unit Height
  281. {
  282. get {
  283. return base.Height;
  284. }
  285. set {
  286. base.Height = value;
  287. }
  288. }
  289. public virtual WebPartHelpMode HelpMode
  290. {
  291. get {
  292. return helpMode;
  293. }
  294. set {
  295. helpMode = value;
  296. }
  297. }
  298. public virtual string HelpUrl
  299. {
  300. get {
  301. return helpUrl;
  302. }
  303. set {
  304. helpUrl = value;
  305. }
  306. }
  307. public virtual bool Hidden
  308. {
  309. get {
  310. return hidden;
  311. }
  312. set {
  313. hidden = value;
  314. }
  315. }
  316. public virtual string ImportErrorMessage
  317. {
  318. get {
  319. return ViewState.GetString("ImportErrorMessage", "Cannot import this Web Part.");
  320. }
  321. set {
  322. ViewState ["ImportErrorMessage"] = value;
  323. }
  324. }
  325. public bool IsClosed
  326. {
  327. get {
  328. return isClosed;
  329. }
  330. }
  331. public bool IsShared
  332. {
  333. get {
  334. return false;
  335. }
  336. }
  337. public bool IsStandalone
  338. {
  339. get {
  340. return true;
  341. }
  342. }
  343. public bool IsStatic
  344. {
  345. get {
  346. return isStatic;
  347. }
  348. }
  349. public virtual string Subtitle
  350. {
  351. get {
  352. return string.Empty;
  353. }
  354. }
  355. public override string Title
  356. {
  357. get {
  358. return base.Title;
  359. }
  360. set {
  361. base.Title = value;
  362. }
  363. }
  364. public virtual string TitleIconImageUrl
  365. {
  366. get {
  367. return titleIconImageUrl;
  368. }
  369. set {
  370. titleIconImageUrl = value;
  371. }
  372. }
  373. public virtual string TitleUrl
  374. {
  375. get {
  376. return titleUrl;
  377. }
  378. set {
  379. titleUrl = value;
  380. }
  381. }
  382. public virtual WebPartVerbCollection Verbs
  383. {
  384. get {
  385. return verbs;
  386. }
  387. }
  388. #if IWebEditableInterface
  389. [MonoTODO("Not implemented")]
  390. public virtual object WebBrowsableObject
  391. {
  392. get {
  393. throw new NotImplementedException ();
  394. }
  395. }
  396. #endif
  397. #if notyet
  398. [MonoTODO("Not implemented")]
  399. protected WebPartManager WebPartManager
  400. {
  401. get {
  402. throw new NotImplementedException ();
  403. }
  404. }
  405. #endif
  406. public override Unit Width
  407. {
  408. get {
  409. return base.Width;
  410. }
  411. set {
  412. base.Width = value;
  413. }
  414. }
  415. #if notyet
  416. [MonoTODO("Not implemented")]
  417. public WebPartZoneBase Zone
  418. {
  419. get {
  420. throw new NotImplementedException ();
  421. }
  422. }
  423. #endif
  424. public int ZoneIndex
  425. {
  426. get {
  427. return zoneIndex;
  428. }
  429. }
  430. }
  431. }