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