Changeset 1405

Show
Ignore:
Timestamp:
05/19/2008 09:54:36 PM (14 months ago)
Author:
thijs
Message:

Buildbot example update (#298)

Location:
examples/trunk/buildbot/flex/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • examples/trunk/buildbot/flex/src/org/pyamf/examples/buildbot/BuildbotBase.as

    r1402 r1405  
    1010        import flash.events.NetStatusEvent; 
    1111         
     12        import mx.collections.ArrayCollection; 
    1213        import mx.core.Application; 
    1314        import mx.utils.URLUtil; 
    1415         
     16        import org.pyamf.examples.buildbot.events.BuildEvent; 
    1517        import org.pyamf.examples.buildbot.events.BuildbotEvent; 
     18        import org.pyamf.examples.buildbot.events.BuilderEvent; 
    1619         
    1720        [Event(name="update", type="org.pyamf.examples.buildbot.events.BuildbotEvent")] 
     
    1922         
    2023        /** 
    21          * This examples shows how to communicate with Buildbot and query the build status. 
     24         * This examples shows how to communicate with Buildbot and query 
     25         * the build status. 
    2226         *  
    2327         * @author Thijs Triemstra (info@collab.nl) 
     
    3337                public var status:String = ""; 
    3438                 
     39                /** 
     40                 * Setup gateway url.  
     41                 */              
    3542                public function BuildbotBase() 
    3643                { 
     
    6471                } 
    6572                 
     73                protected function loadComplete( event:BuilderEvent ):void 
     74        { 
     75                var rows:ArrayCollection = new ArrayCollection(event.builder.rows); 
     76                var columns:Array = new Array(); 
     77                 
     78                for (var d:int=0;d<_builders.length;d++) 
     79                        { 
     80                                columns.push(_builders[d].name); 
     81                        } 
     82                dispatchEvent( new BuildbotEvent(BuildbotEvent.UPDATE, rows, columns) ); 
     83        } 
     84         
     85        protected function addBuilders(result:*): void 
     86        { 
     87                        if (result != null) 
     88                        { 
     89                                for (var d:int=0;d<result.length;d++) 
     90                                { 
     91                                        var builder:Builder = new Builder(result[d]); 
     92                                        builder.addEventListener(BuilderEvent.STATUS, getBuilderStatus); 
     93                                        builder.addEventListener(BuilderEvent.LAST_BUILDS, getLastBuilds); 
     94                                        builder.addEventListener(BuilderEvent.LOAD_COMPLETE, loadComplete); 
     95                                        builder.addEventListener(BuildEvent.BUILD_DETAILS, getBuild); 
     96                                        builder.load(); 
     97                                         
     98                                        _builders.push( builder ); 
     99                                } 
     100                        status = result.length + " builder(s) loaded."; 
     101                        } 
     102                        else 
     103                        { 
     104                                var columns:Array = new Array(); 
     105                                var rows:ArrayCollection = new ArrayCollection(); 
     106                                 
     107                                status = "No builders available."; 
     108                                dispatchEvent( new BuildbotEvent(BuildbotEvent.UPDATE) ); 
     109                        } 
     110        } 
     111         
     112        public function getBuilderStatus(event:BuilderEvent): void 
     113        { 
     114        } 
     115         
     116        public function getLastBuilds(event:BuilderEvent): void 
     117        { 
     118        } 
     119         
     120        public function getBuild(event:BuildEvent): void 
     121        { 
     122        } 
     123         
    66124        protected function onNetstatusError(event:NetStatusEvent): void 
    67125        { 
     
    74132        } 
    75133         
     134        /** 
     135         * Notify the user of the problem. 
     136         *  
     137         * @param error 
     138         */         
    76139        protected function onFault( error:* ): void 
    77140        { 
    78             // notify the user of the problem 
    79141            var errorStr:String = ""; 
    80142            for (var d:String in error) { 
  • examples/trunk/buildbot/flex/src/org/pyamf/examples/buildbot/BuildbotRPC.as

    r1403 r1405  
    1111        import flash.net.Responder; 
    1212         
    13         import mx.collections.ArrayCollection; 
    14          
    15         import org.pyamf.examples.buildbot.events.*; 
    16         import org.pyamf.examples.buildbot.Builder; 
     13        import org.pyamf.examples.buildbot.events.BuildEvent; 
     14        import org.pyamf.examples.buildbot.events.BuilderEvent; 
    1715         
    1816        /** 
    19          * This examples shows how to communicate with the AMF gateway for Buildbot that can 
    20          * be used to query the build status. 
     17         * This examples shows how to communicate with the AMF gateway for 
     18         * Buildbot that can be used to query the build status. 
    2119         *  
    2220         * @author Thijs Triemstra (info@collab.nl) 
     
    3432                private static const GETALLBUILDSINTERVAL:String        = "buildbot.getAllBuildsInInterval"; 
    3533                 
     34                /** 
     35                 * Create AMF connection. 
     36                 */              
    3637                public function BuildbotRPC() 
    3738                { 
     
    4041                        _builders = new Array(); 
    4142                         
    42                         // setup connection 
    4343            _gateway = new NetConnection(); 
    4444            _gateway.addEventListener(NetStatusEvent.NET_STATUS, onNetstatusError); 
     
    4646                } 
    4747                 
     48                /** 
     49                 * Connect to gateway and get builders. 
     50                 *  
     51                 * @param gatewayUrl AMF gateway of the buildbot 
     52                 */              
    4853                public function connect(gatewayUrl:String=undefined): void 
    4954                { 
    5055                        status = "Loading..."; 
    5156                         
    52                         // Setup url 
    5357                        if (gatewayUrl != null) { 
    5458                                _url = gatewayUrl; 
    5559                        } 
    5660                         
    57             // Connect to gateway 
    5861            _gateway.connect(_url); 
    5962             
    60             // Get builders 
    6163            getBuilders(); 
    6264                } 
    6365                 
    64                 private function addBuilders(result:*): void 
    65         { 
    66                         if (result != null) 
    67                         { 
    68                                 for (var d:int=0;d<result.length;d++) 
    69                                 { 
    70                                         var builder:Builder = new Builder(result[d]); 
    71                                         builder.addEventListener(BuilderEvent.STATUS, getBuilderStatus); 
    72                                         builder.addEventListener(BuilderEvent.LAST_BUILDS, getLastBuilds); 
    73                                         builder.addEventListener(BuilderEvent.LOAD_COMPLETE, loadComplete); 
    74                                         builder.addEventListener(BuildEvent.BUILD_DETAILS, getBuild); 
    75                                         builder.load(); 
    76                                         _builders.push( builder ); 
    77                                 } 
    78                                  
    79                         status = result.length + " builder(s) loaded."; 
    80                         } 
    81                         else 
    82                         { 
    83                                 var columns:Array = new Array(); 
    84                                 var rows:ArrayCollection = new ArrayCollection(); 
    85                                  
    86                                 status = "No builder available."; 
    87                                 dispatchEvent( new BuildbotEvent(BuildbotEvent.UPDATE) ); 
    88                         } 
    89         } 
    90                  
    91                 private function loadComplete( event:BuilderEvent ):void 
    92         { 
    93                 var rows:ArrayCollection = new ArrayCollection(event.builder.builds); 
    94                 var columns:Array = new Array(); 
    95                  
    96                 for (var d:int=0;d<_builders.length;d++) 
    97                         { 
    98                                 columns.push(_builders[d].name); 
    99                         } 
    100                  
    101                 dispatchEvent( new BuildbotEvent(BuildbotEvent.UPDATE, rows, columns) ); 
    102         } 
    103          
     66                /** 
     67                 * Call remote service to fetch a list of all builder names.  
     68                 */              
    10469                private function getBuilders():void 
    10570                { 
    106                         // Set responder property to the object and methods that will receive the  
    107             // result or fault condition that the service returns. 
    10871            var responder:Responder = new Responder( addBuilders, onFault ); 
    10972             
    110             // Call remote service to fetch a list of all builder names. 
    11173            _gateway.call( GETALLBUILDERS, responder); 
    11274                } 
    11375                 
    114                 private function getBuilderStatus( event:BuilderEvent ):void 
     76                /** 
     77                 * Call remote service to fetch the result of the last build for the 
     78                 * given builder. 
     79                 *  
     80                 * @param event 
     81                 */              
     82                override public function getBuilderStatus( event:BuilderEvent ):void 
    11583                { 
    11684                        var builder:Builder = event.builder; 
    117  
    118                         // Set responder property to the object and methods that will receive the  
    119             // result or fault condition that the service returns. 
    12085            var responder:Responder = new Responder( builder.setStatus, onFault ); 
    12186             
    122             // Call remote service to fetch the result of the last build for the given builder. 
    12387            _gateway.call( GETSTATUS, responder, builder.name ); 
    12488                } 
    12589                 
    126         private function getLastBuilds( event:BuilderEvent ):void 
     90        /** 
     91         * Call remote service to fetch the result of the last build for the 
     92                 * given builder. 
     93         *   
     94         * @param event 
     95         */              
     96        override public function getLastBuilds( event:BuilderEvent ):void 
    12797        { 
    12898                var builder:Builder = event.builder; 
    129              
    130                 // Set responder property to the object and methods that will receive the  
    131             // result or fault condition that the service returns. 
    13299            var responder:Responder = new Responder( builder.addBuilds, onFault ); 
    133100             
    134             // Call remote service to fetch the result of the last build for the given builder. 
    135101            _gateway.call( GETLASTBUILDS, responder, builder.name, _totalBuilds ); 
    136102        } 
    137103         
    138         private function getBuild( event:BuildEvent ):void 
     104        /** 
     105         * Call remote service to fetch information about a specific build. 
     106         *  
     107         * @param event 
     108         */         
     109        override public function getBuild( event:BuildEvent ):void 
    139110        { 
    140111            var builder:Builder = event.build.builder; 
    141              
    142                 // Set responder property to the object and methods that will receive the  
    143             // result or fault condition that the service returns. 
    144112            var responder:Responder = new Responder( builder.setBuild, onFault ); 
    145113             
    146             // Call remote service to fetch information about a specific build. 
    147114            _gateway.call( GETBUILD, responder, builder.name, event.build.number ); 
    148115        } 
    149116         
    150         // not used atm 
    151         private function getAllBuildsInInterval( event:BuilderEvent ):void 
     117        /** 
     118         * Call remote service to fetch a list of builds that have completed after 
     119             * the 'start' timestamp and before the 'stop' timestamp. This looks at 
     120                 * all builders. 
     121                 *  
     122                 * Note: not being used in this app. 
     123                 *  
     124         * @param event 
     125         */         
     126        internal function getAllBuildsInInterval( event:BuilderEvent ):void 
    152127        { 
    153                 var builder:Builder = event.builder; 
    154128                var start:int = 1000; 
    155129            var stop:int = 2000; 
    156              
    157                 // Set responder property to the object and methods that will receive the  
    158             // result or fault condition that the service returns. 
     130                var builder:Builder = event.builder; 
    159131            var responder:Responder = new Responder( builder.addBuilds, onFault ); 
    160132             
    161             // Call remote service to fetch a list of builds that have completed 
    162                         // after the 'start' timestamp and before the 'stop' timestamp. This looks 
    163                         // at all builders. 
    164133            _gateway.call( GETALLBUILDSINTERVAL, responder, start, stop ); 
    165134        } 
  • examples/trunk/buildbot/flex/src/org/pyamf/examples/buildbot/Builder.as

    r1403 r1405  
    1010        import org.pyamf.examples.buildbot.events.BuildEvent; 
    1111        import org.pyamf.examples.buildbot.events.BuilderEvent; 
     12        import org.pyamf.examples.buildbot.vo.BuildDetails; 
    1213        import org.pyamf.examples.buildbot.vo.BuildInfo; 
    13         import org.pyamf.examples.buildbot.vo.BuildDetails; 
    1414         
    1515        [Event(name="status", type="org.pyamf.examples.buildbot.events.BuilderEvent")] 
     
    2828                private var _lastBuildSuccess: Boolean; 
    2929                private var _builds: Array = new Array(); 
     30                private var _rows: Array = new Array(); 
    3031                private var _buildDetails: Array = new Array(); 
    3132                 
    3233                public static const SUCCESS:String      = "success"; 
    3334                public static const FAILED:String       = "failed"; 
     35                 
     36                public function Builder(name:String="") 
     37                { 
     38                        _name = name; 
     39                } 
    3440                 
    3541                public function get name():String 
     
    4349                } 
    4450                 
    45                 public function Builder( name:String="" ) 
     51                public function get rows():Array 
    4652                { 
    47                         _name = name; 
     53                        return _buildDetails; 
     54                } 
     55                 
     56                public function get lastBuildSuccess():Boolean 
     57                { 
     58                        return _lastBuildSuccess; 
    4859                } 
    4960                 
     
    90101                if (_buildDetails.length == _builds.length) 
    91102                        { 
    92                                 //Alert.show(_builds[0].toString() + " : " + _buildDetails[0].builder_name); 
     103                                var tmp:Array = new Array(); 
     104                                for (var s:int=0;s<_builds.length;s++) { 
     105                                        _buildDetails[s].number = _builds[s].number; 
     106                                        _buildDetails[s].revision = _builds[s].revision; 
     107                                } 
     108                                 
    93109                        loadComplete(); 
    94110                } 
  • examples/trunk/buildbot/flex/src/org/pyamf/examples/buildbot/view/CellField.as

    r1403 r1405  
    4040             {  
    4141                 text = value[DataGridListData(listData).dataField];  
    42                  if (Number(text) > 100)  
     42                 if (Number(text) == 0)  
    4343                 {  
    4444                     setStyle("backgroundColor", 0xFF0000);  
  • examples/trunk/buildbot/flex/src/org/pyamf/examples/buildbot/view/Waterfall.mxml

    r1403 r1405  
    44        <mx:Script> 
    55                <![CDATA[ 
     6                        import mx.charts.events.ChartItemEvent; 
    67                        import mx.controls.dataGridClasses.DataGridColumn; 
    78                        import mx.collections.ArrayCollection; 
     
    2324                                } 
    2425                                 
    25                                 dg.columns = dgColumns; 
    26                                 dg.dataProvider = results; 
     26                                //dg.columns = dgColumns; 
     27                                chart.dataProvider = results; 
    2728                                this.status = status; 
    2829                        } 
     30                         
     31                        private function zoomIntoSeries(e:Event):void 
     32                        { 
     33                        } 
    2934                ]]> 
    3035        </mx:Script> 
    3136         
    32         <mx:DataGrid width="100%" height="100%" 
    33                                  horizontalScrollPolicy="on" 
    34                                  variableRowHeight="true" 
    35                                  id="dg" verticalGridLines="false" 
    36                                  horizontalGridLines="false" 
    37                                  alternatingItemColors="white"/> 
    38          
     37        <mx:SeriesSlide id="slideIn" duration="1000" direction="down"/> 
     38    <mx:SeriesSlide id="slideOut" duration="1000" direction="up"/> 
     39     
     40     <mx:ColumnChart id="chart"  
     41        showDataTips="true" width="100%" height="100%" 
     42        itemClick="zoomIntoSeries(event)"> 
     43        <mx:series>  
     44            <mx:ColumnSeries id="cs1"  
     45                displayName="Warning"  
     46                yField="start"  
     47                xField="number" 
     48                hideDataEffect="slideOut"  
     49                showDataEffect="slideIn"/> 
     50             
     51             <mx:ColumnSeries id="s2"  
     52                    displayName="Success"  
     53                    yField=""   
     54                    xField="end"   
     55                    click="zoomIntoSeries(event)" 
     56                /> 
     57        </mx:series>             
     58 
     59        <mx:verticalAxis> 
     60            <mx:DateTimeAxis title="Date" dataUnits="hours"/> 
     61        </mx:verticalAxis> 
     62    </mx:ColumnChart> 
     63     
    3964</mx:Panel> 
  • examples/trunk/buildbot/flex/src/org/pyamf/examples/buildbot/vo/BuildDetails.as

    r1403 r1405  
    1313        public class BuildDetails 
    1414        { 
     15                [Transient] 
     16                public var number:int; 
     17                 
     18                [Transient] 
     19                public var revision:int; 
     20                 
    1521                public var builder_name:String; 
    1622                public var url:String; 
  • examples/trunk/buildbot/flex/src/rpc.mxml

    r1403 r1405  
    1717                        private function creationComplete():void 
    1818                        { 
    19                                 buildbot  = new BuildbotRPC(); 
    20                                 buildbot.totalBuilds = 10; 
     19                                buildbot = new BuildbotRPC(); 
     20                                buildbot.totalBuilds = 20; 
    2121                                buildbot.addEventListener(BuildbotEvent.UPDATE, onUpdate); 
    2222                                buildbot.addEventListener(BuildbotEvent.ERROR, onError); 
    23                                 buildbot.connect("http://buildbot.pyamf.org/amf"); 
     23                                buildbot.connect("http://localhost:8010/amf"); 
    2424                                 
    2525                                waterfall.title = "Buildbot: PyAMF";