new folders for Formatters
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/c07d8731 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/c07d8731 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/c07d8731 Branch: refs/heads/mavenfolders Commit: c07d873199b82eb3ee735e243594f6ca970ebc1e Parents: 2c40fe9 Author: Alex Harui <aha...@apache.org> Authored: Tue Feb 2 17:11:20 2016 -0800 Committer: Alex Harui <aha...@apache.org> Committed: Tue Feb 2 17:11:20 2016 -0800 ---------------------------------------------------------------------- .../Formatters/as/src/FormattersClasses.as | 41 ---- .../as/src/org/apache/flex/core/FormatBase.as | 113 ---------- .../flex/html/accessories/CurrencyFormatter.as | 215 ------------------- .../html/accessories/DateFormatMMDDYYYYBead.as | 158 -------------- .../flex/html/accessories/NumberFormatter.as | 210 ------------------ .../flex/html/beads/FormatableLabelView.as | 90 -------- .../flex/html/beads/FormatableTextInputView.as | 91 -------- .../projects/Formatters/basic-manifest.xml | 25 --- .../projects/Formatters/compile-asjs-config.xml | 80 ------- .../projects/Formatters/compile-config.xml | 79 ------- .../src/main/flex/FormattersClasses.as | 41 ++++ .../flex/org/apache/flex/core/FormatBase.as | 113 ++++++++++ .../flex/html/accessories/CurrencyFormatter.as | 215 +++++++++++++++++++ .../html/accessories/DateFormatMMDDYYYYBead.as | 158 ++++++++++++++ .../flex/html/accessories/NumberFormatter.as | 210 ++++++++++++++++++ .../flex/html/beads/FormatableLabelView.as | 90 ++++++++ .../flex/html/beads/FormatableTextInputView.as | 91 ++++++++ .../src/main/resources/basic-manifest.xml | 25 +++ .../src/main/resources/compile-asjs-config.xml | 80 +++++++ .../src/main/resources/compile-config.xml | 79 +++++++ 20 files changed, 1102 insertions(+), 1102 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/FormattersClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/FormattersClasses.as b/frameworks/projects/Formatters/as/src/FormattersClasses.as deleted file mode 100644 index bbf43ce..0000000 --- a/frameworks/projects/Formatters/as/src/FormattersClasses.as +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package -{ - -/** - * @private - * This class is used to link additional classes into rpc.swc - * beyond those that are found by dependecy analysis starting - * from the classes specified in manifest.xml. - */ -internal class FormattersClasses -{ - import org.apache.flex.core.FormatBase; FormatBase; - - import org.apache.flex.html.accessories.DateFormatMMDDYYYYBead; DateFormatMMDDYYYYBead; - COMPILE::AS3 - { - import org.apache.flex.html.beads.FormatableLabelView; FormatableLabelView; - import org.apache.flex.html.beads.FormatableTextInputView; FormatableTextInputView; - } -} - -} - http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/org/apache/flex/core/FormatBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/org/apache/flex/core/FormatBase.as b/frameworks/projects/Formatters/as/src/org/apache/flex/core/FormatBase.as deleted file mode 100644 index b1fa1af..0000000 --- a/frameworks/projects/Formatters/as/src/org/apache/flex/core/FormatBase.as +++ /dev/null @@ -1,113 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.core -{ - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.events.IEventDispatcher; - - public class FormatBase extends EventDispatcher implements IFormatBead - { - public function FormatBase() - { - } - - /** - * Retrieves the current value of the property from the strand. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get propertyValue():Object - { - var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; - var value:Object = model[propertyName]; - return value; - } - - private var _propertyName:String; - - /** - * The name of the property in the model holding the value to be - * formatted. The default is text. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get propertyName():String - { - if (_propertyName == null) { - _propertyName = "text"; - } - return _propertyName; - } - public function set propertyName(value:String):void - { - _propertyName = value; - } - - private var _eventName:String; - - /** - * The name of the event dispatched when the property changes. The - * default is propertyName + "Changed". - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get eventName():String - { - if (_eventName == null) { - return _propertyName+"Changed"; - } - return _eventName; - } - public function set eventName(value:String):void - { - _eventName = value; - } - - /** - * The resulting formatted value as a string. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get formattedString():String - { - // override to produce actual result - return null; - } - - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/CurrencyFormatter.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/CurrencyFormatter.as b/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/CurrencyFormatter.as deleted file mode 100644 index 208b5ff..0000000 --- a/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/CurrencyFormatter.as +++ /dev/null @@ -1,215 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.accessories -{ - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IFormatBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.events.IEventDispatcher; - - /** - * The CurrencyFormatter class formats a value in separated groups. The formatter listens - * to a property on a model and when the property changes, formats it and dispatches a - * formatChanged event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class CurrencyFormatter extends EventDispatcher implements IFormatBead - { - /** - * constructor - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function CurrencyFormatter() - { - super(); - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - // Listen for the beadsAdded event which signals when all of a strand's - // beads have been added. - IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); - } - - /** - * @private - */ - private function handleBeadsAdded(event:Event):void - { - // Listen for the change in the model - var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; - model.addEventListener(eventName,propertyChangeHandler); - model.addEventListener(propertyName+"Change",propertyChangeHandler); - - // format the current value of that property - propertyChangeHandler(null); - } - - private var _propertyName:String; - private var _eventName:String; - private var _formattedResult:String; - private var _fractionalDigits:Number = 2; - private var _currencySymbol:String = "$"; - - /** - * The name of the property on the model to format. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get propertyName():String - { - if (_propertyName == null) { - return "text"; - } - return _propertyName; - } - public function set propertyName(value:String):void - { - _propertyName = value; - } - - /** - * The event dispatched by the model when the property changes. The - * default is propertyName+"Changed". - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get eventName():String - { - if (_eventName == null) { - return _propertyName+"Changed"; - } - return _eventName; - } - public function set eventName(value:String):void - { - _eventName = value; - } - - /** - * Number of digits after the decimal separator - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get fractionalDigits():int - { - return _fractionalDigits; - } - public function set fractionalDigits(value:int):void - { - _fractionalDigits = value; - } - - /** - * The currency symbol, such as "$" - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get currencySymbol():String - { - return _currencySymbol; - } - public function set currencySymbol(value:String):void - { - _currencySymbol = value; - } - - /** - * The formatted string. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get formattedString():String - { - return _formattedResult; - } - - /** - * @private - */ - private function propertyChangeHandler(event:Event):void - { - // When the property changes, fetch it from the model and - // format it, storing the result in _formattedResult. - var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; - var value:Object = model[propertyName]; - _formattedResult = format(value); - - // Dispatch the formatChanged event so any bead that's interested in - // the formatted string knows to use it. - var newEvent:Event = new Event("formatChanged"); - this.dispatchEvent(newEvent); - } - - /** - * Computes the formatted string. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function format(value:Object):String - { - if (value == null) return ""; - - var num:Number = Number(value); - var source:String = num.toFixed(fractionalDigits); - - return currencySymbol + source; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as b/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as deleted file mode 100644 index 94d7f20..0000000 --- a/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as +++ /dev/null @@ -1,158 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.accessories -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IDateChooserModel; - import org.apache.flex.core.IFormatBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.IStrandWithModel; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.html.TextInput; - import org.apache.flex.html.beads.DateFieldView; - - /** - * The DateFormatBead class formats the display of a DateField using MM/DD/YYYY format. - * - * @flexjsignoreimport org.apache.flex.core.IStrandWithModel - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class DateFormatMMDDYYYYBead extends EventDispatcher implements IBead, IFormatBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function DateFormatMMDDYYYYBead() - { - } - - private var _propertyName:String; - private var _eventName:String; - private var _formattedResult:String; - - /** - * The name of the property on the model holding the value to be formatted. - * The default is selectedDate. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get propertyName():String - { - if (_propertyName == null) { - return "selectedDate"; - } - return _propertyName; - } - public function set propertyName(value:String):void - { - _propertyName = value; - } - - /** - * The name of the event dispatched when the property changes. The - * default is selectedDateChanged. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get eventName():String - { - if (_eventName == null) { - return _propertyName+"Changed"; - } - return _eventName; - } - public function set eventName(value:String):void - { - _eventName = value; - } - - /** - * The formatted result. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get formattedString():String - { - return _formattedResult; - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @flexjsignorecoercion org.apache.flex.core.IStrandWithModel - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - var model:IDateChooserModel = IStrandWithModel(_strand).model as IDateChooserModel; - model.addEventListener("selectedDateChanged",handleTextChange); - } - - /** - * @private - * - * @flexjsignorecoercion org.apache.flex.core.IStrandWithModel - */ - private function handleTextChange(event:Event):void - { - var model:IDateChooserModel = IStrandWithModel(_strand).model as IDateChooserModel; - /*var view:DateFieldView = _strand.getBeadByType(DateFieldView) as DateFieldView; - var input:TextInput = view.textInput;*/ - - var d:Date = model.selectedDate; - var month:String = String(d.getMonth()+1); - if (Number(month)<10) month = "0"+month; - var date:String = String(d.getDate()); - if (Number(date)<10) date = "0"+date; - var fmt:String = month+"/"+date+"/"+String(d.getFullYear()); - /*input.text = fmt;*/ - _formattedResult = month+"/"+date+"/"+String(d.getFullYear()); - - dispatchEvent( new Event("formatChanged") ); - } - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/NumberFormatter.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/NumberFormatter.as b/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/NumberFormatter.as deleted file mode 100644 index 0d1b613..0000000 --- a/frameworks/projects/Formatters/as/src/org/apache/flex/html/accessories/NumberFormatter.as +++ /dev/null @@ -1,210 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.accessories -{ - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IFormatBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.events.IEventDispatcher; - - /** - * The NumberFormatter class formats a value in separated groups. The formatter listens - * to a property on a model and when the property changes, formats it and dispatches a - * formatChanged event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class NumberFormatter extends EventDispatcher implements IFormatBead - { - /** - * constructor - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function NumberFormatter() - { - super(); - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - // Listen for the beadsAdded event which signals when all of a strand's - // beads have been added. - IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); - } - - /** - * @private - */ - private function handleBeadsAdded(event:Event):void - { - // Listen for the change in the model - var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; - model.addEventListener(eventName,propertyChangeHandler); - model.addEventListener(propertyName+"Change",propertyChangeHandler); - - // format the current value of that property - propertyChangeHandler(null); - } - - private var _propertyName:String; - private var _eventName:String; - private var _formattedResult:String; - private var _groupSize:Number = 3; - private var _thousandsSeparator:String = ","; - - /** - * The name of the property on the model to format. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get propertyName():String - { - if (_propertyName == null) { - return "text"; - } - return _propertyName; - } - public function set propertyName(value:String):void - { - _propertyName = value; - } - - /** - * The event dispatched by the model when the property changes. The - * default is propertyName+"Changed". - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get eventName():String - { - if (_eventName == null) { - return _propertyName+"Changed"; - } - return _eventName; - } - public function set eventName(value:String):void - { - _eventName = value; - } - - /** - * Character to use to separate thousands groups. The default is - * the comma (,). - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get thousandsSeparator():String - { - return _thousandsSeparator; - } - public function set thousandsSeparator(value:String):void - { - _thousandsSeparator = value; - } - - /** - * The formatted string. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get formattedString():String - { - return _formattedResult; - } - - /** - * @private - */ - private function propertyChangeHandler(event:Event):void - { - // When the property changes, fetch it from the model and - // format it, storing the result in _formattedResult. - var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; - var value:Object = model[propertyName]; - _formattedResult = format(value); - - // Dispatch the formatChanged event so any bead that's interested in - // the formatted string knows to use it. - var newEvent:Event = new Event("formatChanged"); - this.dispatchEvent(newEvent); - } - - /** - * @private - */ - private function format(value:Object):String - { - if (value == null) return ""; - - var num:Number = Number(value); - var source:String = String(value); - var parts:Array = source.split(thousandsSeparator); - source = parts.join(""); - - var l:int = source.length; - var result:String = ""; - var group:int = 0; - - for(var i:int=l-1; i >= 0; i--) - { - if (group == _groupSize && result.length > 0) { - result = thousandsSeparator + result; - group = 0; - } - result = source.charAt(i) + result; - group++; - } - - return result; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableLabelView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableLabelView.as b/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableLabelView.as deleted file mode 100644 index 03b6ccd..0000000 --- a/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableLabelView.as +++ /dev/null @@ -1,90 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import org.apache.flex.core.IFormatBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - - /** - * The FormatableLabelView class is a View bead that is capable of working - * with a format bead to display a formatted value. When the format bead has - * created a formatted string, it dispatches a formatChanged event that the - * FormatableLabelView class intercepts and displays in the label. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class FormatableLabelView extends TextFieldView - { - /** - * constructor - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function FormatableLabelView() - { - super(); - } - - private var _formatter:IFormatBead; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); - } - - /** - * @private - */ - private function handleBeadsAdded(event:Event):void - { - _formatter = _strand.getBeadByType(IFormatBead) as IFormatBead; - _formatter.addEventListener("formatChanged",formatReadyHandler); - - // process any text set in the label at this moment - text = _formatter.formattedString; - } - - /** - * @private - */ - private function formatReadyHandler(event:Event):void - { - if (_formatter) { - text = _formatter.formattedString; - } - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableTextInputView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableTextInputView.as b/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableTextInputView.as deleted file mode 100644 index 926253c..0000000 --- a/frameworks/projects/Formatters/as/src/org/apache/flex/html/beads/FormatableTextInputView.as +++ /dev/null @@ -1,91 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import org.apache.flex.core.IFormatBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - - /** - * The FormatableTextInputView class is a View bead that extends TextInputWithBorderView - * and is capable of working with a format bead. When a format bead dispatches a - * formatChanged event, the FormatableTextInputView bead copies the formatted string to - * to the text field. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class FormatableTextInputView extends TextInputWithBorderView - { - /** - * constructor - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function FormatableTextInputView() - { - super(); - } - - private var _formatter:IFormatBead; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); - } - - /** - * @private - */ - private function handleBeadsAdded(event:Event):void - { - _formatter = _strand.getBeadByType(IFormatBead) as IFormatBead; - if (_formatter) { - _formatter.addEventListener("formatChanged",formatChangedHandler); - } - } - - /** - * @private - */ - private function formatChangedHandler(event:Event):void - { - this.textField.text = _formatter.formattedString; - - // move the cursor to the end - var l:int = this.textField.text.length; - this.textField.setSelection(l,l); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/basic-manifest.xml b/frameworks/projects/Formatters/basic-manifest.xml deleted file mode 100644 index 106df8e..0000000 --- a/frameworks/projects/Formatters/basic-manifest.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> - - -<componentPackage> - <component id="NumberFormatter" class="org.apache.flex.html.accessories.NumberFormatter"/> - <component id="CurrencyFormatter" class="org.apache.flex.html.accessories.CurrencyFormatter"/> -</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/compile-asjs-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/compile-asjs-config.xml b/frameworks/projects/Formatters/compile-asjs-config.xml deleted file mode 100644 index 6b9466f..0000000 --- a/frameworks/projects/Formatters/compile-asjs-config.xml +++ /dev/null @@ -1,80 +0,0 @@ -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<flex-config> - - <compiler> - <accessible>false</accessible> - - <external-library-path> - </external-library-path> - - <mxml> - <children-as-data>true</children-as-data> - </mxml> - <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> - <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> - <binding-value-change-event-type>valueChange</binding-value-change-event-type> - - <keep-as3-metadata> - <name>Bindable</name> - <name>Managed</name> - <name>ChangeEvent</name> - <name>NonCommittingChangeEvent</name> - <name>Transient</name> - </keep-as3-metadata> - - <locale/> - - <library-path> - <!-- asjscompc won't 'link' these classes in, but will list their requires - if these swcs are on the external-library-path then their requires - will not be listed --> - <path-element>../../externs/Core.swc</path-element> - <path-element>../../externs/HTML.swc</path-element> - </library-path> - - <namespaces> - <namespace> - <uri>library://ns.apache.org/flexjs/basic</uri> - <manifest>basic-manifest.xml</manifest> - </namespace> - </namespaces> - - <source-path> - <path-element>as/src</path-element> - </source-path> - - <warn-no-constructor>false</warn-no-constructor> - </compiler> - - <include-file> - </include-file> - - <include-classes> - <class>FormattersClasses</class> - </include-classes> - - <include-namespaces> - <uri>library://ns.apache.org/flexjs/basic</uri> - </include-namespaces> - - <target-player>${playerglobal.version}</target-player> - - -</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/compile-config.xml b/frameworks/projects/Formatters/compile-config.xml deleted file mode 100644 index 96c7e48..0000000 --- a/frameworks/projects/Formatters/compile-config.xml +++ /dev/null @@ -1,79 +0,0 @@ -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<flex-config> - - <compiler> - <accessible>false</accessible> - - <external-library-path> - <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> - <path-element>../../libs/Core.swc</path-element> - <path-element>../../libs/HTML.swc</path-element> - </external-library-path> - - <mxml> - <children-as-data>true</children-as-data> - </mxml> - <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> - <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> - <binding-value-change-event-type>valueChange</binding-value-change-event-type> - - <keep-as3-metadata> - <name>Bindable</name> - <name>Managed</name> - <name>ChangeEvent</name> - <name>NonCommittingChangeEvent</name> - <name>Transient</name> - </keep-as3-metadata> - - <locale/> - - <library-path/> - - <namespaces> - <namespace> - <uri>library://ns.apache.org/flexjs/basic</uri> - <manifest>basic-manifest.xml</manifest> - </namespace> - </namespaces> - - <source-path> - <path-element>as/src</path-element> - </source-path> - - <warn-no-constructor>false</warn-no-constructor> - </compiler> - - <include-file> - <name>js/out/*</name> - <path>js/out/*</path> - </include-file> - - <include-classes> - <class>FormattersClasses</class> - </include-classes> - - <include-namespaces> - <uri>library://ns.apache.org/flexjs/basic</uri> - </include-namespaces> - - <target-player>${playerglobal.version}</target-player> - - -</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/FormattersClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/FormattersClasses.as b/frameworks/projects/Formatters/src/main/flex/FormattersClasses.as new file mode 100644 index 0000000..bbf43ce --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/FormattersClasses.as @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package +{ + +/** + * @private + * This class is used to link additional classes into rpc.swc + * beyond those that are found by dependecy analysis starting + * from the classes specified in manifest.xml. + */ +internal class FormattersClasses +{ + import org.apache.flex.core.FormatBase; FormatBase; + + import org.apache.flex.html.accessories.DateFormatMMDDYYYYBead; DateFormatMMDDYYYYBead; + COMPILE::AS3 + { + import org.apache.flex.html.beads.FormatableLabelView; FormatableLabelView; + import org.apache.flex.html.beads.FormatableTextInputView; FormatableTextInputView; + } +} + +} + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/org/apache/flex/core/FormatBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/org/apache/flex/core/FormatBase.as b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/core/FormatBase.as new file mode 100644 index 0000000..b1fa1af --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/core/FormatBase.as @@ -0,0 +1,113 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.IEventDispatcher; + + public class FormatBase extends EventDispatcher implements IFormatBead + { + public function FormatBase() + { + } + + /** + * Retrieves the current value of the property from the strand. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get propertyValue():Object + { + var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; + var value:Object = model[propertyName]; + return value; + } + + private var _propertyName:String; + + /** + * The name of the property in the model holding the value to be + * formatted. The default is text. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get propertyName():String + { + if (_propertyName == null) { + _propertyName = "text"; + } + return _propertyName; + } + public function set propertyName(value:String):void + { + _propertyName = value; + } + + private var _eventName:String; + + /** + * The name of the event dispatched when the property changes. The + * default is propertyName + "Changed". + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get eventName():String + { + if (_eventName == null) { + return _propertyName+"Changed"; + } + return _eventName; + } + public function set eventName(value:String):void + { + _eventName = value; + } + + /** + * The resulting formatted value as a string. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get formattedString():String + { + // override to produce actual result + return null; + } + + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/CurrencyFormatter.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/CurrencyFormatter.as b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/CurrencyFormatter.as new file mode 100644 index 0000000..208b5ff --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/CurrencyFormatter.as @@ -0,0 +1,215 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.accessories +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IFormatBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.IEventDispatcher; + + /** + * The CurrencyFormatter class formats a value in separated groups. The formatter listens + * to a property on a model and when the property changes, formats it and dispatches a + * formatChanged event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class CurrencyFormatter extends EventDispatcher implements IFormatBead + { + /** + * constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function CurrencyFormatter() + { + super(); + } + + private var _strand:IStrand; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + // Listen for the beadsAdded event which signals when all of a strand's + // beads have been added. + IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); + } + + /** + * @private + */ + private function handleBeadsAdded(event:Event):void + { + // Listen for the change in the model + var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; + model.addEventListener(eventName,propertyChangeHandler); + model.addEventListener(propertyName+"Change",propertyChangeHandler); + + // format the current value of that property + propertyChangeHandler(null); + } + + private var _propertyName:String; + private var _eventName:String; + private var _formattedResult:String; + private var _fractionalDigits:Number = 2; + private var _currencySymbol:String = "$"; + + /** + * The name of the property on the model to format. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get propertyName():String + { + if (_propertyName == null) { + return "text"; + } + return _propertyName; + } + public function set propertyName(value:String):void + { + _propertyName = value; + } + + /** + * The event dispatched by the model when the property changes. The + * default is propertyName+"Changed". + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get eventName():String + { + if (_eventName == null) { + return _propertyName+"Changed"; + } + return _eventName; + } + public function set eventName(value:String):void + { + _eventName = value; + } + + /** + * Number of digits after the decimal separator + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get fractionalDigits():int + { + return _fractionalDigits; + } + public function set fractionalDigits(value:int):void + { + _fractionalDigits = value; + } + + /** + * The currency symbol, such as "$" + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get currencySymbol():String + { + return _currencySymbol; + } + public function set currencySymbol(value:String):void + { + _currencySymbol = value; + } + + /** + * The formatted string. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get formattedString():String + { + return _formattedResult; + } + + /** + * @private + */ + private function propertyChangeHandler(event:Event):void + { + // When the property changes, fetch it from the model and + // format it, storing the result in _formattedResult. + var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; + var value:Object = model[propertyName]; + _formattedResult = format(value); + + // Dispatch the formatChanged event so any bead that's interested in + // the formatted string knows to use it. + var newEvent:Event = new Event("formatChanged"); + this.dispatchEvent(newEvent); + } + + /** + * Computes the formatted string. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function format(value:Object):String + { + if (value == null) return ""; + + var num:Number = Number(value); + var source:String = num.toFixed(fractionalDigits); + + return currencySymbol + source; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as new file mode 100644 index 0000000..94d7f20 --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/DateFormatMMDDYYYYBead.as @@ -0,0 +1,158 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.accessories +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IDateChooserModel; + import org.apache.flex.core.IFormatBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IStrandWithModel; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.html.TextInput; + import org.apache.flex.html.beads.DateFieldView; + + /** + * The DateFormatBead class formats the display of a DateField using MM/DD/YYYY format. + * + * @flexjsignoreimport org.apache.flex.core.IStrandWithModel + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DateFormatMMDDYYYYBead extends EventDispatcher implements IBead, IFormatBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateFormatMMDDYYYYBead() + { + } + + private var _propertyName:String; + private var _eventName:String; + private var _formattedResult:String; + + /** + * The name of the property on the model holding the value to be formatted. + * The default is selectedDate. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get propertyName():String + { + if (_propertyName == null) { + return "selectedDate"; + } + return _propertyName; + } + public function set propertyName(value:String):void + { + _propertyName = value; + } + + /** + * The name of the event dispatched when the property changes. The + * default is selectedDateChanged. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get eventName():String + { + if (_eventName == null) { + return _propertyName+"Changed"; + } + return _eventName; + } + public function set eventName(value:String):void + { + _eventName = value; + } + + /** + * The formatted result. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get formattedString():String + { + return _formattedResult; + } + + private var _strand:IStrand; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @flexjsignorecoercion org.apache.flex.core.IStrandWithModel + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + var model:IDateChooserModel = IStrandWithModel(_strand).model as IDateChooserModel; + model.addEventListener("selectedDateChanged",handleTextChange); + } + + /** + * @private + * + * @flexjsignorecoercion org.apache.flex.core.IStrandWithModel + */ + private function handleTextChange(event:Event):void + { + var model:IDateChooserModel = IStrandWithModel(_strand).model as IDateChooserModel; + /*var view:DateFieldView = _strand.getBeadByType(DateFieldView) as DateFieldView; + var input:TextInput = view.textInput;*/ + + var d:Date = model.selectedDate; + var month:String = String(d.getMonth()+1); + if (Number(month)<10) month = "0"+month; + var date:String = String(d.getDate()); + if (Number(date)<10) date = "0"+date; + var fmt:String = month+"/"+date+"/"+String(d.getFullYear()); + /*input.text = fmt;*/ + _formattedResult = month+"/"+date+"/"+String(d.getFullYear()); + + dispatchEvent( new Event("formatChanged") ); + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/NumberFormatter.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/NumberFormatter.as b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/NumberFormatter.as new file mode 100644 index 0000000..0d1b613 --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/accessories/NumberFormatter.as @@ -0,0 +1,210 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.accessories +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IFormatBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.IEventDispatcher; + + /** + * The NumberFormatter class formats a value in separated groups. The formatter listens + * to a property on a model and when the property changes, formats it and dispatches a + * formatChanged event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class NumberFormatter extends EventDispatcher implements IFormatBead + { + /** + * constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function NumberFormatter() + { + super(); + } + + private var _strand:IStrand; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + // Listen for the beadsAdded event which signals when all of a strand's + // beads have been added. + IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); + } + + /** + * @private + */ + private function handleBeadsAdded(event:Event):void + { + // Listen for the change in the model + var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; + model.addEventListener(eventName,propertyChangeHandler); + model.addEventListener(propertyName+"Change",propertyChangeHandler); + + // format the current value of that property + propertyChangeHandler(null); + } + + private var _propertyName:String; + private var _eventName:String; + private var _formattedResult:String; + private var _groupSize:Number = 3; + private var _thousandsSeparator:String = ","; + + /** + * The name of the property on the model to format. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get propertyName():String + { + if (_propertyName == null) { + return "text"; + } + return _propertyName; + } + public function set propertyName(value:String):void + { + _propertyName = value; + } + + /** + * The event dispatched by the model when the property changes. The + * default is propertyName+"Changed". + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get eventName():String + { + if (_eventName == null) { + return _propertyName+"Changed"; + } + return _eventName; + } + public function set eventName(value:String):void + { + _eventName = value; + } + + /** + * Character to use to separate thousands groups. The default is + * the comma (,). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get thousandsSeparator():String + { + return _thousandsSeparator; + } + public function set thousandsSeparator(value:String):void + { + _thousandsSeparator = value; + } + + /** + * The formatted string. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get formattedString():String + { + return _formattedResult; + } + + /** + * @private + */ + private function propertyChangeHandler(event:Event):void + { + // When the property changes, fetch it from the model and + // format it, storing the result in _formattedResult. + var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; + var value:Object = model[propertyName]; + _formattedResult = format(value); + + // Dispatch the formatChanged event so any bead that's interested in + // the formatted string knows to use it. + var newEvent:Event = new Event("formatChanged"); + this.dispatchEvent(newEvent); + } + + /** + * @private + */ + private function format(value:Object):String + { + if (value == null) return ""; + + var num:Number = Number(value); + var source:String = String(value); + var parts:Array = source.split(thousandsSeparator); + source = parts.join(""); + + var l:int = source.length; + var result:String = ""; + var group:int = 0; + + for(var i:int=l-1; i >= 0; i--) + { + if (group == _groupSize && result.length > 0) { + result = thousandsSeparator + result; + group = 0; + } + result = source.charAt(i) + result; + group++; + } + + return result; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableLabelView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableLabelView.as b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableLabelView.as new file mode 100644 index 0000000..03b6ccd --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableLabelView.as @@ -0,0 +1,90 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IFormatBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + /** + * The FormatableLabelView class is a View bead that is capable of working + * with a format bead to display a formatted value. When the format bead has + * created a formatted string, it dispatches a formatChanged event that the + * FormatableLabelView class intercepts and displays in the label. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class FormatableLabelView extends TextFieldView + { + /** + * constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function FormatableLabelView() + { + super(); + } + + private var _formatter:IFormatBead; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); + } + + /** + * @private + */ + private function handleBeadsAdded(event:Event):void + { + _formatter = _strand.getBeadByType(IFormatBead) as IFormatBead; + _formatter.addEventListener("formatChanged",formatReadyHandler); + + // process any text set in the label at this moment + text = _formatter.formattedString; + } + + /** + * @private + */ + private function formatReadyHandler(event:Event):void + { + if (_formatter) { + text = _formatter.formattedString; + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableTextInputView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableTextInputView.as b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableTextInputView.as new file mode 100644 index 0000000..926253c --- /dev/null +++ b/frameworks/projects/Formatters/src/main/flex/org/apache/flex/html/beads/FormatableTextInputView.as @@ -0,0 +1,91 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IFormatBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + /** + * The FormatableTextInputView class is a View bead that extends TextInputWithBorderView + * and is capable of working with a format bead. When a format bead dispatches a + * formatChanged event, the FormatableTextInputView bead copies the formatted string to + * to the text field. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class FormatableTextInputView extends TextInputWithBorderView + { + /** + * constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function FormatableTextInputView() + { + super(); + } + + private var _formatter:IFormatBead; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded); + } + + /** + * @private + */ + private function handleBeadsAdded(event:Event):void + { + _formatter = _strand.getBeadByType(IFormatBead) as IFormatBead; + if (_formatter) { + _formatter.addEventListener("formatChanged",formatChangedHandler); + } + } + + /** + * @private + */ + private function formatChangedHandler(event:Event):void + { + this.textField.text = _formatter.formattedString; + + // move the cursor to the end + var l:int = this.textField.text.length; + this.textField.setSelection(l,l); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/resources/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/resources/basic-manifest.xml b/frameworks/projects/Formatters/src/main/resources/basic-manifest.xml new file mode 100644 index 0000000..106df8e --- /dev/null +++ b/frameworks/projects/Formatters/src/main/resources/basic-manifest.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + + +<componentPackage> + <component id="NumberFormatter" class="org.apache.flex.html.accessories.NumberFormatter"/> + <component id="CurrencyFormatter" class="org.apache.flex.html.accessories.CurrencyFormatter"/> +</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/resources/compile-asjs-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/resources/compile-asjs-config.xml b/frameworks/projects/Formatters/src/main/resources/compile-asjs-config.xml new file mode 100644 index 0000000..6b9466f --- /dev/null +++ b/frameworks/projects/Formatters/src/main/resources/compile-asjs-config.xml @@ -0,0 +1,80 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<flex-config> + + <compiler> + <accessible>false</accessible> + + <external-library-path> + </external-library-path> + + <mxml> + <children-as-data>true</children-as-data> + </mxml> + <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> + <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> + <binding-value-change-event-type>valueChange</binding-value-change-event-type> + + <keep-as3-metadata> + <name>Bindable</name> + <name>Managed</name> + <name>ChangeEvent</name> + <name>NonCommittingChangeEvent</name> + <name>Transient</name> + </keep-as3-metadata> + + <locale/> + + <library-path> + <!-- asjscompc won't 'link' these classes in, but will list their requires + if these swcs are on the external-library-path then their requires + will not be listed --> + <path-element>../../externs/Core.swc</path-element> + <path-element>../../externs/HTML.swc</path-element> + </library-path> + + <namespaces> + <namespace> + <uri>library://ns.apache.org/flexjs/basic</uri> + <manifest>basic-manifest.xml</manifest> + </namespace> + </namespaces> + + <source-path> + <path-element>as/src</path-element> + </source-path> + + <warn-no-constructor>false</warn-no-constructor> + </compiler> + + <include-file> + </include-file> + + <include-classes> + <class>FormattersClasses</class> + </include-classes> + + <include-namespaces> + <uri>library://ns.apache.org/flexjs/basic</uri> + </include-namespaces> + + <target-player>${playerglobal.version}</target-player> + + +</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c07d8731/frameworks/projects/Formatters/src/main/resources/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Formatters/src/main/resources/compile-config.xml b/frameworks/projects/Formatters/src/main/resources/compile-config.xml new file mode 100644 index 0000000..96c7e48 --- /dev/null +++ b/frameworks/projects/Formatters/src/main/resources/compile-config.xml @@ -0,0 +1,79 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<flex-config> + + <compiler> + <accessible>false</accessible> + + <external-library-path> + <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> + <path-element>../../libs/Core.swc</path-element> + <path-element>../../libs/HTML.swc</path-element> + </external-library-path> + + <mxml> + <children-as-data>true</children-as-data> + </mxml> + <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> + <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> + <binding-value-change-event-type>valueChange</binding-value-change-event-type> + + <keep-as3-metadata> + <name>Bindable</name> + <name>Managed</name> + <name>ChangeEvent</name> + <name>NonCommittingChangeEvent</name> + <name>Transient</name> + </keep-as3-metadata> + + <locale/> + + <library-path/> + + <namespaces> + <namespace> + <uri>library://ns.apache.org/flexjs/basic</uri> + <manifest>basic-manifest.xml</manifest> + </namespace> + </namespaces> + + <source-path> + <path-element>as/src</path-element> + </source-path> + + <warn-no-constructor>false</warn-no-constructor> + </compiler> + + <include-file> + <name>js/out/*</name> + <path>js/out/*</path> + </include-file> + + <include-classes> + <class>FormattersClasses</class> + </include-classes> + + <include-namespaces> + <uri>library://ns.apache.org/flexjs/basic</uri> + </include-namespaces> + + <target-player>${playerglobal.version}</target-player> + + +</flex-config>