Author: husted
Date: Thu Oct 20 09:02:35 2005
New Revision: 326929

URL: http://svn.apache.org/viewcvs?rev=326929&view=rev
Log:
OVR-23 
* Add MessageLabel class and several "strategy" classes that modify the initial 
defaults for common cases. 
* Update GetMessages to observe MessageLabel properties. 
* Add MessageLabel (and subsclasses) to the root Bind method. 
** Note that Labels and MessageLabels can be bound from the Criteria, like any 
other control.

Added:
    struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/HintLabel.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/TextLabel.cs
Modified:
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb
    struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
Binary files - no diff available.

Added: struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs?rev=326929&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs Thu Oct 20 09:02:35 
2005
@@ -0,0 +1,27 @@
+namespace Nexus.Web
+{
+       /// <summary>
+       /// Extend MessageLabel to respond only to the View_Alert event 
+       /// and use an alternate suffix.
+       /// </summary>
+       public class AlertLabel : MessageLabel
+       {
+               
+               /// <summary>
+               /// Default suffix for NameLabel IDs ["_alert"].
+               /// </summary>
+               public const string ALERT_SUFFIX = "_alert";
+               
+               /// <summary>
+               /// Set the defaults for this subclass.
+               /// </summary>
+               public AlertLabel()
+               {
+                       Suffix = ALERT_SUFFIX;
+                       Resource = false;
+                       Required = false;
+                       View_Hint = false;
+               }
+       }
+}
+

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Thu Oct 20 
09:02:35 2005
@@ -863,13 +863,14 @@
                /// 
                private void Page_Load(object sender, EventArgs e)
                {
-                       Grid.AutoGenerateColumns = false;
-                       Grid.EditItemIndex = list_ItemIndex;
-                       Grid.CancelCommand += new 
DataGridCommandEventHandler(list_Quit);
-                       Grid.EditCommand += new 
DataGridCommandEventHandler(list_Edit);
-                       Grid.UpdateCommand += new 
DataGridCommandEventHandler(list_Save);
-                       Grid.ItemCommand += new 
DataGridCommandEventHandler(List_Item);
-                       Grid.PageIndexChanged += new 
DataGridPageChangedEventHandler(list_PageIndexChanged);
+                       DataGrid grid = Grid;
+                       grid.AutoGenerateColumns = false;
+                       grid.EditItemIndex = list_ItemIndex;
+                       grid.CancelCommand += new 
DataGridCommandEventHandler(list_Quit);
+                       grid.EditCommand += new 
DataGridCommandEventHandler(list_Edit);
+                       grid.UpdateCommand += new 
DataGridCommandEventHandler(list_Save);
+                       grid.ItemCommand += new 
DataGridCommandEventHandler(List_Item);
+                       grid.PageIndexChanged += new 
DataGridPageChangedEventHandler(list_PageIndexChanged);
                        if (this.Visible) Open();
                }
 

Added: struts/sandbox/trunk/overdrive/Nexus/Web/HintLabel.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/HintLabel.cs?rev=326929&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/HintLabel.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/HintLabel.cs Thu Oct 20 09:02:35 
2005
@@ -0,0 +1,27 @@
+namespace Nexus.Web
+{
+       /// <summary>
+       /// Extend MessageLabel to respond only to the View_Hint event 
+       /// and use an alternate suffix.
+       /// </summary>
+       public class HintLabel : MessageLabel
+       {
+               
+               /// <summary>
+               /// Default suffix for NameLabel IDs ["_hint"].
+               /// </summary>
+               public const string HINT_SUFFIX = "_hint";
+               
+               /// <summary>
+               /// Set the defaults for this subclass.
+               /// </summary>
+               public HintLabel()
+               {
+                       Suffix = HINT_SUFFIX;
+                       Resource = false;
+                       Required = false;
+                       View_Alert = false;
+               }
+       }
+}
+

