Dashboard.mxml

<?xml version="1.0" encoding="utf-8"?>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - Copyright (c) 2009 flex-iframe
 -
 - Permission is hereby granted, free of charge, to any person obtaining a copy
 - of this software and associated documentation files (the "Software"), to deal
 - in the Software without restriction, including without limitation the rights
 - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 - copies of the Software, and to permit persons to whom the Software is
 - furnished to do so, subject to the following conditions:
 -
 - The above copyright notice and this permission notice shall be included in
 - all copies or substantial portions of the Software.
 -
 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 -  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 - THE SOFTWARE.
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - $Id: Dashboard.mxml 199 2010-05-19 21:00:39Z Julien.Nicoulaud $
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -->
<!---
    Test for Dashboard including IFrames. 
    Uses an enhanced Dashboard example from WASI (http://webappsolution.com) found here:
    http://www.adobe.com/devnet/flex/samples/dashboard/dashboard.html
    
    @author artistinclosure
    @author Julien Nicoulaud
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:managers="com.esria.dashboard.managers.*"
                applicationComplete="onApplicationComplete()"
                viewSourceURL="srcview/index.html">

    <mx:Script>
        <![CDATA[
        import com.esria.dashboard.managers.StateManager;
        import com.esria.dashboard.view.Pod;
        import com.google.code.flexiframe.IFrame;

        import mx.events.FlexEvent;

        // Stores PodLayoutManagers keyed off of a Pod.
        // Used for podLayoutManager calls after pods have been created for the first time.
        // Also, used for look-ups when saving pod content ViewStack changes.
        private var podHash:Object = new Object();

        private function onApplicationComplete():void
        {
            for (var i:int = 0; i < 4; ++i) {
                var pod:Pod = new Pod();
                pod.id = "pod" + i;
                pod.title = "IFrame " + i;
                pod.allowMinimize = true;
                pod.allowMaximize = true;
                pod.allowClose = true;
                podHash[pod.id] = pod;
                layoutmanager.addItemAt(pod, i, false);
            }

            var content:IFrame = new IFrame("frame0");
            content.percentHeight = 100;
            content.percentWidth = 100;
            content.source = "http://www.google.com";
            content.overlayDetection = true;
            podHash["pod0"].addChild(content);

            var content2:IFrame = new IFrame("frame1");
            content2.percentHeight = 100;
            content2.percentWidth = 100;
            content2.source = "http://www.yahoo.com";
            content2.overlayDetection = true;
            podHash["pod1"].addChild(content2);

            var content3:IFrame = new IFrame("frame2");
            content3.percentHeight = 100;
            content3.percentWidth = 100;
            content3.source = "http://code.google.com/p/flex-iframe";
            content3.overlayDetection = true;
            podHash["pod2"].addChild(content3);

            var content4:IFrame = new IFrame("frame3");
            content4.percentHeight = 100;
            content4.percentWidth = 100;
            content4.source = "http://code.google.com/p/flex-iframe/updates/list";
            content4.overlayDetection = true;
            podHash["pod3"].addChild(content4);

            // Listen for the last pod to complete so the layout from the ContainerWindowManager is done correctly.
            pod.addEventListener(FlexEvent.UPDATE_COMPLETE, onCreationCompletePod);
        }

        // Pod has been created so update the respective PodLayoutManager.
        private function onCreationCompletePod(e:FlexEvent):void
        {
            e.currentTarget.removeEventListener(FlexEvent.UPDATE_COMPLETE, onCreationCompletePod);
            layoutmanager.removeNullItems();
            layoutmanager.updateLayout(false);
        }
        ]]>
    </mx:Script>
    
    <!-- Stylesheet -->
    <mx:Style source="assets/dashboard.css" />

    <!-- Example project presentation -->
    <mx:ApplicationControlBar dock="true">
        <mx:Text selectable="false">
            <mx:htmlText><![CDATA[<font color="#000000" size="12"><b>Flex-IFrame - Dashboard example</b><br>This example shows several IFrames at the same time.</font>]]></mx:htmlText>
        </mx:Text>
    </mx:ApplicationControlBar>
    
    <!-- The dashboard -->
    <managers:PodLayoutManager id="layoutmanager" 
                               container="{maincanvas}" 
                               update="StateManager.setPodLayout(event)" />
        
    <mx:Canvas id="maincanvas"
               width="100%"
               height="100%" 
               horizontalScrollPolicy="off"
               verticalScrollPolicy="off"/>
   
</mx:Application>