2005-09-27 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Wed, 28 Sep 2005 02:23:46 +0000 (02:23 -0000)
committerChris Toshok <toshok@novell.com>
Wed, 28 Sep 2005 02:23:46 +0000 (02:23 -0000)
* Microsoft.Web.UI/ScriptManager.cs: implement things such that
things kinda work.

* Microsoft.Web.UI/Button.cs (AddAttributesToElement): call base
class method.
(InitializeTypeDescriptor): same.
(OnPreRender): same.

* Microsoft.Web.UI/Label.cs: new implementation.

* Microsoft.Web.UI/TextBox.cs: new implementation.

* Microsoft.Web.UI/ListView.cs: new implementation.

svn path=/trunk/mcs/; revision=50909

mcs/class/Microsoft.Web.Atlas/ChangeLog
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/Button.cs
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/Label.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/ListView.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/ScriptManager.cs
mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/TextBox.cs [new file with mode: 0644]

index c2e54b1c37705f94ce058e1c43038195ff5743a9..e3249e2c07e75e07a233215d8d360cb181b7d28b 100644 (file)
@@ -1,3 +1,19 @@
+2005-09-27  Chris Toshok  <toshok@ximian.com>
+
+       * Microsoft.Web.UI/ScriptManager.cs: implement things such that
+       things kinda work.
+
+       * Microsoft.Web.UI/Button.cs (AddAttributesToElement): call base
+       class method.
+       (InitializeTypeDescriptor): same.
+       (OnPreRender): same.
+
+       * Microsoft.Web.UI/Label.cs: new implementation.
+
+       * Microsoft.Web.UI/TextBox.cs: new implementation.
+
+       * Microsoft.Web.UI/ListView.cs: new implementation.
+       
 2005-09-16  Chris Toshok  <toshok@ximian.com>
 
        * Test/Microsoft.Web.UI/LabelTest.cs: new test.
index c6b78206e31cdc86b3c1783a646f5ac141b603cb..40fe06c2c16e5bf2f31135010c2c1c66575b1b76 100644 (file)
@@ -44,14 +44,17 @@ namespace Microsoft.Web.UI
 
                protected override void AddAttributesToElement (ScriptTextWriter writer)
                {
+                       base.AddAttributesToElement (writer);
                }
 
                protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
                {
+                       base.InitializeTypeDescriptor (typeDescriptor);
                }
 
                protected override void OnPreRender (EventArgs e)
                {
+                       base.OnPreRender(e);
                }
 
                protected override void Render (HtmlTextWriter writer)
