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