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 e47fc89  new ExampleAndSourceCodeTabbedSectionContent in Tour de Jewel 
to have a tabbar for example/sourceCode
e47fc89 is described below

commit e47fc89344c491122f8923041966065fbbac2a90
Author: Carlos Rovira <carlosrov...@apache.org>
AuthorDate: Wed Dec 26 10:52:31 2018 +0100

    new ExampleAndSourceCodeTabbedSectionContent in Tour de Jewel to have a 
tabbar for example/sourceCode
---
 .../src/main/royale/AlertPlayGround.mxml           | 109 ++-------
 .../src/main/royale/PopUpViewPlayGround.mxml       |  16 +-
 .../ExampleAndSourceCodeTabbedSectionContent.as    | 251 +++++++++++++++++++++
 3 files changed, 284 insertions(+), 92 deletions(-)

diff --git a/examples/royale/TourDeJewel/src/main/royale/AlertPlayGround.mxml 
b/examples/royale/TourDeJewel/src/main/royale/AlertPlayGround.mxml
index eee4d69..6e12f74 100644
--- a/examples/royale/TourDeJewel/src/main/royale/AlertPlayGround.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/AlertPlayGround.mxml
@@ -17,12 +17,12 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 
 -->
-<j:SectionContent xmlns:fx="http://ns.adobe.com/mxml/2009";
-                  xmlns:j="library://ns.apache.org/royale/jewel"
-                  xmlns:js="library://ns.apache.org/royale/basic"
-                  xmlns:html="library://ns.apache.org/royale/html"
-                  xmlns:services="services.*">
-    
+<c:ExampleAndSourceCodeTabbedSectionContent 
xmlns:fx="http://ns.adobe.com/mxml/2009";
+                                                                               
        xmlns:j="library://ns.apache.org/royale/jewel"
+                                                                               
        xmlns:html="library://ns.apache.org/royale/html"
+                                                                               
        xmlns:js="library://ns.apache.org/royale/basic"
+                                                                               
        xmlns:c="components.*" 
+                                            
sourceCodeUrl="AlertPlayGround.mxml">
        <fx:Script>
                <![CDATA[
                        import org.apache.royale.core.IBeadLayout;
@@ -81,86 +81,27 @@ limitations under the License.
                 else
                     status.text="You answered No";
             }
-
-            import org.apache.royale.collections.ArrayList;
-            import vos.TabBarButtonVO;
-            import utils.HighlightCode;
-
-            private function changeHandler(event:Event):void
-            {
-                var item:TabBarButtonVO = (event.target as 
TabBar).selectedItem as TabBarButtonVO;
-                tabcontent.showContent(item.href);
-                if(sourceCodeTab.isActive && sourceCodeMXMLText.text == "")
-                {
-                    service.getContent();
-                }
-            }
-
-            private var _tabBarNavigation:ArrayList = new ArrayList([
-                               new TabBarButtonVO("Examples", "exampleTab", 
null),
-                               new TabBarButtonVO("Source Code", 
"sourceCodeTab", null)                
-                       ]);
-
-                       public function get tabBarNavigation():ArrayList
-                       {
-                               return _tabBarNavigation;
-                       }
-
-                       public function dataReadyHandler(event:Event):void
-                       {
-                sourceCodeMXMLText.text = event.target.sourceCode;
-                
-                COMPILE::JS
-                {
-                    var highlightCode:HighlightCode = new HighlightCode();
-                    highlightCode.highlightBlock(sourceCodeMXMLText.element);
-                }
-                       }
                ]]>
        </fx:Script>
 
-    <services:GitHubService id="service"
-            
sourceCodeUrl="https://api.github.com/repos/apache/royale-asjs/contents/examples/royale/TourDeJewel/src/main/royale/AlertPlayGround.mxml";
-            dataReady="dataReadyHandler(event)"/>
-
-    <j:TabBar id="tabbar" className="tabBarIconItemRenderer" 
change="changeHandler(event)">
-        <j:beads>
-            <js:ConstantBinding
-                sourcePropertyName="tabBarNavigation"
-                destinationPropertyName="dataProvider"/>
-        </j:beads>
-    </j:TabBar>
-    
-    <j:TabBarContent id="tabcontent">
+    <j:Card width="350">
+        <html:H3 text="Jewel Alert"/>
         
