flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: git commit: [flex-sdk] [refs/heads/develop] - FLEX-33524: Added convenience feature to enable/disable buttons in a ButtonBar/TabBar.
Date Fri, 03 May 2013 03:44:08 GMT
Hey Mark,

Do you think it is worth trying to have all of these APIs call a common
function?  I think I'm seeing the same code more than once.


On 5/2/13 4:48 PM, "mkessler@apache.org" <mkessler@apache.org> wrote:

> Updated Branches:
>   refs/heads/develop 7d20cec89 -> 3053c3295
> 
> 
> FLEX-33524: Added convenience feature to enable/disable buttons in a
> ButtonBar/TabBar.
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/3053c329
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/3053c329
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/3053c329
> 
> Branch: refs/heads/develop
> Commit: 3053c3295e6c14b291e2aa5a947b1d88e9650a6f
> Parents: 7d20cec
> Author: Mark Kessler <KesslerConsulting@gmail.com>
> Authored: Thu May 2 19:41:46 2013 -0400
> Committer: Mark Kessler <KesslerConsulting@gmail.com>
> Committed: Thu May 2 19:44:51 2013 -0400
> 
> ----------------------------------------------------------------------
>  .../components/supportClasses/ButtonBarBase.as     |  198 ++++++++++++++-
>  1 files changed, 197 insertions(+), 1 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/3053c329/frameworks/proje
> cts/spark/src/spark/components/supportClasses/ButtonBarBase.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.
> as 
> b/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.
> as
> index 233a210..b41504e 100644
> --- 
> a/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.
> as
> +++ 
> b/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.
> as
> @@ -513,7 +513,203 @@ public class ButtonBarBase extends ListBase
>      //  Methods
>      //
>      
> //--------------------------------------------------------------------------
> -    
> +
> +    /**
> +    *  Disable a ButtonBar's Button referencing it by the ButtonBarbutton's
> <code>label</code>.
> +    *
> +    *  <p>The function takes a single argument which is the ButtonBarButtons
> label.</p>
> +    *  <pre>myButtonBar.disableButton("My Button Label")</pre>
> +    *
> +    *  @param labelValue Is the ButtonBarButton label
> +    *  @param fieldName Field used for comparing the label
> +    *
> +    *  @langversion 3.0
> +    *  @playerversion Flash 11.1
> +    *  @playerversion AIR 3.4
> +    *  @productversion Flex 4.10
> +    */
> +    public function disableButton(labelValue:String, fieldName:String =
> ""):void
> +    {
> +        var btnCurrent:ButtonBarButton = null;
> +        var buttonIndex:int = -1;
> +
> +
> +        if (!dataGroup || labelValue == "" || labelValue == null)
> +        {
> +            return;
> +        }
> +
> +        if (fieldName == "" || fieldName == null)
> +        {
> +            buttonIndex = findRowIndex(labelField, labelValue);
> +        }
> +        else
> +        {
> +            buttonIndex = findRowIndex(fieldName, labelValue);
> +        }
> +
> +        if (buttonIndex == -1)
> +        {
> +            return;
> +        }
> +
> +
> +        btnCurrent = dataGroup.getElementAt(buttonIndex) as ButtonBarButton;
> +        btnCurrent.enabled = false;
> +    }
> +
> +
> +    /**
> +    *  Disables several of a ButtonBar's Buttons, referencing them by the
> ButtonBarbutton's <code>label</code>.
> +    *
> +    *  <p>The function takes a single argument which is the ButtonBarButtons
> label.</p>
> +    *  <pre>myButtonBar.disableButtons(["My Button Label1", "My
> Label2"])</pre>
> +    *
> +    *  @param labelValues Is an array of ButtonBarButton labels.
> +    *  @param fieldName Field used for comparing the label
> +    *
> +    *  @langversion 3.0
> +    *  @playerversion Flash 11.1
> +    *  @playerversion AIR 3.4
> +    *  @productversion Flex 4.10
> +    */
> +    public function disableButtons(labelValues:Array, fieldName:String =
> ""):void
> +    {
> +        var btnCurrent:ButtonBarButton = null;
> +        var buttonIndices:Array;
> +        var indicesTotal:uint = 0;
> +        var loopingIndex:uint = 0;
> +
> +
> +        if (!dataGroup || labelValues.length < 1 || labelValues == null)
> +        {
> +            return;
> +        }
> +
> +        if (fieldName == "" || fieldName == null)
> +        {
> +            buttonIndices = findRowIndices(labelField, labelValues);
> +        }
> +        else
> +        {
> +            buttonIndices = findRowIndices(fieldName, labelValues);
> +        }
> +
> +
> +        indicesTotal = buttonIndices.length
> +
> +        if (indicesTotal == 0)
> +        {
> +            return;
> +        }
> +
> +        
> +        for (loopingIndex; loopingIndex < indicesTotal; loopingIndex++)
> +        {
> +            btnCurrent = dataGroup.getElementAt(buttonIndices[loopingIndex])
> as ButtonBarButton;
> +            btnCurrent.enabled = false;
> +        }
> +    }
> +
> +
> +    /**
> +    *  Enable a ButtonBar's Button referencing it by the ButtonBarbutton's
> <code>label</code>.
> +    *
> +    *  <p>The function takes a single argument which is the ButtonBarButtons
> label.</p>
> +    *  <pre>myButtonBar.enableButton("My Button Label")</pre>
> +    *
> +    *  @param labelValue Is the ButtonBarButton label
> +    *  @param fieldName Field used for comparing the label
> +    *
> +    *  @langversion 3.0
> +    *  @playerversion Flash 11.1
> +    *  @playerversion AIR 3.4
> +    *  @productversion Flex 4.10
> +    */
> +    public function enableButton(labelValue:String, fieldName:String =
> ""):void
> +    {
> +        var btnCurrent:ButtonBarButton = null;
> +        var buttonIndex:int = -1;
> +
> +
> +        if (!dataGroup || labelValue == "" || labelValue == null)
> +        {
> +            return;
> +        }
> +
> +        if (fieldName == "" || fieldName == null)
> +        {
> +            buttonIndex = findRowIndex(labelField, labelValue);
> +        }
> +        else
> +        {
> +            buttonIndex = findRowIndex(fieldName, labelValue);
> +        }
> +
> +        if (buttonIndex == -1)
> +        {
> +            return;
> +        }
> +
> +
> +        btnCurrent = dataGroup.getElementAt(buttonIndex) as ButtonBarButton;
> +        btnCurrent.enabled = true;
> +    }
> +
> +
> +    /**
> +    *  Disables several of a ButtonBar's Buttons, referencing them by the
> ButtonBarbutton's <code>label</code>.
> +    *
> +    *  <p>The function takes a single argument which is the ButtonBarButtons
> label.</p>
> +    *  <pre>myButtonBar.enableButtons(["My Button Label1", "My
> Label2"])</pre>
> +    *
> +    *  @param labelValues Is an array of ButtonBarButton labels.
> +    *  @param fieldName Field used for comparing the label
> +    *
> +    *  @langversion 3.0
> +    *  @playerversion Flash 11.1
> +    *  @playerversion AIR 3.4
> +    *  @productversion Flex 4.10
> +    */
> +    public function enableButtons(labelValues:Array, fieldName:String =
> ""):void
> +    {
> +        var btnCurrent:ButtonBarButton = null;
> +        var buttonIndices:Array;
> +        var indicesTotal:uint = 0;
> +        var loopingIndex:uint = 0;
> +
> +
> +        if (!dataGroup || labelValues.length < 1 || labelValues == null)
> +        {
> +            return;
> +        }
> +
> +        if (fieldName == "" || fieldName == null)
> +        {
> +            buttonIndices = findRowIndices(labelField, labelValues);
> +        }
> +        else
> +        {
> +            buttonIndices = findRowIndices(fieldName, labelValues);
> +        }
> +
> +
> +        indicesTotal = buttonIndices.length
> +
> +        if (indicesTotal == 0)
> +        {
> +            return;
> +        }
> +
> +        
> +        for (loopingIndex; loopingIndex < indicesTotal; loopingIndex++)
> +        {
> +            btnCurrent = dataGroup.getElementAt(buttonIndices[loopingIndex])
> as ButtonBarButton;
> +            btnCurrent.enabled = true;
> +        }
> +    }
> +
> +
>      /**
>       *  @private
>       */
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Mime
View raw message