flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mkess...@apache.org
Subject git commit: [flex-sdk] [refs/heads/develop] - FLEX-33524: Combined a few methods and reduced redundant code.
Date Sun, 05 May 2013 11:42:08 GMT
Updated Branches:
  refs/heads/develop ac89b97c2 -> 068c787f1


FLEX-33524: Combined a few methods and reduced redundant code.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/068c787f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/068c787f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/068c787f

Branch: refs/heads/develop
Commit: 068c787f19000b29478be8568582c2f725a2d5b7
Parents: ac89b97
Author: Mark Kessler <KesslerConsulting@gmail.com>
Authored: Sun May 5 07:39:08 2013 -0400
Committer: Mark Kessler <KesslerConsulting@gmail.com>
Committed: Sun May 5 07:41:13 2013 -0400

----------------------------------------------------------------------
 .../components/supportClasses/ButtonBarBase.as     |  142 ++-------------
 1 files changed, 20 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/068c787f/frameworks/projects/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 b41504e..ab5a28e 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.as
@@ -515,108 +515,45 @@ public class ButtonBarBase extends ListBase
     //--------------------------------------------------------------------------
 
     /**
-    *  Disable a ButtonBar's Button referencing it by the ButtonBarbutton's <code>label</code>.

+    *  Gets the index for 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.disableButton("My Button Label")</pre>
+    *  <p>The method takes an array of ButtonBarButtons label and an optional field
name.</p>
+    *  <pre>myButtonBar.getButtonIndices(["My Button Label1", "My Label2"])</pre>
     *
-    *  @param labelValue Is the ButtonBarButton label
-    *  @param fieldName Field used for comparing the label
+    *  @param labelValues Are the ButtonBarButton labels to find.
+    *  @param fieldName Field used for comparing the label (optional)
     *
     *  @langversion 3.0
     *  @playerversion Flash 11.1
     *  @playerversion AIR 3.4
     *  @productversion Flex 4.10
     */
-    public function disableButton(labelValue:String, fieldName:String = ""):void
+    public function getButtonIndices(labelValues:Array, fieldName:String = ""):Array
     {
-        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;
+            return [];
         }
 
         if (fieldName == "" || fieldName == null)
         {
-            buttonIndices = findRowIndices(labelField, labelValues);
+            return 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;
+            return findRowIndices(fieldName, labelValues);
         }
     }
 
 
     /**
-    *  Enable a ButtonBar's Button referencing it by the ButtonBarbutton's <code>label</code>.

+    *  Changes the <code>enabled</code> property of 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>
+    *  <p>The method takes a single ButtonBarButton label, a new <code>enabled</code>
property value, and an optional field name to search for.</p>
+    *  <pre>myButtonBar.setButtonEnabled("My Button Label", false)</pre>
     *
     *  @param labelValue Is the ButtonBarButton label
     *  @param fieldName Field used for comparing the label
@@ -626,42 +563,17 @@ public class ButtonBarBase extends ListBase
     *  @playerversion AIR 3.4
     *  @productversion Flex 4.10
     */
-    public function enableButton(labelValue:String, fieldName:String = ""):void
+    public function setButtonEnabled(labelValue:String, enabledValue:Boolean, 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;
+        setButtonsEnabled([labelValue], enabledValue, fieldName);
     }
 
 
     /**
     *  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>
+    *  <p>The method takes an array of ButtonBarButton labels, a new <code>enabled</code>
property value, and an optional field name to search for.</p>
+    *  <pre>myButtonBar.setButtonsEnabled(["My Button Label1", "My Label2"], false)</pre>
     *
     *  @param labelValues Is an array of ButtonBarButton labels.
     *  @param fieldName Field used for comparing the label
@@ -671,7 +583,7 @@ public class ButtonBarBase extends ListBase
     *  @playerversion AIR 3.4
     *  @productversion Flex 4.10
     */
-    public function enableButtons(labelValues:Array, fieldName:String = ""):void
+    public function setButtonsEnabled(labelValues:Array, enabledValue:Boolean, fieldName:String
= ""):void
     {
         var btnCurrent:ButtonBarButton = null;
         var buttonIndices:Array;
@@ -679,22 +591,8 @@ public class ButtonBarBase extends ListBase
         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
+        buttonIndices = getButtonIndices(labelValues, fieldName);
+        indicesTotal = buttonIndices.length;
 
         if (indicesTotal == 0)
         {
@@ -705,7 +603,7 @@ public class ButtonBarBase extends ListBase
         for (loopingIndex; loopingIndex < indicesTotal; loopingIndex++)
         {
             btnCurrent = dataGroup.getElementAt(buttonIndices[loopingIndex]) as ButtonBarButton;
-            btnCurrent.enabled = true;
+            btnCurrent.enabled = enabledValue;
         }
     }
 


Mime
View raw message