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 D3E7F108A4 for ; Wed, 9 Oct 2013 14:10:59 +0000 (UTC) Received: (qmail 50964 invoked by uid 500); 9 Oct 2013 14:10:57 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 50878 invoked by uid 500); 9 Oct 2013 14:10:53 -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 50850 invoked by uid 99); 9 Oct 2013 14:10:51 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 14:10:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1860A8B2F8C; Wed, 9 Oct 2013 14:10:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pent@apache.org To: commits@flex.apache.org Date: Wed, 09 Oct 2013 14:10:51 -0000 Message-Id: <127b0c673bf84ea0bf85bcd646d0faac@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] Separated controls into common and dynamicControls from staticControls as an experiment to see if we can maintain a set of simple (static) components that would translate easily into basic HTML elements. Updated Branches: refs/heads/features/dynamicControls [created] 90dd38428 http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldLabelMeasurementBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldLabelMeasurementBead.as b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldLabelMeasurementBead.as new file mode 100644 index 0000000..449f616 --- /dev/null +++ b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldLabelMeasurementBead.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.dynamicControls.beads +{ + import org.apache.flex.core.IMeasurementBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.html.dynamicControls.beads.TextFieldView; + + public class TextFieldLabelMeasurementBead implements IMeasurementBead + { + public function TextFieldLabelMeasurementBead() + { + } + + public function get measuredWidth():Number + { + var view:TextFieldView = _strand.getBeadByType(TextFieldView) as TextFieldView; + if( view ) return view.textField.textWidth; + else return 0; + } + + public function get measuredHeight():Number + { + var view:TextFieldView = _strand.getBeadByType(TextFieldView) as TextFieldView; + if( view ) return view.textField.textHeight; + else return 0; + } + + 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/90dd3842/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldView.as b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldView.as new file mode 100644 index 0000000..9e2c956 --- /dev/null +++ b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldView.as @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.dynamicControls.beads +{ + import flash.text.TextFieldType; + + public class TextFieldView extends TextFieldViewBase + { + public function TextFieldView() + { + super(); + + textField.selectable = false; + textField.type = TextFieldType.DYNAMIC; + textField.mouseEnabled = false; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldViewBase.as b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldViewBase.as new file mode 100644 index 0000000..79e6cdd --- /dev/null +++ b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextFieldViewBase.as @@ -0,0 +1,112 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.dynamicControls.beads +{ + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + + import org.apache.flex.core.CSSTextField; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ITextModel; + import org.apache.flex.core.ITextFieldView; + import org.apache.flex.events.Event; + + public class TextFieldViewBase implements IBeadView, ITextFieldView + { + public function TextFieldViewBase() + { + _textField = new CSSTextField(); + } + + private var _textField:CSSTextField; + + public function get textField() : CSSTextField + { + return _textField; + } + + private var _textModel:ITextModel; + + public function get textModel() : ITextModel + { + return _textModel; + } + + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + _textModel = value.getBeadByType(ITextModel) as ITextModel; + textModel.addEventListener("textChange", textChangeHandler); + textModel.addEventListener("htmlChange", htmlChangeHandler); + textModel.addEventListener("widthChanged", sizeChangeHandler); + textModel.addEventListener("heightChanged", sizeChangeHandler); + DisplayObjectContainer(value).addChild(_textField); + sizeChangeHandler(null); + if (textModel.text !== null) + text = textModel.text; + if (textModel.html !== null) + html = textModel.html; + } + + public function get strand() : IStrand + { + return _strand; + } + + public function get text():String + { + return _textField.text; + } + public function set text(value:String):void + { + if (value == null) + value = ""; + _textField.text = value; + } + + public function get html():String + { + return _textField.htmlText; + } + + public function set html(value:String):void + { + _textField.htmlText = value; + } + + private function textChangeHandler(event:Event):void + { + text = textModel.text; + } + + private function htmlChangeHandler(event:Event):void + { + html = textModel.html; + } + + private function sizeChangeHandler(event:Event):void + { + textField.width = DisplayObject(_strand).width; + textField.height = DisplayObject(_strand).height; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputView.as b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputView.as new file mode 100644 index 0000000..889751d --- /dev/null +++ b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputView.as @@ -0,0 +1,65 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.dynamicControls.beads +{ + import flash.display.DisplayObject; + import flash.text.TextFieldType; + + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + public class TextInputView extends TextFieldViewBase + { + public function TextInputView() + { + super(); + + textField.selectable = true; + textField.type = TextFieldType.INPUT; + textField.mouseEnabled = true; + textField.multiline = false; + textField.wordWrap = false; + } + + override public function set strand(value:IStrand):void + { + super.strand = value; + + // Default size + var ww:Number = DisplayObject(strand).width; + if( isNaN(ww) || ww == 0 ) DisplayObject(strand).width = 100; + var hh:Number = DisplayObject(strand).height; + if( isNaN(hh) || hh == 0 ) DisplayObject(strand).height = 18; + + IEventDispatcher(strand).addEventListener("widthChanged", sizeChangedHandler); + IEventDispatcher(strand).addEventListener("heightChanged", sizeChangedHandler); + sizeChangedHandler(null); + } + + private function sizeChangedHandler(event:Event):void + { + var ww:Number = DisplayObject(strand).width; + if( !isNaN(ww) && ww > 0 ) textField.width = ww; + + var hh:Number = DisplayObject(strand).height; + if( !isNaN(hh) && hh > 0 ) textField.height = hh; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputWithBorderView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputWithBorderView.as b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputWithBorderView.as new file mode 100644 index 0000000..87f9b55 --- /dev/null +++ b/frameworks/as/src/org/apache/flex/html/dynamicControls/beads/TextInputWithBorderView.as @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.dynamicControls.beads +{ + import flash.display.DisplayObject; + + import org.apache.flex.core.IParent; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.common.beads.SingleLineBorderBead; + import org.apache.flex.html.common.beads.models.SingleLineBorderModel; + import org.apache.flex.html.common.supportClasses.Border; + + public class TextInputWithBorderView extends TextInputView + { + public function TextInputWithBorderView() + { + super(); + } + + private var _border:Border; + + public function get border():Border + { + return _border; + } + + override public function set strand(value:IStrand):void + { + super.strand = value; + + // add a border to this + _border = new Border(); + _border.model = new SingleLineBorderModel(); + _border.addBead(new SingleLineBorderBead()); + IParent(strand).addElement(border); + + IEventDispatcher(strand).addEventListener("widthChanged", sizeChangedHandler); + IEventDispatcher(strand).addEventListener("heightChanged", sizeChangedHandler); + sizeChangedHandler(null); + } + + private function sizeChangedHandler(event:Event):void + { + var ww:Number = DisplayObject(strand).width; + _border.width = ww; + + var hh:Number = DisplayObject(strand).height; + _border.height = hh; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as b/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as index b3cf5e2..0e06086 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as @@ -17,18 +17,16 @@ // //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.html.staticControls -{ +{ import org.apache.flex.core.IAlertModel; import org.apache.flex.core.IPopUp; import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + + [Event(name="close", type="org.apache.flex.events.Event")] public class Alert extends UIBase implements IPopUp { - public static const YES:uint = 0x000001; - public static const NO:uint = 0x000002; - public static const OK:uint = 0x000004; - public static const CANCEL:uint = 0x000008; - public function Alert() { super(); @@ -36,49 +34,36 @@ package org.apache.flex.html.staticControls className = "Alert"; } - // note: only passing parent to this function as I don't see a way to identify - // the 'application' or top level view without supplying a place to start to - // look for it. - static public function show( text:String, parent:Object, title:String="", flags:uint=Alert.OK ) : void + private function get message():String { - var alert:Alert = new Alert(); - alert.message = text; - alert.title = title; - alert.flags = flags; - - alert.show(parent); + return IAlertModel(model).message; } - - public function show(parent:Object) : void + private function set message(value:String):void { - parent.addElement(this); + IAlertModel(model).message = value; } - public function get title():String + private function get htmlMessage():String { - return IAlertModel(model).title; + return IAlertModel(model).htmlMessage; } - public function set title(value:String):void + private function set htmlMessage(value:String):void { - IAlertModel(model).title = value; + IAlertModel(model).htmlMessage = value; } - public function get message():String - { - return IAlertModel(model).message; - } - public function set message(value:String):void + public function show(parent:Object) : void { - IAlertModel(model).message = value; + parent.addElement(this); } - public function get flags():uint + static public function show(message:String, parent:Object):Alert { - return IAlertModel(model).flags; - } - public function set flags(value:uint):void - { - IAlertModel(model).flags = value; + var alert:Alert = new Alert(); + alert.message = message; + alert.show(parent); + + return alert; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as b/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as deleted file mode 100644 index cf4cc8c..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as +++ /dev/null @@ -1,70 +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.staticControls -{ - import org.apache.flex.core.IAlertModel; - import org.apache.flex.core.IPopUp; - import org.apache.flex.core.UIBase; - import org.apache.flex.events.Event; - - [Event(name="close", type="org.apache.flex.events.Event")] - - public class SimpleAlert extends UIBase implements IPopUp - { - public function SimpleAlert() - { - super(); - - className = "SimpleAlert"; - } - - private function get message():String - { - return IAlertModel(model).message; - } - private function set message(value:String):void - { - IAlertModel(model).message = value; - } - - private function get htmlMessage():String - { - return IAlertModel(model).htmlMessage; - } - private function set htmlMessage(value:String):void - { - IAlertModel(model).htmlMessage = value; - } - - public function show(parent:Object) : void - { - parent.addElement(this); - } - - static public function show(message:String, parent:Object):SimpleAlert - { - var alert:SimpleAlert = new SimpleAlert(); - alert.message = message; - alert.show(parent); - - return alert; - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/accessories/NumericOnlyTextInputBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/accessories/NumericOnlyTextInputBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/accessories/NumericOnlyTextInputBead.as index b92a317..cf6a5e7 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/accessories/NumericOnlyTextInputBead.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/accessories/NumericOnlyTextInputBead.as @@ -25,7 +25,7 @@ package org.apache.flex.html.staticControls.accessories import org.apache.flex.core.IStrand; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.beads.ITextFieldView; + import org.apache.flex.core.ITextFieldView; public class NumericOnlyTextInputBead implements IBead { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/accessories/PasswordInputBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/accessories/PasswordInputBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/accessories/PasswordInputBead.as index 9280317..5235edb 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/accessories/PasswordInputBead.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/accessories/PasswordInputBead.as @@ -23,7 +23,7 @@ package org.apache.flex.html.staticControls.accessories import org.apache.flex.core.IStrand; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.beads.ITextFieldView; + import org.apache.flex.core.ITextFieldView; public class PasswordInputBead implements IBead { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertMeasurementBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertMeasurementBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertMeasurementBead.as deleted file mode 100644 index 8199b28..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertMeasurementBead.as +++ /dev/null @@ -1,46 +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.staticControls.beads -{ - import org.apache.flex.core.IMeasurementBead; - import org.apache.flex.core.IStrand; - - public class AlertMeasurementBead implements IMeasurementBead - { - public function AlertMeasurementBead() - { - } - - public function get measuredWidth():Number - { - return 0; - } - - public function get measuredHeight():Number - { - return 0; - } - - 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/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as deleted file mode 100644 index b02911a..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as +++ /dev/null @@ -1,178 +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.staticControls.beads -{ - import org.apache.flex.core.IAlertModel; - import org.apache.flex.core.IBead; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IMeasurementBead; - import org.apache.flex.core.IParent; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.UIMetrics; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.createjs.staticControls.Label; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.Alert; - import org.apache.flex.html.staticControls.ControlBar; - import org.apache.flex.html.staticControls.TextButton; - import org.apache.flex.html.staticControls.TitleBar; - import org.apache.flex.utils.BeadMetrics; - - public class AlertView implements IBeadView - { - public function AlertView() - { - } - - private var _titleBar:TitleBar; - private var _controlBar:ControlBar; - private var _label:Label; - private var _okButton:TextButton; - private var _cancelButton:TextButton; - private var _yesButton:TextButton; - private var _noButton:TextButton; - - private var _strand:IStrand; - public function set strand(value:IStrand):void - { - _strand = value; - - var backgroundColor:Object = ValuesManager.valuesImpl.getValue(value, "background-color"); - var backgroundImage:Object = ValuesManager.valuesImpl.getValue(value, "background-image"); - if (backgroundColor != null || backgroundImage != null) - { - if (value.getBeadByType(IBackgroundBead) == null) - value.addBead(new (ValuesManager.valuesImpl.getValue(value, "iBackgroundBead")) as IBead); - } - - var borderStyle:String; - var borderStyles:Object = ValuesManager.valuesImpl.getValue(value, "border"); - if (borderStyles is Array) - { - borderStyle = borderStyles[1]; - } - if (borderStyle == null) - { - borderStyle = ValuesManager.valuesImpl.getValue(value, "border-style") as String; - } - if (borderStyle != null && borderStyle != "none") - { - if (value.getBeadByType(IBorderBead) == null) - value.addBead(new (ValuesManager.valuesImpl.getValue(value, "iBorderBead")) as IBead); - } - - var flags:uint = IAlertModel(UIBase(_strand).model).flags; - if( flags & Alert.OK ) { - _okButton = new TextButton(); - _okButton.text = IAlertModel(UIBase(_strand).model).okLabel; - _okButton.addEventListener("click",handleOK); - } - if( flags & Alert.CANCEL ) { - _cancelButton = new TextButton(); - _cancelButton.text = IAlertModel(UIBase(_strand).model).cancelLabel; - _cancelButton.addEventListener("click",handleCancel); - } - if( flags & Alert.YES ) { - _yesButton = new TextButton(); - _yesButton.text = IAlertModel(UIBase(_strand).model).yesLabel; - _yesButton.addEventListener("click",handleYes); - } - if( flags & Alert.NO ) { - _noButton = new TextButton(); - _noButton.text = IAlertModel(UIBase(_strand).model).noLabel; - _noButton.addEventListener("click",handleNo); - } - - _titleBar = new TitleBar(); - _titleBar.title = IAlertModel(UIBase(_strand).model).title; - - _label = new Label(); - _label.text = IAlertModel(UIBase(_strand).model).message; - - _controlBar = new ControlBar(); - if( _okButton ) _controlBar.addElement(_okButton); - if( _cancelButton ) _controlBar.addElement(_cancelButton); - if( _yesButton ) _controlBar.addElement(_yesButton); - if( _noButton ) _controlBar.addElement(_noButton); - - IParent(_strand).addElement(_titleBar); - IParent(_strand).addElement(_controlBar); - IParent(_strand).addElement(_label); - - sizeHandler(null); - } - - private function sizeHandler(event:Event):void - { - var labelMeasure:IMeasurementBead = _label.measurementBead; - var titleMeasure:IMeasurementBead = _titleBar.measurementBead; - var ctrlMeasure:IMeasurementBead = _controlBar.measurementBead; - var maxWidth:Number = Math.max(titleMeasure.measuredWidth, ctrlMeasure.measuredWidth, labelMeasure.measuredWidth); - - var metrics:UIMetrics = BeadMetrics.getMetrics(_strand); - - _titleBar.x = metrics.left; - _titleBar.y = metrics.top; - _titleBar.width = maxWidth; - - // content placement here - _label.x = metrics.left; - _label.y = _titleBar.y + _titleBar.height + 2; - _label.width = maxWidth; - - _controlBar.x = metrics.left; - _controlBar.y = _label.y + _label.height + 2; - _controlBar.width = maxWidth; - - UIBase(_strand).width = maxWidth + metrics.left + metrics.right; - UIBase(_strand).height = _controlBar.y + _controlBar.height + metrics.bottom + 2; - } - - private function handleOK(event:Event):void - { - // create some custom event where the detail value - // is the OK button flag. Do same for other event handlers - dispatchCloseEvent(Alert.OK); - } - - private function handleCancel(event:Event):void - { - dispatchCloseEvent(Alert.CANCEL); - } - - private function handleYes(event:Event):void - { - dispatchCloseEvent(Alert.YES); - } - - private function handleNo(event:Event):void - { - dispatchCloseEvent(Alert.NO); - } - - public function dispatchCloseEvent(buttonFlag:uint):void - { - // TO DO: buttonFlag should be part of the event - var newEvent:Event = new Event("close",true); - IEventDispatcher(_strand).dispatchEvent(newEvent); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as index d7a5bba..b241c54 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as @@ -24,16 +24,17 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.core.IBeadView; import org.apache.flex.core.IComboBoxModel; + import org.apache.flex.core.IComboBoxView; + import org.apache.flex.core.IParent; import org.apache.flex.core.IPopUpHost; import org.apache.flex.core.IStrand; import org.apache.flex.core.ValuesManager; - import org.apache.flex.core.IParent; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; import org.apache.flex.html.staticControls.Button; import org.apache.flex.html.staticControls.TextInput; - public class ComboBoxView implements IBeadView, IComboBoxView + public class ComboBoxView implements IBeadView, org.apache.flex.core.IComboBoxView { public function ComboBoxView() { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/ContainerView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ContainerView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ContainerView.as index c0eb0b7..be9faf1 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ContainerView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ContainerView.as @@ -30,7 +30,7 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.core.ValuesManager; import org.apache.flex.html.staticControls.Container; import org.apache.flex.html.staticControls.ContainerContentArea; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; public class ContainerView implements IBeadView, ILayoutParent http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/IComboBoxView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IComboBoxView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IComboBoxView.as deleted file mode 100644 index e3866fc..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IComboBoxView.as +++ /dev/null @@ -1,37 +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.staticControls.beads -{ - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - - public interface IComboBoxView extends IBeadView - { - function get text():String; - function set text(value:String):void; - - function get html():String; - function set html(value:String):void; - - function get popUp():IStrand; - - function get popUpVisible():Boolean; - function set popUpVisible(value:Boolean):void; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/IListView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IListView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IListView.as index 8e74ff4..baff324 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IListView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IListView.as @@ -20,7 +20,7 @@ package org.apache.flex.html.staticControls.beads { import org.apache.flex.core.IItemRendererParent; import org.apache.flex.core.IStrand; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; public interface IListView http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/ITextFieldView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ITextFieldView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ITextFieldView.as deleted file mode 100644 index 67fa049..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ITextFieldView.as +++ /dev/null @@ -1,27 +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.staticControls.beads -{ - import org.apache.flex.core.CSSTextField; - - public interface ITextFieldView - { - function get textField():CSSTextField; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as index dbe9e36..2180c5c 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as @@ -33,10 +33,11 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.core.ValuesManager; import org.apache.flex.events.Event; import org.apache.flex.html.staticControls.beads.models.ScrollBarModel; - import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.beads.models.SingleLineBorderModel; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; + import org.apache.flex.html.common.beads.SingleLineBorderBead; public class ListView extends Strand implements IBeadView, IStrand, IListView, ILayoutParent { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as index 27308ef..523aa0c 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as @@ -33,7 +33,7 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.html.staticControls.Spinner; import org.apache.flex.html.staticControls.TextInput; import org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; public class NumericStepperView implements IBeadView, ILayoutParent http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as deleted file mode 100644 index 5886073..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as +++ /dev/null @@ -1,73 +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.staticControls.beads -{ - import flash.display.Graphics; - - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - - public class SingleLineBorderBead implements IBead, IBorderBead, IGraphicsDrawing - { - public function SingleLineBorderBead() - { - } - - private var _strand:IStrand; - - public function get strand():IStrand - { - return _strand; - } - public function set strand(value:IStrand):void - { - _strand = value; - IEventDispatcher(value).addEventListener("heightChanged", changeHandler); - IEventDispatcher(value).addEventListener("widthChanged", changeHandler); - } - - private function changeHandler(event:Event):void - { - var styleObject:* = ValuesManager.valuesImpl.getValue(_strand,"border-color"); - var borderColor:Number = Number(styleObject); - if( isNaN(borderColor) ) borderColor = 0x000000; - styleObject = ValuesManager.valuesImpl.getValue(_strand,"border-thickness"); - var borderThickness:Number = Number(styleObject); - if( isNaN(borderThickness) ) borderThickness = 1; - - var host:UIBase = UIBase(_strand); - var g:Graphics = host.graphics; - var w:Number = host.width; - var h:Number = host.height; - - var gd:IGraphicsDrawing = strand.getBeadByType(IGraphicsDrawing) as IGraphicsDrawing; - if( this == gd ) g.clear(); - - g.lineStyle(); - g.beginFill(borderColor); - g.drawRect(0, 0, w, h); - g.drawRect(borderThickness, borderThickness, w-2*borderThickness, h-2*borderThickness); - g.endFill(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as index bea4cb5..7dd6d16 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as @@ -28,9 +28,10 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.core.IStrand; import org.apache.flex.core.IParent; import org.apache.flex.html.staticControls.beads.models.ScrollBarModel; - import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.beads.models.SingleLineBorderModel; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; + import org.apache.flex.html.common.beads.SingleLineBorderBead; public class TextAreaView extends TextFieldViewBase implements IStrand { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonMeasurementBead.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonMeasurementBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonMeasurementBead.as deleted file mode 100644 index c6e3b6d..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonMeasurementBead.as +++ /dev/null @@ -1,50 +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.staticControls.beads -{ - import org.apache.flex.core.IMeasurementBead; - import org.apache.flex.core.IStrand; - - public class TextButtonMeasurementBead implements IMeasurementBead - { - public function TextButtonMeasurementBead() - { - } - - public function get measuredWidth():Number - { - var view:TextButtonView = _strand.getBeadByType(TextButtonView) as TextButtonView; - if( view ) return Math.max(view.upTextField.textWidth,view.downTextField.textWidth,view.overTextField.textWidth); - else return 0; - } - - public function get measuredHeight():Number - { - var view:TextButtonView = _strand.getBeadByType(TextButtonView) as TextButtonView; - if( view ) return Math.max(view.upTextField.textHeight,view.downTextField.textHeight,view.overTextField.textHeight); - else return 0; - } - - 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/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldViewBase.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldViewBase.as index 5f5ba8f..9c958b6 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldViewBase.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldViewBase.as @@ -26,6 +26,7 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.core.IStrand; import org.apache.flex.core.ITextModel; import org.apache.flex.events.Event; + import org.apache.flex.core.ITextFieldView; public class TextFieldViewBase implements IBeadView, ITextFieldView { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as index 8d5e405..f3746d3 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as @@ -22,10 +22,11 @@ package org.apache.flex.html.staticControls.beads import org.apache.flex.core.IStrand; import org.apache.flex.core.IParent; - import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.beads.models.SingleLineBorderModel; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.common.beads.SingleLineBorderBead; public class TextInputWithBorderView extends TextInputView { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/AlertController.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/AlertController.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/AlertController.as deleted file mode 100644 index 01ba18a..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/AlertController.as +++ /dev/null @@ -1,52 +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.staticControls.beads.controllers -{ - import flash.display.DisplayObject; - - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - - public class AlertController implements IBeadController - { - public function AlertController() - { - } - - private var _strand:IStrand; - - public function get strand():IStrand - { - return _strand; - } - - public function set strand(value:IStrand):void - { - _strand = value; - IEventDispatcher(value).addEventListener("close",handleAlertClose); - } - - private function handleAlertClose(event:Event):void - { - DisplayObject(_strand).parent.removeChild(DisplayObject(_strand)); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/ComboBoxController.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/ComboBoxController.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/ComboBoxController.as deleted file mode 100644 index ed2d228..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/ComboBoxController.as +++ /dev/null @@ -1,71 +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.staticControls.beads.controllers -{ - import flash.display.DisplayObject; - import flash.events.MouseEvent; - - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.ISelectionModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.beads.IComboBoxView; - - public class ComboBoxController implements IBeadController - { - public function ComboBoxController() - { - } - - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - IEventDispatcher(value).addEventListener(MouseEvent.CLICK, clickHandler); - } - - private function clickHandler(event:MouseEvent):void - { - var viewBead:IComboBoxView = _strand.getBeadByType(IComboBoxView) as IComboBoxView; - viewBead.popUpVisible = true; - var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; - var popUpModel:ISelectionModel = viewBead.popUp.getBeadByType(ISelectionModel) as ISelectionModel; - popUpModel.dataProvider = selectionModel.dataProvider; - popUpModel.selectedIndex = selectionModel.selectedIndex; - DisplayObject(viewBead.popUp).width = DisplayObject(_strand).width; - DisplayObject(viewBead.popUp).height = 200; - DisplayObject(viewBead.popUp).x = DisplayObject(_strand).x; - DisplayObject(viewBead.popUp).y = DisplayObject(_strand).y; - IEventDispatcher(viewBead.popUp).addEventListener("change", changeHandler); - } - - private function changeHandler(event:Event):void - { - var viewBead:IComboBoxView = _strand.getBeadByType(IComboBoxView) as IComboBoxView; - viewBead.popUpVisible = false; - var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; - var popUpModel:ISelectionModel = viewBead.popUp.getBeadByType(ISelectionModel) as ISelectionModel; - selectionModel.selectedIndex = popUpModel.selectedIndex; - IEventDispatcher(_strand).dispatchEvent(new Event("change")); - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/EditableTextKeyboardController.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/EditableTextKeyboardController.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/EditableTextKeyboardController.as deleted file mode 100644 index e505217..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/controllers/EditableTextKeyboardController.as +++ /dev/null @@ -1,55 +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.staticControls.beads.controllers -{ - import org.apache.flex.core.CSSTextField; - import org.apache.flex.core.IBead; - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ITextModel; - import org.apache.flex.core.UIBase; - import org.apache.flex.html.staticControls.beads.ITextFieldView; - - public class EditableTextKeyboardController implements IBead, IBeadController - { - public function EditableTextKeyboardController() - { - } - - private var model:ITextModel; - private var textField:CSSTextField; - - private var _strand:IStrand; - public function set strand(value:IStrand):void - { - _strand = value; - - model = UIBase(_strand).model as ITextModel; - - var viewBead:ITextFieldView = _strand.getBeadByType(ITextFieldView) as ITextFieldView; - textField = viewBead.textField; - textField.addEventListener("change", inputChangeHandler); - } - - private function inputChangeHandler( event:Object ) : void - { - model.text = textField.text; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalScrollingLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalScrollingLayout.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalScrollingLayout.as index 00dcfc1..5634b8d 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalScrollingLayout.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalScrollingLayout.as @@ -29,7 +29,7 @@ package org.apache.flex.html.staticControls.beads.layouts import org.apache.flex.core.IStrand; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; public class NonVirtualHorizontalScrollingLayout implements IBeadLayout http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualVerticalScrollingLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualVerticalScrollingLayout.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualVerticalScrollingLayout.as index 0bc9dfd..1bbeb3a 100644 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualVerticalScrollingLayout.as +++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualVerticalScrollingLayout.as @@ -29,7 +29,7 @@ package org.apache.flex.html.staticControls.beads.layouts import org.apache.flex.core.IStrand; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.supportClasses.Border; + import org.apache.flex.html.common.supportClasses.Border; import org.apache.flex.html.staticControls.supportClasses.ScrollBar; public class NonVirtualVerticalScrollingLayout implements IBeadLayout http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/AlertModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/AlertModel.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/AlertModel.as deleted file mode 100644 index 12deea4..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/AlertModel.as +++ /dev/null @@ -1,163 +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.staticControls.beads.models -{ - import org.apache.flex.core.IAlertModel; - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class AlertModel extends EventDispatcher implements IAlertModel, IBead - { - public function AlertModel() - { - super(); - } - - private var _strand:IStrand; - public function set strand(value:IStrand):void - { - _strand = value; - } - - private var _title:String; - public function get title():String - { - return _title; - } - public function set title(value:String):void - { - if( value != _title ) { - _title = value; - dispatchEvent( new Event("titleChange") ); - } - } - - private var _htmlTitle:String; - public function get htmlTitle():String - { - return _htmlTitle; - } - public function set htmlTitle(value:String):void - { - if( value != _htmlTitle ) { - _htmlTitle = value; - dispatchEvent( new Event("htmlTitleChange") ); - } - } - - private var _message:String; - public function get message():String - { - return _message; - } - public function set message(value:String):void - { - if( value != _message ) { - _message = value; - dispatchEvent( new Event("messageChange") ); - } - } - - private var _htmlMessage:String; - public function get htmlMessage():String - { - return _htmlMessage; - } - public function set htmlMessage(value:String):void - { - if( value != _htmlMessage ) - { - _htmlMessage = value; - dispatchEvent( new Event("htmlMessageChange") ); - } - } - - private var _flags:uint; - public function get flags():uint - { - return _flags; - } - public function set flags(value:uint):void - { - if( value != _flags ) - { - _flags = value; - dispatchEvent( new Event("flagsChange") ); - } - } - - private var _okLabel:String = "OK"; - public function get okLabel():String - { - return _okLabel; - } - public function set okLabel(value:String):void - { - if( value != _okLabel ) - { - _okLabel = value; - dispatchEvent( new Event("okLabelChange") ); - } - } - - private var _cancelLabel:String = "Cancel"; - public function get cancelLabel():String - { - return _cancelLabel; - } - public function set cancelLabel(value:String):void - { - if( value != _cancelLabel ) - { - _cancelLabel = value; - dispatchEvent( new Event("cancelLabelChange") ); - } - } - - private var _yesLabel:String = "YES"; - public function get yesLabel():String - { - return _yesLabel; - } - public function set yesLabel(value:String):void - { - if( value != _yesLabel ) - { - _yesLabel = value; - dispatchEvent( new Event("yesLabelChange") ); - } - } - - private var _noLabel:String = "NO"; - public function get noLabel():String - { - return _noLabel; - } - public function set noLabel(value:String):void - { - if( value != _noLabel ) - { - _noLabel = value; - dispatchEvent( new Event("noLabelChange") ); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ComboBoxModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ComboBoxModel.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ComboBoxModel.as deleted file mode 100644 index 91d2ce0..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ComboBoxModel.as +++ /dev/null @@ -1,61 +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.staticControls.beads.models -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IComboBoxModel; - import org.apache.flex.events.Event; - - public class ComboBoxModel extends ArraySelectionModel implements IBead, IComboBoxModel - { - public function ComboBoxModel() - { - } - - private var _text:String; - public function get text():String - { - return _text; - } - - public function set text(value:String):void - { - if (value != _text) - { - _text = value; - dispatchEvent(new Event("textChange")); - } - } - - private var _html:String; - public function get html():String - { - return _html; - } - - public function set html(value:String):void - { - if (value != _html) - { - _html = value; - dispatchEvent(new Event("htmlChange")); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/SingleLineBorderModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/SingleLineBorderModel.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/SingleLineBorderModel.as deleted file mode 100644 index 39908e8..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/SingleLineBorderModel.as +++ /dev/null @@ -1,49 +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.staticControls.beads.models -{ - import flash.geom.Rectangle; - - import org.apache.flex.core.IBead; - import org.apache.flex.core.IBorderModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.EventDispatcher; - - public class SingleLineBorderModel extends EventDispatcher implements IBead, IBorderModel - { - public function SingleLineBorderModel() - { - } - - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - } - - static private var rect:Rectangle = new Rectangle(1, 1, 1, 1); - - public function get offsets():Rectangle - { - return rect; - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TextModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TextModel.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TextModel.as deleted file mode 100644 index 6a994b2..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/TextModel.as +++ /dev/null @@ -1,70 +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.staticControls.beads.models -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ITextModel; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class TextModel extends EventDispatcher implements IBead, ITextModel - { - public function TextModel() - { - } - - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - } - - private var _text:String; - public function get text():String - { - return _text; - } - - public function set text(value:String):void - { - if (value != _text) - { - _text = value; - dispatchEvent(new Event("textChange")); - } - } - - private var _html:String; - public function get html():String - { - return _html; - } - - public function set html(value:String):void - { - if (value != _html) - { - _html = value; - dispatchEvent(new Event("htmlChange")); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/Border.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/Border.as b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/Border.as deleted file mode 100644 index 615e35c..0000000 --- a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/Border.as +++ /dev/null @@ -1,31 +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.staticControls.supportClasses -{ - import org.apache.flex.core.UIBase; - - public class Border extends UIBase - { - public function Border() - { - super(); - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/ComboBox.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/ComboBox.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/ComboBox.js index 04f88b4..0b1c6f8 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/ComboBox.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/ComboBox.js @@ -15,6 +15,9 @@ goog.provide('org.apache.flex.html.staticControls.ComboBox'); goog.require('org.apache.flex.core.ListBase'); +goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel'); +goog.require('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData'); +goog.require('org.apache.flex.html.staticControls.beads.ComboBoxView'); @@ -23,7 +26,13 @@ goog.require('org.apache.flex.core.ListBase'); * @extends {org.apache.flex.core.ListBase} */ org.apache.flex.html.staticControls.ComboBox = function() { + + this.model = new + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel(); + this.addBead(this.model); + goog.base(this); + }; goog.inherits(org.apache.flex.html.staticControls.ComboBox, org.apache.flex.core.ListBase); @@ -35,136 +44,12 @@ goog.inherits(org.apache.flex.html.staticControls.ComboBox, */ org.apache.flex.html.staticControls.ComboBox.prototype.createElement = function() { - var button, input; - - this.element = document.createElement('div'); - - input = document.createElement('input'); - input.style.position = 'absolute'; - input.style.width = '80px'; - this.element.appendChild(input); - - button = document.createElement('div'); - button.style.position = 'absolute'; - button.style.top = '0px'; - button.style.right = '0px'; - button.style.background = '#bbb'; - button.style.width = '16px'; - button.style.height = '20px'; - button.style.margin = '0'; - button.style.border = 'solid #609 1px'; - goog.events.listen(button, 'click', goog.bind(this.buttonClicked, this)); - this.element.appendChild(button); - - this.element.style.position = 'relative'; - - this.positioner = this.element; - - // add a click handler so that a click outside of the combo box can - // dismiss the pop-up should it be visible. - goog.events.listen(document, 'click', - goog.bind(this.dismissPopup, this)); - - input.flexjs_wrapper = this; -}; - - -/** - * @expose - * @this {org.apache.flex.html.staticControls.ComboBox} - * @param {string} event The event. - */ -org.apache.flex.html.staticControls.ComboBox.prototype.selectChanged = - function(event) { - var select; - - select = event.currentTarget; - - this.set_selectedItem(select.options[select.selectedIndex].value); - - this.popup.parentNode.removeChild(this.popup); - this.popup = null; - - this.dispatchEvent(event); -}; - - -/** - * @expose - * @this {org.apache.flex.html.staticControls.ComboBox} - * @param {string} event The event. - */ -org.apache.flex.html.staticControls.ComboBox.prototype.dismissPopup = - function(event) { - // remove the popup if it already exists - if (this.popup) { - this.popup.parentNode.removeChild(this.popup); - this.popup = null; - } -}; - - -/** - * @expose - * @this {org.apache.flex.html.staticControls.ComboBox} - * @param {string} event The event. - */ -org.apache.flex.html.staticControls.ComboBox.prototype.buttonClicked = - function(event) { - var dp, i, input, left, n, opt, opts, pn, popup, select, si, top, width; - - event.stopPropagation(); - - if (this.popup) { - this.dismissPopup(); - - return; - } - - input = this.element.childNodes.item(0); - - pn = this.element; - top = pn.offsetTop + input.offsetHeight; - left = pn.offsetLeft; - width = pn.offsetWidth; - - popup = document.createElement('div'); - popup.className = 'popup'; - popup.id = 'test'; - popup.style.position = 'absolute'; - popup.style.top = top.toString() + 'px'; - popup.style.left = left.toString() + 'px'; - popup.style.width = width.toString() + 'px'; - popup.style.margin = '0px auto'; - popup.style.padding = '0px'; - popup.style.zIndex = '10000'; - - select = document.createElement('select'); - select.style.width = width.toString() + 'px'; - goog.events.listen(select, 'change', goog.bind(this.selectChanged, this)); - opts = select.options; - - dp = this.get_dataProvider(); - n = dp.length; - for (i = 0; i < n; i++) { - opt = document.createElement('option'); - opt.text = dp[i]; - opts.add(opt); - } - - select.size = n; - - si = this.get_selectedIndex(); - if (si < 0) { - select.value = null; - } else { - select.value = dp[si]; - } - - this.popup = popup; - - popup.appendChild(select); - document.body.appendChild(popup); + goog.base(this,'createElement'); + + this.set_className('ComboBox'); + + this.viewBead = new org.apache.flex.html.staticControls.beads.ComboBoxView(); + this.addBead(this.viewBead); }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/90dd3842/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ComboBoxView.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ComboBoxView.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ComboBoxView.js new file mode 100644 index 0000000..1829085 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ComboBoxView.js @@ -0,0 +1,186 @@ +/** + * Licensed 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. + */ + +goog.provide('org.apache.flex.html.staticControls.beads.ComboBoxView'); + +goog.require('org.apache.flex.core.IItemRendererParent'); +goog.require('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData'); +goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel'); +goog.require('org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup'); + +/** + * @constructor + */ +org.apache.flex.html.staticControls.beads.ComboBoxView = function() { + this.lastSelectedIndex = -1; +}; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.ComboBoxView} + * @param {Object} value The new host. + */ +org.apache.flex.html.staticControls.beads.ComboBoxView.prototype.set_strand = + function(value) { + + this.strand_ = value; + + this.model = value.getBeadByType( + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel); + this.model.addEventListener('selectedIndexChanged', + goog.bind(this.selectionChangeHandler, this)); + + this.input = document.createElement('input'); + this.input.style.position = 'relative'; + this.input.style.width = '80px'; + this.input.style.height = '21px'; + this.strand_.element.appendChild(this.input); + + this.button = document.createElement('div'); + this.button.style.position = 'relative'; + this.button.style.top = '0px'; + this.button.style.left = '80px'; + this.button.style.background = '#bbb'; + this.button.style.width = '50px'; + this.button.style.height = '21px'; + this.button.style.margin = '0'; + this.button.style.border = 'solid #609 1px'; + goog.events.listen(this.button, 'click', goog.bind(this.buttonClicked, this)); + this.strand_.element.appendChild(this.button); + + + // add a click handler so that a click outside of the combo box can + // dismiss the pop-up should it be visible. + goog.events.listen(document, 'click', + goog.bind(this.dismissPopup, this)); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.ComboBox} + * @param {string} event The event. + */ +org.apache.flex.html.staticControls.beads.ComboBoxView.prototype.dismissPopup = + function(event) { + // remove the popup if it already exists + if (this.popup) { + this.popup.parentNode.removeChild(this.popup); + this.popup = null; + } +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.ComboBox} + * @param {string} event The event. + */ +org.apache.flex.html.staticControls.beads.ComboBoxView.prototype.buttonClicked = + function(event) { + var dp, i, left, n, opt, opts, pn, popup, select, si, top, width; + + event.stopPropagation(); + + if (this.popup) { + this.dismissPopup(); + + return; + } + + pn = this.strand_.element; + top = pn.offsetTop + this.input.offsetHeight; + left = pn.offsetLeft; + width = pn.offsetWidth; + + popup = document.createElement('div'); + popup.className = 'popup'; + popup.id = 'test'; + popup.style.position = 'absolute'; + popup.style.top = top.toString() + 'px'; + popup.style.left = left.toString() + 'px'; + popup.style.width = width.toString() + 'px'; + popup.style.margin = '0px auto'; + popup.style.padding = '0px'; + popup.style.zIndex = '10000'; + + select = document.createElement('select'); + select.style.width = width.toString() + 'px'; + goog.events.listen(select, 'change', goog.bind(this.selectChanged, this)); + opts = select.options; + + dp = this.strand_.get_dataProvider(); + n = dp.length; +/* for (i = 0; i < n; i++) { + opt = document.createElement('option'); + opt.text = dp[i]; + opts.add(opt); + } + + select.size = n; + + si = this.get_selectedIndex(); + if (si < 0) { + select.value = null; + } else { + select.value = dp[si]; + } +*/ + this.popup = popup; + + popup.appendChild(select); + document.body.appendChild(popup); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.ComboBoxView} + * @param {string} event The event. + */ +org.apache.flex.html.staticControls.beads.ComboBoxView.prototype.selectChanged = + function(event) { + var select; + + select = event.currentTarget; + + this.set_selectedItem(select.options[select.selectedIndex].value); + + this.popup.parentNode.removeChild(this.popup); + this.popup = null; + + this.dispatchEvent(event); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.ComboBoxView} + * @param {object} value The event that triggered the selection. + */ +org.apache.flex.html.staticControls.beads.ComboBoxView.prototype. +selectionChangeHandler = function(value) { +/* + if (this.lastSelectedIndex != -1) { + var ir = this.dataGroup_.getItemRendererForIndex(this.lastSelectedIndex); + if (ir) ir.set_selected(false); + } + if (this.model.get_selectedIndex() != -1) { + ir = this.dataGroup_.getItemRendererForIndex( + this.model.get_selectedIndex()); + if (ir) ir.set_selected(true); + } + this.lastSelectedIndex = this.model.get_selectedIndex(); +*/ +};