diff --git a/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/Label.cs b/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/Label.cs
new file mode 100644 (file)
index 0000000..1d57f6f
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Microsoft.Web.UI.Label
+//
+// Author:
+//   Chris Toshok (toshok@ximian.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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// 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
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Web.UI;
+using Microsoft.Web;
+
+namespace Microsoft.Web.UI
+{
+       public class Label : ScriptControl
+       {
+               public Label ()
+               {
+               }
+
+               protected override void AddParsedSubObject (object obj)
+               {
+                       base.AddParsedSubObject (obj);
+               }
+
+               protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
+               {
+                       base.InitializeTypeDescriptor (typeDescriptor);
+
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("text", ScriptType.String, false, "Text"));
+               }
+
+               protected override void OnPreRender (EventArgs e)
+               {
+                       base.OnPreRender (e);
+
+                       ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
+                       mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
+                       mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
+               }
+
+               protected override void Render (HtmlTextWriter writer)
+               {
+               }
+
+               public override string TagName {
+                       get {
+                               return "label";
+                       }
+               }
+
+               public string Text {
+                       get {
+                               object o = ViewState["Text"];
+                               if (o == null)
+                                       return "";
+                               return (string)o;
+                       }
+                       set {
+                               if (value == null)
+                                       ViewState.Remove ("Text");
+                               else
+                                       ViewState["Text"] = value;
+                       }
+               }
+       }
+
+}
+
+#endif
diff --git a/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/ListView.cs b/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/ListView.cs
new file mode 100644 (file)
index 0000000..4189e52
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Microsoft.Web.UI.ListView
+//
+// Author:
+//   Chris Toshok (toshok@ximian.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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// 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
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Web.UI;
+using Microsoft.Web;
+
+namespace Microsoft.Web.UI
+{
+       public class ListView : ScriptControl
+       {
+               ITemplate emptyTemplate;
+               ITemplate layoutTemplate;
+               
+               public ListView ()
+               {
+               }
+
+               protected override void AddAttributesToElement (ScriptTextWriter writer)
+               {
+                       base.AddAttributesToElement (writer);
+               }
+
+               protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
+               {
+                       base.InitializeTypeDescriptor (typeDescriptor);
+
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("alternatingItemCssClass", ScriptType.String, false, "AlternatingItemCssClass"));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("data", ScriptType.Object, false, ""));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("length", ScriptType.Number, true, ""));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("layoutTemplate", ScriptType.Object, false, ""));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemCssClass", ScriptType.String, false, "ItemCssClass"));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemTemplateParentElementId", ScriptType.String, false, ""));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("separatorTemplate", ScriptType.Object, false, ""));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("emptyTemplate", ScriptType.Object, false, ""));
+               }
+
+               protected override void OnPreRender (EventArgs e)
+               {
+                       base.OnPreRender (e);
+
+                       ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
+                       mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
+                       mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
+               }
+
+               protected override void Render (HtmlTextWriter writer)
+               {
+               }
+
+               protected override void RenderScriptTagContents (ScriptTextWriter writer)
+               {
+                       base.RenderScriptTagContents (writer);
+
+                       writer.WriteStartElement ("layoutTemplate");
+                       writer.WriteStartElement ("template");
+                       writer.WriteAttributeString ("layoutElement", ID + "_layoutTemplate"); // XXX ?
+                       writer.WriteEndElement (); // template
+                       writer.WriteEndElement (); // layoutTemplate
+
+                       writer.WriteStartElement ("itemTemplate");
+                       writer.WriteEndElement (); // itemTemplate
+               }
+
+               public string AlternatingItemCssClass {
+                       get {
+                               object o = ViewState["AlternatingItemCssClass"];
+                               if (o == null)
+                                       return "";
+                               return (string)o;
+                       }
+                       set {
+                               ViewState["AlternatingItemCssClass"] = value;
+                       }
+               }
+
+               public ITemplate EmptyTemplate {
+                       get {
+                               return emptyTemplate;
+                       }
+                       set {
+                               emptyTemplate = value;
+                       }
+               }
+
+               public string ItemCssClass {
+                       get {
+                               object o = ViewState["ItemCssClass"];
+                               if (o == null)
+                                       return "";
+                               return (string)o;
+                       }
+                       set {
+                               ViewState["ItemCssClass"] = value;
+                       }
+               }
+
+               public string ItemTemplateControlID {
+                       get {
+                               object o = ViewState["ItemTemplateControlID"];
+                               if (o == null)
+                                       return "";
+                               return (string)o;
+                       }
+                       set {
+                               ViewState["ItemTemplateControlID"] = value;
+                       }
+               }
+
+               public ITemplate LayoutTemplate {
+                       get {
+                               return layoutTemplate;
+                       }
+                       set {
+                               layoutTemplate = value;
+                       }
+               }
+
+               public string SeparatorTemplateControlID {
+                       get {
+                               object o = ViewState["SeparatorTemplateControlID"];
+                               if (o == null)
+                                       return "";
+                               return (string)o;
+                       }
+                       set {
+                               ViewState["SeparatorTemplateControlID"] = value;
+                       }
+               }
+
+               public override string TagName {
+                       get {
+                               return "listView";
+                       }
+               }
+       }
+
+}
+
+#endif
index 12b287c2fcb75258ed51ebc27fb31adb1319ae91..ee5e5a0a185ae17ec1f0ae252c6aa34c5f53f31a 100644 (file)
 #if NET_2_0
 
 using System;
