You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2013/06/03 23:11:19 UTC
git commit: [flex-asjs] [refs/heads/develop] - First draft of a
SimpleAlert, ActionScript side.
Updated Branches:
refs/heads/develop d78ed669d -> 6f3bfc1fb
First draft of a SimpleAlert, ActionScript side.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/6f3bfc1f
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/6f3bfc1f
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/6f3bfc1f
Branch: refs/heads/develop
Commit: 6f3bfc1fb2749c1557b634d0d62444ca8a1c1742
Parents: d78ed66
Author: Peter Ent <pe...@apache.org>
Authored: Mon Jun 3 17:11:05 2013 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Mon Jun 3 17:11:05 2013 -0400
----------------------------------------------------------------------
frameworks/as/basic-manifest.xml | 2 +
frameworks/as/defaults.css | 7 +
frameworks/as/src/FlexJSUIClasses.as | 2 +
.../as/src/org/apache/flex/core/IAlertModel.as | 37 ++++
.../apache/flex/html/staticControls/SimpleAlert.as | 91 +++++++++
.../html/staticControls/beads/ISimpleAlertBead.as | 30 +++
.../html/staticControls/beads/SimpleAlertBead.as | 143 +++++++++++++++
.../html/staticControls/beads/models/AlertModel.as | 93 ++++++++++
.../html/staticControls/supportClasses/PopUp.as | 49 +++++
9 files changed, 454 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/basic-manifest.xml b/frameworks/as/basic-manifest.xml
index 764ecd8..e8f05ff 100644
--- a/frameworks/as/basic-manifest.xml
+++ b/frameworks/as/basic-manifest.xml
@@ -52,5 +52,7 @@
<component id="NonVirtualVerticalLayout" class="org.apache.flex.html.staticControls.beads.layouts.NonVirtualVerticalLayout"/>
<component id="NonVirtualHorizontalLayout" class="org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout"/>
<component id="PanelBead" class="org.apache.flex.html.staticControls.beads.PanelBead"/>
+ <component id="PopUp" class="org.apache.flex.html.staticControls.supportClasses.PopUp"/>
+ <component id="SimpleAlert" class="org.apache.flex.html.staticControls.SimpleAlert"/>
</componentPackage>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index bc39a75..ccc280b 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -136,6 +136,13 @@ Panel
IPanelBead: ClassReference("org.apache.flex.html.staticControls.beads.PanelBead");
}
+SimpleAlert
+{
+ IAlertModel: ClassReference("org.apache.flex.html.staticControls.beads.models.AlertModel");
+ IAlertBead: ClassReference("org.apache.flex.html.staticControls.beads.SimpleAlertBead");
+ IPopUp: ClassReference("org.apache.flex.html.staticControls.supportClasses.DropDownListList");
+}
+
/* HTML5 */
h5|TextButton
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/FlexJSUIClasses.as b/frameworks/as/src/FlexJSUIClasses.as
index f98497e..a324460 100644
--- a/frameworks/as/src/FlexJSUIClasses.as
+++ b/frameworks/as/src/FlexJSUIClasses.as
@@ -39,6 +39,7 @@ internal class FlexJSUIClasses
import org.apache.flex.html.staticControls.beads.ComboBoxBead; ComboBoxBead;
import org.apache.flex.html.staticControls.beads.ContainerBead; ContainerBead;
import org.apache.flex.html.staticControls.beads.PanelBead; PanelBead;
+ import org.apache.flex.html.staticControls.beads.SimpleAlertBead; SimpleAlertBead;
import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; ComboBoxModel;
import org.apache.flex.html.staticControls.beads.models.ToggleButtonModel; ToggleButtonModel;
@@ -46,6 +47,7 @@ internal class FlexJSUIClasses
import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; ArraySelectionModel;
import org.apache.flex.html.staticControls.beads.models.TitleBarModel; TitleBarModel;
import org.apache.flex.html.staticControls.beads.models.PanelModel; PanelModel;
+ import org.apache.flex.html.staticControls.beads.models.AlertModel; AlertModel;
import org.apache.flex.events.CustomEvent; CustomEvent;
import org.apache.flex.events.Event; Event;
import org.apache.flex.utils.Timer; Timer;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/src/org/apache/flex/core/IAlertModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IAlertModel.as b/frameworks/as/src/org/apache/flex/core/IAlertModel.as
new file mode 100644
index 0000000..8a3337e
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IAlertModel.as
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IEventDispatcher;
+
+ public interface IAlertModel extends IEventDispatcher, IBeadModel
+ {
+ function get title():String;
+ function set title(value:String):void;
+
+ function get htmlTitle():String;
+ function set htmlTitle(value:String):void;
+
+ function get message():String;
+ function set message(value:String):void;
+
+ function get htmlMessage():String;
+ function set htmlMessage(value:String):void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/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
new file mode 100644
index 0000000..444253a
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.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.staticControls
+{
+ import flash.display.DisplayObjectContainer;
+
+ import org.apache.flex.core.IAlertModel;
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IInitSkin;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.ValuesManager;
+ import org.apache.flex.html.staticControls.beads.ISimpleAlertBead;
+
+ [Event(name="close", type="org.apache.flex.events.Event")]
+
+ public class SimpleAlert extends UIBase implements IInitSkin
+ {
+ public function SimpleAlert()
+ {
+ super();
+ }
+
+ override public function initModel():void
+ {
+ if (getBeadByType(IAlertModel) == null)
+ addBead(new (ValuesManager.valuesImpl.getValue(this, "iAlertModel")) as IBead);
+ }
+
+ public function get message():String
+ {
+ return IAlertModel(model).message;
+ }
+ public function set message(value:String):void
+ {
+ IAlertModel(model).message = value;
+ }
+
+ public function get htmlMessage():String
+ {
+ return IAlertModel(model).htmlMessage;
+ }
+ public function set htmlMessage(value:String):void
+ {
+ IAlertModel(model).htmlMessage = value;
+ }
+
+ public function initSkin():void
+ {
+ if( getBeadByType(ISimpleAlertBead) == null ) {
+ addBead(new (ValuesManager.valuesImpl.getValue(this, "iAlertBead")) as IBead);
+ }
+ }
+
+ public function show(parent:Object) : void
+ {
+ (getBeadByType(ISimpleAlertBead) as ISimpleAlertBead).showPopUp(parent as DisplayObjectContainer);
+ }
+
+ public function hide() : void
+ {
+ (getBeadByType(ISimpleAlertBead) as ISimpleAlertBead).hidePopUp();
+ }
+
+ static public function show(message:String, parent:Object):SimpleAlert
+ {
+ var alert:SimpleAlert = new SimpleAlert();
+ alert.initModel();
+ alert.message = message;
+ alert.initSkin();
+ alert.show(parent);
+
+ return alert;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/src/org/apache/flex/html/staticControls/beads/ISimpleAlertBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ISimpleAlertBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ISimpleAlertBead.as
new file mode 100644
index 0000000..379413a
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ISimpleAlertBead.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.DisplayObjectContainer;
+
+ import org.apache.flex.core.IBead;
+
+ public interface ISimpleAlertBead extends IBead
+ {
+ function showPopUp(host:DisplayObjectContainer):void;
+ function hidePopUp():void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
new file mode 100644
index 0000000..4c2ca4d
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
@@ -0,0 +1,143 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.DisplayObject;
+ import flash.display.DisplayObjectContainer;
+
+ import org.apache.flex.core.IAlertModel;
+ import org.apache.flex.core.IInitModel;
+ import org.apache.flex.core.IInitSkin;
+ 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;
+ import org.apache.flex.html.staticControls.Label;
+ import org.apache.flex.html.staticControls.TextButton;
+
+ public class SimpleAlertBead implements ISimpleAlertBead
+ {
+ public function SimpleAlertBead()
+ {
+ }
+
+ private var messageLabel:Label;
+ private var okButton:TextButton;
+
+ private var _strand:IStrand;
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+
+ var model:IAlertModel = _strand.getBeadByType(IAlertModel) as IAlertModel;
+ model.addEventListener("messageChange",handleMessageChange);
+ model.addEventListener("htmlMessageChange",handleMessageChange);
+
+ messageLabel = new Label();
+ messageLabel.initModel();
+ messageLabel.initSkin();
+ messageLabel.text = model.message;
+ messageLabel.html = model.htmlMessage;
+ messageLabel.addToParent(_strand);
+
+ okButton = new TextButton();
+ okButton.initModel();
+ okButton.text = "OK";
+ okButton.initSkin();
+ okButton.addToParent(_strand);
+ okButton.addEventListener("click",handleOK);
+
+ handleMessageChange(null);
+ }
+
+ private function handleMessageChange(event:Event):void
+ {
+ var maxWidth:Number = Math.max(UIBase(_strand).width,messageLabel.width);
+
+ messageLabel.x = 0;
+ messageLabel.y = 0;
+ messageLabel.width = maxWidth;
+
+ okButton.x = (UIBase(_strand).width - okButton.width)/2;
+ okButton.y = messageLabel.height + 20;
+
+ UIBase(_strand).width = maxWidth;
+ UIBase(_strand).height = messageLabel.height + okButton.height + 20;
+ }
+
+ private function handleOK(event:Event):void
+ {
+ var newEvent:Event = new Event("close");
+ IEventDispatcher(_strand).dispatchEvent(newEvent);
+ hidePopUp();
+ }
+
+
+
+ private var _popUp:IStrand;
+ public function get popUp():IStrand
+ {
+ return _popUp;
+ }
+
+ private var _popUpVisible:Boolean;
+
+ public function get popUpVisible():Boolean
+ {
+ return _popUpVisible;
+ }
+
+ public function showPopUp( host:DisplayObjectContainer ) : void
+ {
+ if (!_popUp)
+ {
+ var popUpClass:Class = ValuesManager.valuesImpl.getValue(_strand, "iPopUp") as Class;
+ _popUp = new popUpClass() as IStrand;
+ UIBase(_strand).addToParent(_popUp);
+ UIBase(_strand).x = 10;
+ UIBase(_strand).y = 10;
+ }
+
+ host.addChild(_popUp as DisplayObject);
+ if (_popUp is IInitModel)
+ IInitModel(_popUp).initModel();
+ if (_popUp is IInitSkin)
+ IInitSkin(_popUp).initSkin();
+
+ UIBase(_popUp).width = UIBase(_strand).width + 20;
+ UIBase(_popUp).height = UIBase(_strand).height + 20;
+
+ UIBase(_popUp).x = (host.width + UIBase(_strand).width)/2;
+ UIBase(_popUp).y = (host.height + UIBase(_strand).height)/2;
+
+ _popUpVisible = true;
+ }
+
+ public function hidePopUp() : void
+ {
+ if( _popUp )
+ {
+ DisplayObject(_popUp).parent.removeChild(_popUp as DisplayObject);
+ }
+
+ _popUpVisible = false;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/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
new file mode 100644
index 0000000..793ba9d
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/AlertModel.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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") );
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f3bfc1f/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/PopUp.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/PopUp.as b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/PopUp.as
new file mode 100644
index 0000000..cb014b8
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/PopUp.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IPopUp;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.html.staticControls.beads.SingleLineBorderBead;
+ import org.apache.flex.html.staticControls.beads.SolidBackgroundBead;
+ import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel;
+
+ public class PopUp extends UIBase implements IPopUp
+ {
+ public function PopUp()
+ {
+ super();
+ }
+
+ private var _border:Border;
+ private var _background:SolidBackgroundBead;
+
+ public function initSkin():void
+ {
+ _border = new Border();
+ _border.addToParent(this);
+ _border.model = new SingleLineBorderModel();
+ _border.addBead(new SingleLineBorderBead());
+
+ _background = new SolidBackgroundBead();
+ _background.backgroundColor = 0xffffff;
+ addBead(_background);
+ }
+ }
+}
\ No newline at end of file