You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/04/16 14:41:50 UTC

[royale-asjs] branch develop updated: jewel-tabbar: new AssignTabContent bead to add a TabBarContent to a TabBar. The bead adds the content next to the tabbar and setups the logic to select content based on user tabbar selection

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

carlosrovira 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 7dbb066  jewel-tabbar: new AssignTabContent bead to add a TabBarContent to a TabBar. The bead adds the content next to the tabbar and setups the logic to select content based on user tabbar selection
7dbb066 is described below

commit 7dbb066f77e42508a16f4c69a4338437ce91e1ac
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Tue Apr 16 16:41:44 2019 +0200

    jewel-tabbar: new AssignTabContent bead to add a TabBarContent to a TabBar. The bead adds the content next to the tabbar and setups the logic to select content based on user tabbar selection
---
 .../Jewel/src/main/resources/jewel-manifest.xml    |   2 +
 .../beads/controls/tabbar/AssignTabContent.as      | 130 +++++++++++++++++++++
 2 files changed, 132 insertions(+)

diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index d07ef52..f850233 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -82,6 +82,8 @@
     <component id="SelectedItemNullValidator" class="org.apache.royale.jewel.beads.validators.SelectedItemNullValidator"/>
     <component id="CheckBoxValidator" class="org.apache.royale.jewel.beads.validators.CheckBoxValidator"/>
     <component id="RadioButtonValidator" class="org.apache.royale.jewel.beads.validators.RadioButtonValidator"/>
+    
+    <component id="AssignTabContent" class="org.apache.royale.jewel.beads.controls.tabbar.AssignTabContent"/>
 
     <component id="TabBar" class="org.apache.royale.jewel.TabBar"/>
     <component id="TabBarButtonItemRenderer" class="org.apache.royale.jewel.itemRenderers.TabBarButtonItemRenderer"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as
new file mode 100644
index 0000000..d4f134b
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as
@@ -0,0 +1,130 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.royale.jewel.beads.controls.tabbar
+{	
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.jewel.TabBar;
+	import org.apache.royale.jewel.TabBarContent;
+	import org.apache.royale.core.IDataProviderModel;
+	
+	/**
+	 *  The Disabled bead class is a specialty bead that can be used to disable a Jewel control.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.4
+	 */
+	public class AssignTabContent implements IBead
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.4
+		 */
+		public function AssignTabContent()
+		{
+		}
+
+		protected var tabbar:TabBar;
+		
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 *  @royaleignorecoercion HTMLInputElement
+		 *  @royaleignorecoercion org.apache.royale.core.UIBase;
+		 */
+		public function set strand(value:IStrand):void
+		{
+			tabbar = value as TabBar;
+			tabbar.addEventListener(Event.CHANGE, changeHandler);
+			tabbar.addEventListener("selectionChanged", selectionChangedChangeHandler);
+			updateHost();
+		}
+
+		protected function updateHost():void
+		{
+			if(tabbar)
+			{
+				tabbar.parent.addElement(content);
+			}
+		}
+		
+		protected function selectionChangedChangeHandler(event:Event):void
+		{
+			if(content && tabbar.selectedIndex != -1)
+			{
+				content.selectedContent = tabbar.selectedItem[selectedContentProperty];
+			}
+		}
+
+		protected function changeHandler(event:Event):void
+		{
+			var item:Object = event.target.selectedItem;
+			content.selectedContent = item[selectedContentProperty];
+		}
+
+		private var _content:TabBarContent;
+        /**
+		 *  The TabBarContent related to the TabBar
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+        public function get content():TabBarContent
+        {
+            return _content;
+        }
+        public function set content(value:TabBarContent):void
+        {
+            _content = value;
+			updateHost();
+        }
+		
+		private var _selectedContentProperty:String;
+        /**
+		 *  the property in the object that will be used to
+		 *  select the content
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+        public function get selectedContentProperty():String
+        {
+            return _selectedContentProperty;
+        }
+        public function set selectedContentProperty(value:String):void
+        {
+            _selectedContentProperty = value;
+        }
+	}
+}