+using System.Collections;
+using System.Collections.Generic;
 using System.Web.UI;
 
 namespace Microsoft.Web.UI
 {
-       public class ScriptManager : Control
+       class ScriptReference
        {
+               public string scriptPath;
+               public bool commonScript;
+       }
+
+       class ScriptNamespace
+       {
+               public string prefix;
+               public string namespaceUri;
+       }
+
+       internal class XmlScriptNode : Control
+       {
+               ScriptManager mgr;
+
+               public XmlScriptNode (ScriptManager mgr)
+               {
+                       this.mgr = mgr;
+               }
+
+               protected override void Render (HtmlTextWriter writer)
+               {
+                       ScriptTextWriter scriptwriter = new ScriptTextWriter (writer);
+
+                       scriptwriter.WriteStartElement ("script");
+                       scriptwriter.WriteAttributeString ("type", "text/xml-script");
+                       scriptwriter.WriteStartElement ("page");
+                       scriptwriter.WriteAttributeString ("xmlns:script", "http://schemas.microsoft.com/xml-script/2005");
+
+                       scriptwriter.WriteStartElement ("components");
+                       foreach (IScriptComponent component in mgr.Components) {
+                               if (((IScriptObject)component).Owner == null) // only render the toplevel script objects
+                                       component.RenderScript (scriptwriter);
+                       }
+                       scriptwriter.WriteEndElement (); // components 
+
+                       scriptwriter.WriteStartElement ("references");
+                       foreach (string scriptPath in mgr.ScriptRefs.Keys) {
+                               if ((bool)mgr.ScriptRefs[scriptPath]) {
+                                       scriptwriter.WriteStartElement ("add");
+                                       scriptwriter.WriteAttributeString ("src", scriptPath);
+                                       scriptwriter.WriteEndElement ();
+                               }
+                       }
+                       scriptwriter.WriteEndElement (); //references
+
+                       scriptwriter.WriteEndElement (); // page
+                       scriptwriter.WriteEndElement (); // script
+
+                       ScriptManager.Pages.Remove (Page);
+               }
+       }
+
+       public class ScriptManager : Control, INamingContainer, IScriptComponentContainer
+       {
+               internal ScriptComponentCollection Components;
+               internal Hashtable ScriptRefs;
+               internal List<ScriptNamespace> Namespaces;
+
+               internal static Hashtable Pages = new Hashtable();
+
                public ScriptManager ()
                {
-                       throw new NotImplementedException ();
+                       Components = new ScriptComponentCollection();
+                       Namespaces = new List<ScriptNamespace>();
+                       ScriptRefs = new Hashtable();
+               }
+
+               protected override void OnInit (EventArgs e)
+               {
+                       base.OnInit(e);
+
+                       if (Page != null) {
+                               Pages.Add (Page, this);
+                               Page.Controls.Add (new XmlScriptNode(this));
+                       }
                }
 
                public static ScriptManager GetCurrentScriptManager (Page page)
                {
-                       throw new NotImplementedException ();
+                       return (ScriptManager)Pages[page];
                }
 
                public void RegisterComponent (IScriptComponent component)
                {
-                       throw new NotImplementedException ();
+                       Components.Add (component);
                }
 
                public void RegisterScriptNamespace (string prefix, string namespaceUri)
                {
-                       throw new NotImplementedException ();
+                       ScriptNamespace ns = new ScriptNamespace ();
+                       ns.prefix = prefix;
+                       ns.namespaceUri = namespaceUri;
+                       Namespaces.Add (ns);
                }
 
                public void RegisterScriptReference (string scriptPath, bool commonScript)
                {
-                       throw new NotImplementedException ();
+                       if (ScriptRefs.Contains (scriptPath))
+                               return;
+
+                       ScriptRefs.Add (scriptPath, commonScript);
                }
 
                public void RegisterScriptReference (string scriptPath)
                {
-                       throw new NotImplementedException ();
+                       RegisterScriptReference (scriptPath, false);
                }
        }
 }