Added: struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs?rev=326929&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs Thu Oct 20 
09:02:35 2005
@@ -0,0 +1,128 @@
+using System.Web.UI.WebControls;
+
+namespace Nexus.Web
+{
+
+       /// <summary>
+       /// Present dynamic message by consulting with Message Resources 
+       /// or handling an event.
+       /// </summary>
+       public class MessageLabel : Label
+       {
+
+               /// <summary>
+               /// Field for EntryID property.
+               /// </summary>
+               /// 
+               private string _EntryID;
+
+               /// <summary>
+               /// Name of corresponding entry.
+               /// </summary>
+               /// <remarks><p>
+               /// If this is not set, 
+               /// the EntryId is obtained by truncating the Suffix 
+               /// from the ID.
+               /// </p></remarks>
+               public string EntryID
+               {
+                       get
+                       {
+                               if ((_EntryID==null) || (_EntryID.Length==0))
+                               {
+                                       int v = ID.LastIndexOf(Suffix);
+                                       _EntryID = ID.Substring(0, v);
+                               }
+                               return _EntryID;
+                       }
+                       set { _EntryID = value;}
+               }
+
+               public const string MESSAGE_SUFFIX = "_msg";
+
+               /// <summary>
+               /// Field for Suffix property.
+               /// </summary>
+               /// 
+               private string _Suffix = MESSAGE_SUFFIX;
+
+               /// <summary>
+               /// Suffix to trim from ID to obtain EntryID [MESSAGE_SUFFIX].
+               /// </summary>
+               /// 
+               public string Suffix
+               {
+                       get { return _Suffix; }
+                       set { _Suffix = value;}
+               }
+
+               /// <summary>
+               /// Field for Resource property.
+               /// </summary>
+               /// 
+               private bool _Resource = true;
+
+               /// <summary>
+               /// If true, populate from Message Resources [TRUE].
+               /// </summary>
+               /// 
+               public bool Resource
+               {
+                       get { return _Resource; }
+                       set { _Resource = value;}
+               }
+               
+               /// <summary>
+               /// Field for Required property.
+               /// </summary>
+               /// 
+               private bool _Required = false;
+
+               /// <summary>
+               /// If true, throw exception if Resource==true 
+               /// and message not in resource [FALSE].
+               /// </summary>
+               /// 
+               public bool Required
+               {
+                       get { return _Required; }
+                       set { _Required = value;}
+               }
+
+               /// <summary>
+               /// Field for View_Hint property.
+               /// </summary>
+               /// 
+               private bool _View_Hint = true;
+
+               /// <summary>
+               /// If true, register for View_Alert event 
+               /// and display any alert for corresponding field [TRUE].
+               /// </summary>
+               /// 
+               public bool View_Hint
+               {
+                       get { return _View_Hint; }
+                       set { _View_Hint = value;}
+               }
+
+               /// <summary>
+               /// Field for View_Alert property.
+               /// </summary>
+               /// 
+               private bool _View_Alert = true;
+
+               /// <summary>
+               /// If true, register for View_Hint event 
+               /// and display any hint for corresponding field [TRUE].
+               /// </summary>
+               /// 
+               public bool View_Alert
+               {
+                       get { return _View_Alert; }
+                       set { _View_Alert = value;}
+               }
+
+       }
+               
+}

Added: struts/sandbox/trunk/overdrive/Nexus/Web/TextLabel.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/TextLabel.cs?rev=326929&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/TextLabel.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/TextLabel.cs Thu Oct 20 09:02:35 
2005
@@ -0,0 +1,26 @@
+namespace Nexus.Web
+{
+       /// <summary>
+       /// Extend MessageLabel to ignore runtime events,  
+       /// require an entry, and use an alternate suffix.
+       /// </summary>
+       public class TextLabel : MessageLabel
+       {
+               
+               /// <summary>
+               /// Default suffix for NameLabel IDs ["_label"].
+               /// </summary>
+               public const string TEXT_SUFFIX = "_label";
+               
+               /// <summary>
+               /// Set the defaults for this subclass.
+               /// </summary>
+               public TextLabel()
+               {
+                       Suffix = TEXT_SUFFIX;
+                       Required = true;
+                       View_Hint = false;
+                       View_Alert = false;
+               }
+       }
+}

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs Thu Oct 20 
09:02:35 2005
@@ -52,7 +52,8 @@
                /// <param name="id">The full id, including prefix and 
