You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2021/08/25 16:09:24 UTC

[royale-asjs] branch develop updated: jewel-alert: Make AlertView more pleasent for extending

This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new f7f2f95  jewel-alert: Make AlertView more pleasent for extending
f7f2f95 is described below

commit f7f2f95b78c59e5858fd784c548d970494cc4af5
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Wed Aug 25 18:09:18 2021 +0200

    jewel-alert: Make AlertView more pleasent for extending
    
    - Extract content creation of Alert to separate protected method
    - Add curly brackets to some condition in Alert class
---
 .../main/royale/org/apache/royale/jewel/Alert.as   |  6 +++-
 .../apache/royale/jewel/beads/views/AlertView.as   | 34 +++++++++++++---------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Alert.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Alert.as
index 72aa408..e06961b 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Alert.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Alert.as
@@ -241,7 +241,7 @@ package org.apache.royale.jewel
 		  *  @playerversion AIR 2.6
 		  *  @productversion Royale 0.9.4
 		  */
-		static public function show(message:String, title:String="", flags:uint=Alert.OK, parent:Object = null, modal:Boolean = true) : Alert
+		static public function show(message:String, title:String="", flags:uint=Alert.OK, parent:Object = null, modal:Boolean = true):Alert
 		{
 			var alert:Alert = new Alert();
 			alert.message = message;
@@ -249,9 +249,13 @@ package org.apache.royale.jewel
 			alert.flags = flags;
 			
 			if(modal)
+			{
 				alert.showModal(parent);
+			}
 			else
+			{
 				alert.show(parent);
+			}
 
 			return alert;
 		}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/AlertView.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/AlertView.as
index 4412a51..f20677f 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/AlertView.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/AlertView.as
@@ -165,14 +165,7 @@ package org.apache.royale.jewel.beads.views
 			IParent(_strand).addElement(titleBar);
 
 			// Text
-			label = new Label();
-			label.multiline = true;
-			label.html = alertModel.message ? alertModel.message : "";
-			
-			content = new VGroup();
-			content.addClass("content");
-			content.addElement(label);
-			IParent(_strand).addElement(content);
+			createContent();
 			
 			// controlBar
 			createButtons();
@@ -186,7 +179,20 @@ package org.apache.royale.jewel.beads.views
 			setTimeout(prepareForPopUp,  300);
 		}
 
-		private function prepareForPopUp():void
+		protected function createContent():void
+		{
+			// Text
+			label = new Label();
+			label.multiline = true;
+			label.html = alertModel.message ? alertModel.message : "";
+
+			content = new VGroup();
+			content.addClass("content");
+			content.addElement(label);
+			IParent(_strand).addElement(content);
+		}
+
+		protected function prepareForPopUp():void
         {
 			COMPILE::JS
 			{
@@ -194,7 +200,7 @@ package org.apache.royale.jewel.beads.views
 			}
 		}
 
-		private function createButtons():void
+		protected function createButtons():void
 		{
 			COMPILE::SWF
 			{
@@ -297,7 +303,7 @@ package org.apache.royale.jewel.beads.views
 		/**
 		 * @private
 		 */
-		private function handleOK(event:MouseEvent):void
+		protected function handleOK(event:MouseEvent):void
 		{
 			// create some custom event where the detail value
 			// is the OK button flag. Do same for other event handlers
@@ -307,7 +313,7 @@ package org.apache.royale.jewel.beads.views
 		/**
 		 * @private
 		 */
-		private function handleCancel(event:MouseEvent):void
+		protected function handleCancel(event:MouseEvent):void
 		{
 			dispatchCloseEvent(Alert.CANCEL);
 		}
@@ -315,7 +321,7 @@ package org.apache.royale.jewel.beads.views
 		/**
 		 * @private
 		 */
-		private function handleYes(event:MouseEvent):void
+		protected function handleYes(event:MouseEvent):void
 		{
 			dispatchCloseEvent(Alert.YES);
 		}
@@ -323,7 +329,7 @@ package org.apache.royale.jewel.beads.views
 		/**
 		 * @private
 		 */
-		private function handleNo(event:MouseEvent):void
+		protected function handleNo(event:MouseEvent):void
 		{
 			dispatchCloseEvent(Alert.NO);
 		}