-        <j:SectionContent id="exampleTab" isActive="true">
-            <j:Card width="350">
-                <html:H3 text="Jewel Alert"/>
-                
-                <!-- Alert 1-->
-                <j:Label text="Click the button below to display a simple 
Alert window"
-                        multiline="true"/>
-                <j:Button text="Click Me" click="Alert.show('This is an Alert 
component example that shows a label text and the default OK button.', 'Alert 
Example')"/>
-
-                <!-- Alert 2-->
-                <j:Label text="Click the button below to display an Alert 
window and capture the button pressed by the user."
-                        multiline="true"/>
-                <j:Button text="Click Me" click="clickHandler(event)"/>
-                <j:Label id="status"/>
-                
-                <!-- Alert 3 (Complex Example)-->
-                <j:Label text="This is a complex example that add and retrieve 
beads at runtime. Click the button below to display an Alert window that add 
content and make changes in some layout parts."
-                        multiline="true"/>
-                <j:Button text="Click Me" click="clickHandler2(event)"/>
-            </j:Card>
-        </j:SectionContent>
-
-        <j:SectionContent id="sourceCodeTab">
-            <html:Pre>
-                <html:Code id="sourceCodeMXMLText" className="xml 
codeExample"/>
-            </html:Pre>
-        </j:SectionContent>
-
-    </j:TabBarContent>
+        <!-- Alert 1-->
+        <j:Label text="Click the button below to display a simple Alert window"
+                multiline="true"/>
+        <j:Button text="Click Me" click="Alert.show('This is an Alert 
component example that shows a label text and the default OK button.', 'Alert 
Example')"/>
+
+        <!-- Alert 2-->
+        <j:Label text="Click the button below to display an Alert window and 
capture the button pressed by the user."
+                multiline="true"/>
+        <j:Button text="Click Me" click="clickHandler(event)"/>
+        <j:Label id="status"/>
+        
+        <!-- Alert 3 (Complex Example)-->
+        <j:Label text="This is a complex example that add and retrieve beads 
at runtime. Click the button below to display an Alert window that add content 
and make changes in some layout parts."
+                multiline="true"/>
+        <j:Button text="Click Me" click="clickHandler2(event)"/>
+    </j:Card>
        
-</j:SectionContent>
+</c:ExampleAndSourceCodeTabbedSectionContent>
diff --git 
a/examples/royale/TourDeJewel/src/main/royale/PopUpViewPlayGround.mxml 
b/examples/royale/TourDeJewel/src/main/royale/PopUpViewPlayGround.mxml
index ea8cde9..ffeee20 100644
--- a/examples/royale/TourDeJewel/src/main/royale/PopUpViewPlayGround.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/PopUpViewPlayGround.mxml
@@ -17,15 +17,15 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 
 -->
-<j:SectionContent xmlns:fx="http://ns.adobe.com/mxml/2009";
-                               xmlns:j="library://ns.apache.org/royale/jewel"
-                               xmlns:html="library://ns.apache.org/royale/html"
-                               xmlns:js="library://ns.apache.org/royale/basic">
+<c:ExampleAndSourceCodeTabbedSectionContent 
xmlns:fx="http://ns.adobe.com/mxml/2009";
+                                                                               
        xmlns:j="library://ns.apache.org/royale/jewel"
+                                                                               
        xmlns:html="library://ns.apache.org/royale/html"
+                                                                               
        xmlns:js="library://ns.apache.org/royale/basic"
+                                                                               
        xmlns:c="components.*" 