suffix.</param>
                /// <param name="prefix">The prefix to omit.</param>
                /// <param name="suffix">The suffix to omit.</param>
-               /// <returns></returns>
+               /// <returns>ID for corresponding entry</returns>
+               /// 
                private string RootId(string id, string prefix, string suffix)
                {
                        int v = id.LastIndexOf(suffix);
@@ -62,10 +63,11 @@
                }
 
                /// <summary>
-               /// Trim Sany QL wildcards that may have been added to a search 
string.
+               /// Trim any SQL wildcards that may have been added to a search 
string.
                /// </summary>
                /// <param name="input">String to trim</param>
                /// <returns>Input without SQL wildcards</returns>
+               /// 
                protected string TrimWildCards(string input)
                {
                        string trimmed = null;
@@ -143,6 +145,18 @@
                }
 
                /// <summary>
+               /// Return true if control is a MessageLabel 
+               /// or MessageLabel subclass.
+               /// </summary>
+               /// <param name="control">Control to test.</param>
+               /// <returns>True if control is a NameLabel</returns>
+               /// 
+               protected bool IsMessageLabel(Control control)
+               {
+                       return (control is MessageLabel);
+               }
+
+               /// <summary>
                /// Return true if control is a List Control or one of the 
standard subclasses.
                /// </summary>
                /// <param name="control">Control to test.</param>
@@ -301,7 +315,8 @@
                {
                        IViewHelper helper = Catalog.GetHelperFor(command);
                        helper.Profile = Profile;
-                       // helper;
+                       // IDictionary criteria = Profile.Criteria;
+                       // helper.Read(criteria);
                        return helper;
                }
 
@@ -322,6 +337,13 @@
                                        object v = dictionary[ToColumn(x.ID, 
prefix)];
                                        if (v != null) x.Text = v.ToString();
                                }
+                               if (IsMessageLabel(t))
+                               {
+                                       MessageLabel x = (MessageLabel) t;
+                                       object v = dictionary[ToColumn(x.ID, 
prefix)];
+                                       if (v != null) x.Text = v.ToString();
+                                       continue;
+                               }
                                if (IsLabel(t))
                                {
                                        Label x = (Label) t;
@@ -538,10 +560,17 @@
                {
                        foreach (Control t in controls)
                        {
-                               if (IsLabel(t))
+                               if (IsMessageLabel(t))
                                {
-                                       Label x = (Label) t;
-                                       x.Text = GetMessage(x.ID);
+                                       MessageLabel x = (MessageLabel) t;
+                                       if (x.Resource) try
+                                       {
+                                               x.Text = GetMessage(x.ID);      
                                        
+                                       }
+                                       catch (Exception e)
+                                       {
+                                               if (x.Required)  throw(e);
+                                       }
                                        continue;
                                }
                                if (IsButton(t))

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj?rev=326929&r1=326928&r2=326929&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj Thu Oct 20 09:02:35 2005
@@ -114,6 +114,11 @@
         <Files>
             <Include>
                 <File
+                    RelPath = "AlertLabel.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "AssemblyInfo.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -166,13 +171,28 @@
                     BuildAction = "EmbeddedResource"
                 />
                 <File
+                    RelPath = "HintLabel.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "IViewControl.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "MessageLabel.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Messages.resx"
                     BuildAction = "EmbeddedResource"
+                />
+                <File
+                    RelPath = "TextLabel.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
                 />
                 <File
                     RelPath = "ViewControl.ascx"



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to