Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 641FD105BC for ; Sun, 5 May 2013 11:42:19 +0000 (UTC) Received: (qmail 37415 invoked by uid 500); 5 May 2013 11:42:17 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 37098 invoked by uid 500); 5 May 2013 11:42:10 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 37053 invoked by uid 99); 5 May 2013 11:42:08 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 May 2013 11:42:08 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5E1F18871A0; Sun, 5 May 2013 11:42:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mkessler@apache.org To: commits@flex.apache.org Message-Id: <96ccf7d0a82045d5b28832eac36b3886@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: [flex-sdk] [refs/heads/develop] - FLEX-33524: Combined a few methods and reduced redundant code. Date: Sun, 5 May 2013 11:42:08 +0000 (UTC) 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 Authored: Sun May 5 07:39:08 2013 -0400 Committer: Mark Kessler 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 label. + * Gets the index for several of a ButtonBar's Buttons, referencing them by the ButtonBarbutton's label. * - *

The function takes a single argument which is the ButtonBarButtons label.

- *
myButtonBar.disableButton("My Button Label")
+ *

The method takes an array of ButtonBarButtons label and an optional field name.

+ *
myButtonBar.getButtonIndices(["My Button Label1", "My Label2"])
* - * @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 label. - * - *

The function takes a single argument which is the ButtonBarButtons label.

- *
myButtonBar.disableButtons(["My Button Label1", "My Label2"])
- * - * @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 label. + * Changes the enabled property of a ButtonBar's Button referencing it by the ButtonBarbutton's label. * - *

The function takes a single argument which is the ButtonBarButtons label.

- *
myButtonBar.enableButton("My Button Label")
+ *

The method takes a single ButtonBarButton label, a new enabled property value, and an optional field name to search for.

+ *
myButtonBar.setButtonEnabled("My Button Label", false)
* * @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 label. * - *

The function takes a single argument which is the ButtonBarButtons label.

- *
myButtonBar.enableButtons(["My Button Label1", "My Label2"])
+ *

The method takes an array of ButtonBarButton labels, a new enabled property value, and an optional field name to search for.

+ *
myButtonBar.setButtonsEnabled(["My Button Label1", "My Label2"], false)
* * @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; } }