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