TARGET_JVM
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls.WebParts / WebPart.cs
index d2be54c7c1b8ed8f7f8a376287bd8349ff7048b6..099273a410bc790e09cf2209b03c489c9c094886 100644 (file)
@@ -1,14 +1,9 @@
 //
-// System.Web.UI.WebControls.WebParts.Part.cs
+// System.Web.UI.WebControls.WebParts.Part
 //
-// Authors:
-//   Gaurav Vaish (gaurav[DOT]vaish[AT]gmail[DOT]com)
-//   Sanjay Gupta (gsanjay@novell.com)
+// Authors: Chris Toshok <toshok@novell.com>
 //
-// (C) 2004 Gaurav Vaish (http://www.mastergaurav.org)
-// (C) 2004 Novell Inc., (http://www.novell.com)
-//
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-//
+// 
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-//
+// 
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 //
 
 #if NET_2_0
-
 using System;
-using System.ComponentModel;
-using System.Web;
-using System.Web.UI.WebControls;
 
 namespace System.Web.UI.WebControls.WebParts
 {
-       [DesignerAttribute ("System.Web.UI.Design.WebControls.WebParts.WebPartDesigner, System.Design", 
-               "System.ComponentModel.Design.IDesigner")]                      
-       public class WebPart : Part, IWebPart, IWebActionable
+       public abstract class WebPart : Part, IWebPart, IWebActionable
+#if IWebEditableInterface
+         , IWebEditable
+#endif
        {
-               private bool allowClose      = true;
-               private bool allowEdit       = true;
-               private bool allowHide       = true;
-               private bool allowMinimize   = true;
-               private bool allowZoneChange = true;
-               private bool allowHelp       = true;
+               [Flags]
+               enum Allow {
+                       Close      = 0x01,
+                       Connect    = 0x02,
+                       Edit       = 0x04,
+                       Hide       = 0x08,
+                       Minimize   = 0x10,
+                       ZoneChange = 0x20
+               }
+
+
+               WebPartVerbCollection verbs = new WebPartVerbCollection();
+               Allow allow;
+               string auth_filter;
+               string catalog_icon_url;
+               WebPartExportMode exportMode = WebPartExportMode.None;
+               string  titleIconImageUrl,       
+                               titleUrl,                       
+                               helpUrl;
+               bool isStatic, hidden, isClosed, hasSharedData, hasUserData;
+               WebPartHelpMode helpMode = WebPartHelpMode.Navigate;
+               int zoneIndex ;
+
+               protected WebPart ()
+               {
+                       verbs = new WebPartVerbCollection();
+                       allow = Allow.Close | Allow.Connect | Allow.Edit | Allow.Hide | Allow.Minimize | Allow.ZoneChange;
+                       auth_filter = "";
+                       catalog_icon_url = "";
+                       titleIconImageUrl       = string.Empty;
+                       titleUrl                = string.Empty;
+                       helpUrl                 = string.Empty;
+                       isStatic                = false;
+                       hasUserData             = false;
+                       hasSharedData   = false;
+                       hidden = false;
+                       isClosed = false;
+               }
+
+#if IWebEditableInterface
+               [MonoTODO]
+               public virtual EditorPartCollection CreateEditorParts ()
+               {
+                       throw new NotImplementedException ();
+               }
+#endif
+
+               [MonoTODO]
+               protected void SetPersonalizationDirty ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static void SetPersonalizationDirty (Control control)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void TrackViewState ()
+               {
+                       base.TrackViewState();
+
+                       foreach (IStateManager verb in verbs) {
+                               verb.TrackViewState();
+                       }
+               }
+
+               protected internal virtual void OnClosing (EventArgs e)
+               { /* no base class implementation */ }
+
+               protected internal virtual void OnConnectModeChanged (EventArgs e)
+               { /* no base class implementation */ }
+
+               protected internal virtual void OnDeleting (EventArgs e)
+               { /* no base class implementation */ }
+
+               protected internal virtual void OnEditModeChanged (EventArgs e)
+               { /* no base class implementation */ }
+
+               [WebSysDescriptionAttribute ("")]
+               [WebCategoryAttribute ("Behavior")]
+               public virtual bool AllowClose 
+               {
+                       get {
+                               return (allow & Allow.Close) != 0;
+                       }
+                       set {
+                               if (value)
+                                       allow |= Allow.Close;
+                               else
+                                       allow &= ~Allow.Close;
+                       }
+               }
+
+               [WebSysDescriptionAttribute ("")]
+               [WebCategoryAttribute ("Behavior")]
+               public virtual bool AllowConnect 
+               {
+                       get {
+                               return (allow & Allow.Connect) != 0;
+                       }
+                       set {
+                               if (value)
+                                       allow |= Allow.Connect;
+                               else
+                                       allow &= ~Allow.Connect;
+                       }
+               }
+
+               [WebSysDescriptionAttribute ("")]
+               [WebCategoryAttribute ("Behavior")]
+               public virtual bool AllowEdit 
+               {
+                       get {
+                               return (allow & Allow.Edit) != 0;
+                       }
+                       set {
+                               if (value)
+                                       allow |= Allow.Edit;
+                               else
+                                       allow &= ~Allow.Edit;
+                       }
+               }
+
+               [WebSysDescriptionAttribute ("")]
+               [WebCategoryAttribute ("Behavior")]
+               public virtual bool AllowHide 
+               {
+                       get {
+                               return (allow & Allow.Hide) != 0;
+                       }
+                       set {
+                               if (value)
+                                       allow |= Allow.Hide;
+                               else
+                                       allow &= ~Allow.Hide;
+                       }
+               }
+
+               [WebSysDescriptionAttribute ("")]
+               [WebCategoryAttribute ("Behavior")]
+               public virtual bool AllowMinimize 
+               {
+                       get {
+                               return (allow & Allow.Minimize) != 0;
+                       }
+                       set {
+                               if (value)
+                                       allow |= Allow.Minimize;
+                               else
+                                       allow &= ~Allow.Minimize;
+                       }
+               }
+
+               [WebSysDescriptionAttribute ("")]
+               [WebCategoryAttribute ("Behavior")]
+               public virtual bool AllowZoneChange 
+               {
+                       get {
+                               return (allow & Allow.ZoneChange) != 0;
+                       }
+                       set {
+                               if (value)
+                                       allow |= Allow.ZoneChange;
+                               else
+                                       allow &= ~Allow.ZoneChange;
+                       }
+               }
+
+               [MonoTODO]
+               public virtual string AuthorizationFilter 
+               {
+                       get {
+                               return auth_filter;
+                       }
+                       set {
+                               auth_filter = value;
+                       }
+               }
+
+               [MonoTODO]
+               public virtual string CatalogIconImageUrl 
+               {
+                       get {
+                               return catalog_icon_url;
+                       }
+                       set {
+                               catalog_icon_url = value;
+                       }
+               }
+
+               [MonoTODO ("why override?")]
+               public override PartChromeState ChromeState 
+               {
+                       get {
+                               return base.ChromeState;
+                       }
+                       set {
+                               base.ChromeState = value;
+                       }
+               }
+
+               [MonoTODO ("why override?")]
+               public override PartChromeType ChromeType 
+               {
+                       get {
+                               return base.ChromeType;
+                       }
+                       set {
+                               base.ChromeType = value;
+                       }
+               }
+
+               [MonoTODO]
+               public string ConnectErrorMessage 
+               {
+                       get {
+                               return "";
+                       }
+               }
+
+               [MonoTODO ("why override?")]
+               public override string Description 
+               {
+                       get {
+                               return base.Description;
+                       }
+                       set {
+                               base.Description = value;
+                       }
+               }
 
-               private bool isStatic = true;
-               private bool isStandalone = true;
-               private bool isClosed = true;
+               [MonoTODO]
+               /* msdn2 lists this as an override, but it doesn't appear to work with our implementation */
+               public /*override*/ ContentDirection Direction 
+               {
+                       get {
+                       throw new NotImplementedException ();
+                       }
+                       set {
+                       throw new NotImplementedException ();
+                       }
+               }
 
-               private PartChromeState chromeState = PartChromeState.Normal;
-               private PartChromeType chromeType = PartChromeType.Default;
-               private WebPartExportMode exportMode = WebPartExportMode.None;
-               private WebPartHelpMode   helpMode   = WebPartHelpMode.Navigate;
-
-               private string subtitle;
-               private string catalogIconImageUrl;
-               private string description;
-               private string titleIconImageUrl;
-               private string title;
-               private string titleUrl;
-               private WebPartVerbCollection verbCollection;
-               
-               protected WebPart()
+               public string DisplayTitle 
                {
+                       get {
+                               return "Untitled";
+                       }
                }
-               
-               [WebSysDescriptionAttribute ("Determines Whether the Web Part can be closed."),
-               DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
-               //, PersonalizableAttribute 
-               public virtual bool AllowClose {
-                       get { return allowClose; }
-                       set { allowClose = value; }
+
+               [MonoTODO]
+               public virtual WebPartExportMode ExportMode 
+               {
+                       get {
+                               return exportMode;
+                       }
+                       set {
+                               exportMode = value;
+                       }
                }
-
-               [WebSysDescriptionAttribute ("Determines Whether properties of the Web Part can be changed using the EditorZone."),
-               DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
-               //, PersonalizableAttribute 
-               public virtual bool AllowEdit {
-                       get { return allowEdit; }
-                       set { allowEdit = value; }
+
+               [MonoTODO]
+               public bool HasSharedData 
+               {
+                       get {
+                               return hasSharedData;
+                       }
                }
 
-               [WebSysDescriptionAttribute ("Determines Whether properties of the Web Part can be changed using the EditorZone."),
-               DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
-               //, PersonalizableAttribute 
-               public virtual bool AllowHelp {
-                       get { return AllowHelp; }
-                       set { allowHelp = value; }
+               [MonoTODO]
+               public bool HasUserData 
+               {
+                       get {
+                               return hasUserData;
+                       }
                }
 
-               [WebSysDescriptionAttribute ("Determines Whether the Web Part can be minimized."),
-               DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
-               //, PersonalizableAttribute 
-               public virtual bool AllowMinimize {
-                       get { return allowMinimize; }
-                       set { allowMinimize = value; }
+               [MonoTODO("why override?")]
+               public override Unit Height 
+               {
+                       get {
+                               return base.Height;
+                       }
+                       set {
+                               base.Height = value;
+                       }
                }
-
-               [WebSysDescriptionAttribute ("Determines Whether the Web Part can be moved to some other zone."),
-               DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
-               //, PersonalizableAttribute 
-               public virtual bool AllowZoneChange {
-                       get { return allowZoneChange; }
-                       set { allowZoneChange = value; }
+
+               [MonoTODO]
+               public virtual WebPartHelpMode HelpMode 
+               {
+                       get {
+                               return helpMode;
+                       }
+                       set {
+                               helpMode = value;
+                       }
                }
 
-               [BrowsableAttribute (false), 
-               DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
-               public bool IsClosed {
-                       get { return isClosed; }
+               [MonoTODO]
+               public virtual string HelpUrl 
+               {
+                       get {
+                               return helpUrl;
+                       }
+                       set {
+                               helpUrl = value;
+                       }
                }
 
-               [BrowsableAttribute (false),
-               DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
-               public bool IsStandalone
+               [MonoTODO]
+               public virtual bool Hidden 
                {
-                       get { return isStandalone; }
+                       get {
+                               return hidden;
+                       }
+                       set {
+                               hidden = value;
+                       }
                }
-               
-               //[PersonalizableAttribute ]
-               public override PartChromeState ChromeState {
-                       get { return chromeState; }
+
+               public virtual string ImportErrorMessage 
+               {
+                       get {
+                               return ViewState.GetString("ImportErrorMessage", "Cannot import this Web Part.");
+                       }
                        set {
-                               if(!Enum.IsDefined (typeof (PartChromeState), value))
-                                       throw new ArgumentException ("value");
-                               chromeState = value;
+                               ViewState ["ImportErrorMessage"] = value;
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsClosed 
+               {
+                       get {
+                               return isClosed;
                        }
                }
-               
-               //[PersonalizableAttribute ]
-               public override PartChromeType ChromeType {
-                       get { return chromeType; }
+
+               [MonoTODO("not virtual and no setter..")]
+               public bool IsShared 
+               {
+                       get {
+                               return false;
+                       }
+               }
+
+               [MonoTODO("not virtual and no setter..")]
+               public bool IsStandalone 
+               {
+                       get {
+                               return true;
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsStatic 
+               {
+                       get {
+                               return isStatic;
+                       }
+               }
+
+               [MonoTODO]
+               public virtual string Subtitle 
+               {
+                       get {
+                               return string.Empty;
+                       }
+               }
+
+               [MonoTODO ("why override?")]
+               public override string Title 
+               {
+                       get {
+                               return base.Title;
+                       }
                        set {
-                               if(!Enum.IsDefined (typeof (PartChromeType), value))
-                                       throw new ArgumentException ("value");
-                               chromeType = value;
+                               base.Title = value;
                        }
                }
 
-               [BrowsableAttribute (false), 
-               DesignerSerializationVisibilityAttribute (System.ComponentModel.DesignerSerializationVisibility.Hidden),
-               LocalizableAttribute (true)]                    
-               string IWebPart.Subtitle { 
-                       get { return subtitle; }
+               [MonoTODO]
+               public virtual string TitleIconImageUrl 
+               {
+                       get {
+                               return titleIconImageUrl;
+                       }
+                       set {
+                               titleIconImageUrl = value;
+                       }
                }
-       
-               [DefaultValueAttribute (""), 
-               EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design", 
-                               "System.Drawing.Design.UITypeEditor, System.Drawing") , 
-               WebCategoryAttribute ("Appearance of the Web Part"),
-               WebSysDescriptionAttribute ("Specifies URL of image which is displayed in WebPart's Catalog.")]
-               //UrlPropertyAttribute, PersonalizableAttribute
-               string IWebPart.CatalogIconImageUrl { 
-                       get { return catalogIconImageUrl; }
-                       set { catalogIconImageUrl = value; }
+
+               [MonoTODO]
+               public virtual string TitleUrl 
+               {
+                       get {
+                               return titleUrl;
+                       }
+                       set {
+                               titleUrl = value;
+                       }
                }
 
-               string IWebPart.Description { 
-                       get { return description; }
-                       set { description = value; }
+               public virtual WebPartVerbCollection Verbs 
+               {
+                       get {
+                               return verbs;
+                       }
                }
 
-               string IWebPart.Title { 
-                       get { return title; }
-                       set { title = value; }
+#if IWebEditableInterface
+               [MonoTODO]
+               public virtual object WebBrowsableObject 
+               {
+                       get {
+                       throw new NotImplementedException ();
+                       }
                }
+#endif
 
-               [DefaultValueAttribute (""),
-               EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design",
-                               "System.Drawing.Design.UITypeEditor, System.Drawing"),
-               WebCategoryAttribute ("Appearance of the Web Part"),
-               WebSysDescriptionAttribute ("Specifies URL of image which is displayed in WebPart's title bar.")]
-               //UrlPropertyAttribute, PersonalizableAttribute
-               string IWebPart.TitleIconImageUrl
+#if notyet
+               [MonoTODO]
+               protected WebPartManager WebPartManager 
                {
-                       get { return titleIconImageUrl; }
-                       set { titleIconImageUrl = value; }
+                       get {
+                       throw new NotImplementedException ();
+                       }
                }
+#endif
 
-               [DefaultValueAttribute (""),
-               EditorAttribute ("System.Web.UI.Design.UrlEditor, System.Design",
-                               "System.Drawing.Design.UITypeEditor, System.Drawing"),
-               WebCategoryAttribute ("Behavior of the Web Part"),
-               WebSysDescriptionAttribute ("Specifies URL of page, containing additional information about this WebPart.")]
-               //UrlPropertyAttribute, PersonalizableAttribute
-               string IWebPart.TitleUrl { 
-                       get { return titleUrl; }
-                       set { titleUrl = value; }
+               [MonoTODO ("why override?")]
+               public override Unit Width 
+               {
+                       get {
+                               return base.Width;
+                       }
+                       set {
+                               base.Width = value;
+                       }
                }
 
-               [BrowsableAttribute (false),
-               DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
-               WebPartVerbCollection IWebActionable.Verbs {
+#if notyet
+               [MonoTODO]
+               public WebPartZoneBase Zone 
+               {
                        get {
-                               if (verbCollection == null) {
-                                       verbCollection = new WebPartVerbCollection ();
-                               }
-                               return verbCollection;
+                       throw new NotImplementedException ();
+                       }
+               }
+#endif
+
+               [MonoTODO]
+               public int ZoneIndex 
+               {
+                       get {
+                               return zoneIndex;
                        }
                }
        }
+
 }
+
 #endif