+                                                                               
        sourceCodeUrl="PopUpViewPlayGround.mxml">
        <fx:Script>
                <![CDATA[
-               import org.apache.royale.jewel.PopUp;
-
-                       
+               import org.apache.royale.jewel.PopUp;                   
                ]]>
        </fx:Script>
 
@@ -54,4 +54,4 @@ limitations under the License.
                        </j:Card>
                </j:GridCell>
        </j:Grid>
-</j:SectionContent>
+</c:ExampleAndSourceCodeTabbedSectionContent>
diff --git 
a/examples/royale/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
 
b/examples/royale/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
new file mode 100644
index 0000000..065acfd
--- /dev/null
+++ 
b/examples/royale/TourDeJewel/src/main/royale/components/ExampleAndSourceCodeTabbedSectionContent.as
@@ -0,0 +1,251 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 components
+{
+    import org.apache.royale.collections.ArrayList;
+    import org.apache.royale.events.Event;
+    import org.apache.royale.html.elements.Code;
+    import org.apache.royale.html.elements.Pre;
+    import org.apache.royale.jewel.SectionContent;
+    import org.apache.royale.jewel.TabBar;
+    import org.apache.royale.jewel.TabBarContent;
+
+    import services.GitHubService;
+
+    import utils.HighlightCode;
+
+    import vos.TabBarButtonVO;
+    import org.apache.royale.core.ValuesManager;
+    import org.apache.royale.utils.MXMLDataInterpreter;
+    import org.apache.royale.core.IContainerBaseStrandChildrenHost;
+    import org.apache.royale.core.IChild;
+
+    [DefaultProperty("mxmlContent")]
+
+    public class ExampleAndSourceCodeTabbedSectionContent extends 
SectionContent implements IContainerBaseStrandChildrenHost 
+       {
+        /**
+                *  constructor.
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.4
+                */
+               public function ExampleAndSourceCodeTabbedSectionContent()
+               {
+            super();
+
+            exampleTab = new SectionContent();
+            exampleTab.activableName = "exampleTab";
+            exampleTab.isActive = true;
+            contentArea = exampleTab;
+
+            addEventListener("initComplete", initCompleteHandler);
+               }
+
+        private var service:GitHubService;
+
+        private var sourceCodeUrlPrefix:String = 
"https://api.github.com/repos/apache/royale-asjs/contents/examples/royale/TourDeJewel/src/main/royale/";;
+        public var sourceCodeUrl:String;
+
+        private var tabbar:TabBar;
+        private var tabBarNavigation:ArrayList;
+
+        private var tabcontent:TabBarContent;
+
+        private var exampleTab:SectionContent;
+        private var sourceCodeTab:SectionContent;
+
+        private var sourceCodeMXMLText:Code;
+
+
+        private function initCompleteHandler(event:Event):void
+        {
+            tabBarNavigation = new ArrayList([
+                               new TabBarButtonVO("Examples", "exampleTab", 
null),
+                               new TabBarButtonVO("Source Code", 
"sourceCodeTab", null)                
+                       ]);
+
+            tabbar = new TabBar();
+            tabbar.className = "tabBarIconItemRenderer";
+            tabbar.addEventListener(Event.CHANGE, changeHandler);
+            tabbar.dataProvider = tabBarNavigation;
+            $addElement(tabbar);
+            
+            sourceCodeTab = new SectionContent();
+            sourceCodeTab.activableName = "sourceCodeTab";
+            var pre:Pre = new Pre();
+            sourceCodeMXMLText = new Code();
+            sourceCodeMXMLText.className = "xml codeExample";
+            pre.addElement(sourceCodeMXMLText);
+            sourceCodeTab.addElement(pre);
+
+            tabcontent = new TabBarContent();
+            tabcontent.addElement(exampleTab);
+            tabcontent.addElement(sourceCodeTab);
+            $addElement(tabcontent);
+            
+            service = new GitHubService();
+            service.addEventListener("dataReady", dataReadyHandler);
+            service.sourceCodeUrl = sourceCodeUrlPrefix + sourceCodeUrl;
+        }
+
+        private function changeHandler(event:Event):void
+        {
+            var item:TabBarButtonVO = (event.target as TabBar).selectedItem as 
TabBarButtonVO;
+            tabcontent.showContent(item.href);
+            if(sourceCodeTab.isActive && sourceCodeMXMLText.text == "")
+            {
+                service.getContent();
+            }
+        }
+
+        public function dataReadyHandler(event:Event):void
+        {
+            sourceCodeMXMLText.text = event.target.sourceCode;
+            
+            COMPILE::JS
+            {
+                var highlightCode:HighlightCode = new HighlightCode();
+                highlightCode.highlightBlock(sourceCodeMXMLText.element);
+            }
+        }
+
+        public function $addElement(c:IChild, dispatchEvent:Boolean = 
true):void
+               {
+                       super.addElement(c, dispatchEvent);
+               }
+               
+        /**
+         * @private
+         * @suppress {undefinedNames}
+         * Support strandChildren.
+         */
+        public function $addElementAt(c:IChild, index:int, 
dispatchEvent:Boolean = true):void
+        {
+            super.addElementAt(c, index, dispatchEvent);
+        }
+        
+               public function get $numElements():int
+               {
+                       return super.numElements;
+               }
+               
+               public function $getElementAt(index:int):IChild
+               {
+                       return super.getElementAt(index);
+               }
+               
+        /**
+         * @private
+         * @suppress {undefinedNames}
+         * Support strandChildren.
+         */
+        public function $removeElement(c:IChild, dispatchEvent:Boolean = 
true):void
+        {
+            super.removeElement(c, dispatchEvent);
+        }
+        
+        /**
+         * @private
+         * @suppress {undefinedNames}
+         * Support strandChildren.
+         */
+        public function $getElementIndex(c:IChild):int
+        {
+            return super.getElementIndex(c);
+        }
+
+        private var _contentArea:SectionContent;
+               /**
+                * The content area of the formItem.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.4
+                */
+               public function get contentArea():SectionContent
+               {
+                       return _contentArea;
+               }
+               public function set contentArea(value:SectionContent):void
+               {
+                       _contentArea = value;
+               }
+
+
+        /**
+                * @private
+                * @royaleignorecoercion org.apache.royale.html.beads.PanelView
+                */
+               override public function addElement(c:IChild, 
dispatchEvent:Boolean = true):void
+               {
+                       contentArea.addElement(c, dispatchEvent);
+                       contentArea.dispatchEvent(new Event("layoutNeeded"));
+               }
+               
+               /**
+                * @private
+                * @royaleignorecoercion org.apache.royale.html.beads.PanelView
+                */
+               override public function addElementAt(c:IChild, index:int, 
dispatchEvent:Boolean = true):void
+               {
+                       contentArea.addElementAt(c, index, dispatchEvent);
+                       contentArea.dispatchEvent(new Event("layoutNeeded"));
+               }
+               
+               /**
+                * @private
+                * @royaleignorecoercion org.apache.royale.html.beads.PanelView
+                */
+               override public function getElementIndex(c:IChild):int
+               {
+                       return contentArea.getElementIndex(c);
+               }
+               
+               /**
+                * @private
+                * @royaleignorecoercion org.apache.royale.html.beads.PanelView
+                */
+               override public function removeElement(c:IChild, 
dispatchEvent:Boolean = true):void
+               {
+                       contentArea.removeElement(c, dispatchEvent);
+               }
+               
+               /**
+                * @private
+                * @royaleignorecoercion org.apache.royale.html.beads.PanelView
+                */
+               override public function get numElements():int
+               {
+                       return contentArea.numElements;
+               }
+               
+               /**
+                * @private
+                * @royaleignorecoercion org.apache.royale.html.beads.PanelView
+                */
+               override public function getElementAt(index:int):IChild
+               {
+                       return contentArea.getElementAt(index);
+               }
+    }
+}
\ No newline at end of file

Reply via email to