diff --git a/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/TextBox.cs b/mcs/class/Microsoft.Web.Atlas/Microsoft.Web.UI/TextBox.cs
new file mode 100644 (file)
index 0000000..660c97f
--- /dev/null
@@ -0,0 +1,180 @@
+//
+// Microsoft.Web.UI.TextBox
+//
+// Author:
+//   Chris Toshok (toshok@ximian.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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// 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
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Web.UI;
+using Microsoft.Web;
+
+namespace Microsoft.Web.UI
+{
+       public class TextBox : ScriptControl
+       {
+               public TextBox ()
+               {
+               }
+
+               protected override void AddAttributesToElement (ScriptTextWriter writer)
+               {
+                       base.AddAttributesToElement (writer);
+               }
+
+               protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
+               {
+                       base.InitializeTypeDescriptor (typeDescriptor);
+
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("validators", ScriptType.Array, true, "Validators"));
+                       typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("text", ScriptType.String, false, "Text"));
+               }
+
+               protected override void OnPreRender (EventArgs e)
+               {
+                       base.OnPreRender (e);
+
+                       ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
+                       mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
+                       mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
+               }
+
+               protected override void Render (HtmlTextWriter writer)
+               {
+               }
+
+               protected override void RenderScriptTagContents (ScriptTextWriter writer)
+               {
+                       base.RenderScriptTagContents (writer);
+
+                       if (AutoCompletionServiceMethod != ""
+                           && AutoCompletionServiceUrl != "") {
+                               writer.WriteStartElement ("behaviors");
+                               writer.WriteStartElement ("autoComplete");
+                               writer.WriteAttributeString ("serviceURL", AutoCompletionServiceUrl);
+                               writer.WriteAttributeString ("serviceMethod", AutoCompletionServiceMethod);
+                               if (AutoCompletionMinimumPrefixLength != 0)
+                                       writer.WriteAttributeString ("minimumPrefixLength", AutoCompletionMinimumPrefixLength.ToString());
+
+                               writer.WriteAttributeString ("completionList", ID + "__autocomplete"); // XXX ?
+
+                               writer.WriteEndElement (); // autoComplete
+                               writer.WriteEndElement (); // behaviors
+                       }
+                               
+               }
+
+               public int AutoCompletionInterval {
+                       get {
+                               object o = ViewState["AutoCompletionInterval"];
+                               if (o == null)
+                                       return 1000;
+                               return (int)o;
+                       }
+                       set {
+                               ViewState["AutoCompletionInterval"] = value;
+                       }
+               }
+
+               [MonoTODO]
+               public int AutoCompletionMinimumPrefixLength {
+                       get {
+                               object o = ViewState["AutoCompletionMinimumPrefixLength"];
+                               if (o == null)
+                                       return 3;
+                               return (int)o;
+                       }
+                       set {
+                               ViewState["AutoCompletionMinimumPrefixLength"] = value;
+                       }
+               }
+
+               public string AutoCompletionServiceMethod {
+                       get {
+                               return (string)ViewState["AutoCompletionServiceMethod"];
+                       }
+                       set {
+                               ViewState["AutoCompletionServiceMethod"] = value;
+                       }
+               }
+
+               public string AutoCompletionServiceUrl {
+                       get {
+                               return (string)ViewState["AutoCompletionServiceUrl"];
+                       }
+                       set {
+                               ViewState["AutoCompletionServiceUrl"] = value;
+                       }
+               }
+
+               public int AutoCompletionSetCount {
+                       get {
+                               object o = ViewState["AutoCompletionSetCount"];
+                               if (o == null)
+                                       return 10;
+                               return (int)o;
+                       }
+                       set {
+                               ViewState["AutoCompletionSetCount"] = value;
+                       }
+               }
+
+               public int Size {
+                       get {
+                               object o = ViewState["Size"];
+                               if (o == null)
+                                       return 0;
+                               return (int)o;
+                       }
+                       set {
+                               ViewState["Size"] = value;
+                       }
+               }
+
+               public override string TagName {
+                       get {
+                               return "textBox";
+                       }
+               }
+
+               public string Text {
+                       get {
+                               object o = ViewState["Text"];
+                               if (o == null)
+                                       return "";
+                               return (string)o;
+                       }
+                       set {
+                               ViewState["Text"] = value;
+                       }
+               }
+       }
+
+}
+
+#endif