[sandbox.akabana]/trunk/yui-frameworks/yui-framework/src/main/flex/jp/akb7/yui/core/YuiFrameworkController.as
Parent Directory
|
Revision Log
Revision 1669 -
(hide annotations)
Sat Aug 6 00:12:59 2011 JST (21 months, 2 weeks ago) by e1arkw
Original Path: trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/core/YuiFrameworkController.as
File size: 23726 byte(s)
Sat Aug 6 00:12:59 2011 JST (21 months, 2 weeks ago) by e1arkw
Original Path: trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/core/YuiFrameworkController.as
File size: 23726 byte(s)
リファクタリング
| 1 | e1arkw | 404 | /* |
| 2 | e1arkw | 1504 | * Copyright 2004-2011 the Seasar Foundation and the Others. |
| 3 | e1arkw | 1316 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | * you may not use this file except in compliance with the License. | ||
| 6 | * You may obtain a copy of the License at | ||
| 7 | * | ||
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | * | ||
| 10 | * Unless required by applicable law or agreed to in writing, software | ||
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| 13 | * either express or implied. See the License for the specific language | ||
| 14 | * governing permissions and limitations under the License. | ||
| 15 | */ | ||
| 16 | e1arkw | 404 | package org.seasar.akabana.yui.framework.core |
| 17 | { | ||
| 18 | e1arkw | 1316 | CONFIG::FP10{ |
| 19 | import __AS3__.vec.Vector; | ||
| 20 | } | ||
| 21 | |||
| 22 | CONFIG::UNCAUGHT_ERROR_GLOBAL{ | ||
| 23 | import flash.events.UncaughtErrorEvent; | ||
| 24 | } | ||
| 25 | |||
| 26 | e1arkw | 404 | import flash.events.Event; |
| 27 | e1arkw | 1475 | import flash.errors.IllegalOperationError; |
| 28 | e1arkw | 863 | import flash.system.Capabilities; |
| 29 | e1arkw | 1316 | import flash.display.DisplayObjectContainer; |
| 30 | import flash.display.DisplayObject; | ||
| 31 | e1arkw | 1477 | import flash.utils.Dictionary; |
| 32 | e1arkw | 1525 | import flash.display.LoaderInfo; |
| 33 | e1arkw | 1316 | |
| 34 | e1arkw | 404 | import mx.core.UIComponent; |
| 35 | import mx.events.FlexEvent; | ||
| 36 | e1arkw | 716 | import mx.managers.ISystemManager; |
| 37 | e1arkw | 1316 | import mx.managers.SystemManager; |
| 38 | e1arkw | 1475 | import mx.managers.CursorManager; |
| 39 | import mx.managers.PopUpManager; | ||
| 40 | import mx.managers.DragManager; | ||
| 41 | import mx.styles.IStyleManager2; | ||
| 42 | import mx.styles.CSSStyleDeclaration; | ||
| 43 | e1arkw | 1316 | |
| 44 | e1arkw | 760 | import org.seasar.akabana.yui.core.Environment; |
| 45 | e1arkw | 1480 | import org.seasar.akabana.yui.core.ns.yui_internal; |
| 46 | e1arkw | 1316 | |
| 47 | e1arkw | 955 | import org.seasar.akabana.yui.framework.YuiFrameworkGlobals; |
| 48 | e1arkw | 1485 | import org.seasar.akabana.yui.framework.event.YuiFrameworkEvent; |
| 49 | e1arkw | 1507 | import org.seasar.akabana.yui.framework.bridge.FrameworkBridge; |
| 50 | e1arkw | 404 | import org.seasar.akabana.yui.framework.customizer.IComponentCustomizer; |
| 51 | e1arkw | 1264 | import org.seasar.akabana.yui.framework.customizer.IViewCustomizer; |
| 52 | import org.seasar.akabana.yui.framework.customizer.IElementCustomizer; | ||
| 53 | e1arkw | 1482 | import org.seasar.akabana.yui.framework.error.YuiFrameworkError; |
| 54 | e1arkw | 1264 | import org.seasar.akabana.yui.framework.util.UIComponentUtil; |
| 55 | e1arkw | 1316 | import org.seasar.akabana.yui.framework.util.StyleManagerUtil; |
| 56 | e1arkw | 1482 | import org.seasar.akabana.yui.framework.event.RuntimeErrorEvent; |
| 57 | e1arkw | 1431 | import org.seasar.akabana.yui.framework.logging.debug; |
| 58 | e1arkw | 1475 | import org.seasar.akabana.yui.framework.logging.dump; |
| 59 | e1arkw | 1431 | import org.seasar.akabana.yui.framework.logging.Logging; |
| 60 | e1arkw | 1480 | import org.seasar.akabana.yui.core.ns.yui_internal; |
| 61 | e1arkw | 1507 | import org.seasar.akabana.yui.framework.convention.NamingConvention; |
| 62 | e1arkw | 1669 | import mx.managers.FocusManager; |
| 63 | import mx.styles.StyleManager; | ||
| 64 | e1arkw | 1316 | |
| 65 | use namespace yui_internal; | ||
| 66 | |||
| 67 | e1arkw | 1034 | [ExcludeClass] |
| 68 | e1arkw | 1669 | public final class YuiFrameworkController extends YuiFrameworkControllerBase { |
| 69 | e1arkw | 1586 | |
| 70 | e1arkw | 1669 | private static function isView(component:DisplayObject):Boolean{ |
| 71 | if( component == null ){ | ||
| 72 | return false; | ||
| 73 | } | ||
| 74 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; | ||
| 75 | if( frameworkBridge.isContainer(component)){ | ||
| 76 | const namingConvention:NamingConvention = YuiFrameworkGlobals.public::namingConvention as NamingConvention; | ||
| 77 | return namingConvention.isViewClassName( getCanonicalName(component) ); | ||
| 78 | } else { | ||
| 79 | return false; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | private static function isComponent( target:DisplayObject ):Boolean{ | ||
| 84 | if( target == null ){ | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; | ||
| 88 | return frameworkBridge.isComponent(target); | ||
| 89 | } | ||
| 90 | |||
| 91 | e1arkw | 1586 | private static function getDocumentOf(target:DisplayObject):UIComponent{ |
| 92 | e1arkw | 1669 | if( target == null || !isComponent(target) ){ |
| 93 | e1arkw | 1586 | return null; |
| 94 | } | ||
| 95 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; | ||
| 96 | return frameworkBridge.getDocumentOf(target) as UIComponent; | ||
| 97 | } | ||
| 98 | |||
| 99 | e1arkw | 1316 | { |
| 100 | CursorManager; | ||
| 101 | PopUpManager; | ||
| 102 | DragManager; | ||
| 103 | e1arkw | 1303 | } |
| 104 | |||
| 105 | e1arkw | 1520 | private static var _this:IYuiFrameworkController; |
| 106 | e1arkw | 1316 | |
| 107 | e1arkw | 1520 | public static function getInstance():IYuiFrameworkController{ |
| 108 | return _this; | ||
| 109 | e1arkw | 683 | } |
| 110 | e1arkw | 1316 | |
| 111 | e1arkw | 1523 | protected function set currentSystemManger(value:ISystemManager):void{ |
| 112 | e1arkw | 1565 | CONFIG::DEBUG{ |
| 113 | if( _currentRoot != value ){ | ||
| 114 | _debug("CurrentRoot",value); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | e1arkw | 1523 | _currentRoot = value as DisplayObject; |
| 118 | } | ||
| 119 | |||
| 120 | e1arkw | 1482 | public function YuiFrameworkController(){ |
| 121 | e1arkw | 834 | super(); |
| 122 | e1arkw | 1520 | if( _this == null ){ |
| 123 | _this = this; | ||
| 124 | e1arkw | 834 | } else { |
| 125 | e1arkw | 1482 | throw new YuiFrameworkError("container is already created."); |
| 126 | e1arkw | 1316 | } |
| 127 | e1arkw | 404 | } |
| 128 | e1arkw | 1316 | |
| 129 | public override function customizeView( container:DisplayObjectContainer ):void{ | ||
| 130 | e1arkw | 1656 | var viewCustomizer_:IViewCustomizer; |
| 131 | e1arkw | 1316 | var view:UIComponent = container as UIComponent; |
| 132 | e1arkw | 1626 | if( view == null && !isView(view) ){ |
| 133 | return; | ||
| 134 | } | ||
| 135 | CONFIG::DEBUG{ | ||
| 136 | _debug("ViewCustomizing", view, view.owner); | ||
| 137 | } | ||
| 138 | if( !view.initialized ){ | ||
| 139 | e1arkw | 1565 | CONFIG::DEBUG{ |
| 140 | _debug("ViewCustomizeInitializeError",view); | ||
| 141 | e1arkw | 1336 | } |
| 142 | e1arkw | 1316 | return; |
| 143 | } | ||
| 144 | e1arkw | 1523 | currentSystemManger = view.systemManager; |
| 145 | e1arkw | 1626 | // |
| 146 | e1arkw | 1656 | processViewRegister(view); |
| 147 | e1arkw | 1206 | for each( var customizer_:IElementCustomizer in _customizers ){ |
| 148 | e1arkw | 1656 | viewCustomizer_ = customizer_ as IViewCustomizer; |
| 149 | if( viewCustomizer_ != null ){ | ||
| 150 | viewCustomizer_.customizeView( view ); | ||
| 151 | e1arkw | 1264 | } |
| 152 | e1arkw | 903 | } |
| 153 | e1arkw | 1487 | if( view.hasEventListener(YuiFrameworkEvent.VIEW_INITIALIZED)){ |
| 154 | view.dispatchEvent( new YuiFrameworkEvent(YuiFrameworkEvent.VIEW_INITIALIZED)); | ||
| 155 | } | ||
| 156 | e1arkw | 1565 | CONFIG::DEBUG{ |
| 157 | _debug("ViewCustomized",view,view.owner); | ||
| 158 | } | ||
| 159 | e1arkw | 903 | } |
| 160 | e1arkw | 1316 | |
| 161 | public override function uncustomizeView( container:DisplayObjectContainer ):void{ | ||
| 162 | e1arkw | 1656 | var viewCustomizer_:IViewCustomizer; |
| 163 | e1arkw | 1316 | var view:UIComponent = container as UIComponent; |
| 164 | e1arkw | 1626 | if( !isView(view) ){ |
| 165 | return; | ||
| 166 | } | ||
| 167 | e1arkw | 1316 | if( !view.initialized ){ |
| 168 | e1arkw | 1336 | CONFIG::DEBUG { |
| 169 | e1arkw | 1565 | _debug("ViewUncustomizeInitializeError",view); |
| 170 | e1arkw | 1336 | } |
| 171 | e1arkw | 1316 | return; |
| 172 | } | ||
| 173 | CONFIG::DEBUG{ | ||
| 174 | e1arkw | 1565 | _debug("ViewUncustomizing",view,view.owner); |
| 175 | e1arkw | 1316 | } |
| 176 | e1arkw | 1523 | currentSystemManger = view.systemManager; |
| 177 | e1arkw | 903 | var numCustomizers:int = customizers.length; |
| 178 | for( var i:int = numCustomizers-1; i >= 0; i-- ){ | ||
| 179 | e1arkw | 1656 | viewCustomizer_ = customizers[i] as IViewCustomizer; |
| 180 | if( viewCustomizer_ != null ){ | ||
| 181 | viewCustomizer_.uncustomizeView( view ); | ||
| 182 | e1arkw | 1264 | } |
| 183 | e1arkw | 903 | } |
| 184 | e1arkw | 1626 | processViewUnregister(view); |
| 185 | e1arkw | 1565 | CONFIG::DEBUG{ |
| 186 | _debug("ViewUncustomized",view,view.owner); | ||
| 187 | } | ||
| 188 | e1arkw | 903 | } |
| 189 | e1arkw | 1264 | |
| 190 | e1arkw | 1316 | public override function customizeComponent( container:DisplayObjectContainer, child:DisplayObject ):void{ |
| 191 | e1arkw | 1669 | if( container == null || !isView(container) ){ |
| 192 | return; | ||
| 193 | } | ||
| 194 | if( child == null || !isComponent(child) ){ | ||
| 195 | return; | ||
| 196 | } | ||
| 197 | // | ||
| 198 | e1arkw | 1656 | var componentCustomizer_:IComponentCustomizer; |
| 199 | e1arkw | 1316 | var view:UIComponent = container as UIComponent; |
| 200 | var component:UIComponent = child as UIComponent; | ||
| 201 | if( !view.initialized || !component.initialized){ | ||
| 202 | e1arkw | 1336 | CONFIG::DEBUG{ |
| 203 | e1arkw | 1565 | _debug("ComponentCustomizeViewInitializeError",view,view.owner); |
| 204 | e1arkw | 1336 | } |
| 205 | e1arkw | 1316 | return; |
| 206 | } | ||
| 207 | CONFIG::DEBUG{ | ||
| 208 | e1arkw | 1565 | _debug("ComponentCustomizing",child,container); |
| 209 | e1arkw | 1316 | } |
| 210 | e1arkw | 1523 | currentSystemManger = view.systemManager; |
| 211 | e1arkw | 1264 | for each( var customizer_:IElementCustomizer in _customizers ){ |
| 212 | e1arkw | 1656 | componentCustomizer_ = customizer_ as IComponentCustomizer; |
| 213 | if( componentCustomizer_ != null ){ | ||
| 214 | componentCustomizer_.customizeComponent( view, component ); | ||
| 215 | e1arkw | 1264 | } |
| 216 | } | ||
| 217 | e1arkw | 1346 | CONFIG::DEBUG{ |
| 218 | e1arkw | 1565 | _debug("ComponentCustomized",child,container); |
| 219 | e1arkw | 1346 | } |
| 220 | e1arkw | 1264 | } |
| 221 | |||
| 222 | e1arkw | 1316 | public override function uncustomizeComponent( container:DisplayObjectContainer, child:DisplayObject ):void{ |
| 223 | e1arkw | 1669 | if( container == null || !isView(container) ){ |
| 224 | return; | ||
| 225 | } | ||
| 226 | if( child == null || !isComponent(child) ){ | ||
| 227 | return; | ||
| 228 | } | ||
| 229 | // | ||
| 230 | e1arkw | 1656 | var componentCustomizer_:IComponentCustomizer; |
| 231 | e1arkw | 1316 | var view:UIComponent = container as UIComponent; |
| 232 | var component:UIComponent = child as UIComponent; | ||
| 233 | e1arkw | 1336 | if( !view.initialized ){ |
| 234 | CONFIG::DEBUG{ | ||
| 235 | e1arkw | 1565 | _debug("ComponentUncustomizeViewInitializeError",view); |
| 236 | e1arkw | 1336 | } |
| 237 | e1arkw | 1316 | return; |
| 238 | } | ||
| 239 | CONFIG::DEBUG{ | ||
| 240 | e1arkw | 1565 | _debug("ComponentUncustomizing",child, container); |
| 241 | e1arkw | 1316 | } |
| 242 | e1arkw | 1523 | currentSystemManger = view.systemManager; |
| 243 | e1arkw | 1264 | var numCustomizers:int = customizers.length; |
| 244 | for( var i:int = numCustomizers-1; i >= 0; i-- ){ | ||
| 245 | e1arkw | 1656 | componentCustomizer_ = customizers[i] as IComponentCustomizer; |
| 246 | if( componentCustomizer_ != null ){ | ||
| 247 | componentCustomizer_.uncustomizeComponent( view, component ); | ||
| 248 | e1arkw | 1264 | } |
| 249 | } | ||
| 250 | e1arkw | 1346 | CONFIG::DEBUG{ |
| 251 | e1arkw | 1565 | _debug("ComponentUncustomized",child, container); |
| 252 | e1arkw | 1346 | } |
| 253 | e1arkw | 1316 | } |
| 254 | |||
| 255 | e1arkw | 1581 | private function application_initCompleteHandler( event:Event ):void{ |
| 256 | e1arkw | 1475 | Logging.initialize(); |
| 257 | e1arkw | 1316 | CONFIG::DEBUG_EVENT{ |
| 258 | e1arkw | 1475 | dump(this,event); |
| 259 | e1arkw | 1316 | } |
| 260 | e1arkw | 1125 | } |
| 261 | e1arkw | 1316 | |
| 262 | e1arkw | 1581 | private function application_preloaderDoneHandler( event:Event ):void{ |
| 263 | e1arkw | 1316 | CONFIG::DEBUG_EVENT{ |
| 264 | e1arkw | 1475 | dump(this,event); |
| 265 | e1arkw | 903 | } |
| 266 | e1arkw | 1477 | if( event.currentTarget is ISystemManager ){ |
| 267 | e1arkw | 1624 | var root:ISystemManager = event.currentTarget as ISystemManager; |
| 268 | CONFIG::DEBUG{ | ||
| 269 | _info("SystemManagerMonitoringStart",root); | ||
| 270 | } | ||
| 271 | registerRootDisplayObject(root as DisplayObject); | ||
| 272 | |||
| 273 | //detecting component addition for register | ||
| 274 | root.addEventListener( | ||
| 275 | Event.ADDED_TO_STAGE, | ||
| 276 | systemManager_addedToStageHandler, | ||
| 277 | true, | ||
| 278 | int.MAX_VALUE | ||
| 279 | ); | ||
| 280 | e1arkw | 1477 | } else { |
| 281 | throw new IllegalOperationError("Illegal SystemManager"+event.currentTarget); | ||
| 282 | } | ||
| 283 | e1arkw | 1316 | YuiFrameworkGlobals.initNamingConvention(); |
| 284 | CONFIG::DEBUG{ | ||
| 285 | e1arkw | 1565 | _debug("ApplicationConventions",YuiFrameworkGlobals.public::namingConvention.conventions.toString()); |
| 286 | e1arkw | 1316 | } |
| 287 | e1arkw | 903 | } |
| 288 | e1arkw | 1316 | |
| 289 | e1arkw | 1581 | private function application_applicationCompleteHandler( event:FlexEvent ):void{ |
| 290 | e1arkw | 1316 | CONFIG::DEBUG_EVENT{ |
| 291 | e1arkw | 1475 | dump(this,event); |
| 292 | e1arkw | 1264 | } |
| 293 | e1arkw | 1624 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; |
| 294 | const root:DisplayObject = frameworkBridge.systemManager; | ||
| 295 | systemManagerMonitoringStop(root); | ||
| 296 | applicationInitialize(); | ||
| 297 | e1arkw | 903 | } |
| 298 | e1arkw | 1303 | |
| 299 | e1arkw | 1624 | private function systemManager_addedToStageHandler( event:Event ):void{ |
| 300 | CONFIG::DEBUG_EVENT{ | ||
| 301 | dump(this,event); | ||
| 302 | } | ||
| 303 | var component:UIComponent = event.target as UIComponent; | ||
| 304 | if( component == null || !component.initialized ){ | ||
| 305 | return; | ||
| 306 | } | ||
| 307 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; | ||
| 308 | if( frameworkBridge.application == null && frameworkBridge.isApplication(component) ){ | ||
| 309 | e1arkw | 1669 | processApplicationRegisteration(component as DisplayObjectContainer); |
| 310 | e1arkw | 1624 | } else { |
| 311 | processViewRegister(component); | ||
| 312 | } | ||
| 313 | } | ||
| 314 | |||
| 315 | e1arkw | 1581 | private function systemManager_creationCompleteHandler(event:FlexEvent):void{ |
| 316 | e1arkw | 1316 | CONFIG::DEBUG_EVENT{ |
| 317 | e1arkw | 1475 | dump(this,event); |
| 318 | e1arkw | 1316 | } |
| 319 | e1arkw | 1624 | doRegisterComponent(event.target as DisplayObject); |
| 320 | e1arkw | 1303 | } |
| 321 | |||
| 322 | e1arkw | 1669 | private function applicationInitialize():void{ |
| 323 | |||
| 324 | if( _customizers == null ){ | ||
| 325 | _customizers = getDefaultCustomizers(); | ||
| 326 | } | ||
| 327 | CONFIG::DEBUG{ | ||
| 328 | _debug("ViewAssembleStart"); | ||
| 329 | } | ||
| 330 | |||
| 331 | var allView:Dictionary = ViewComponentRepository.allView; | ||
| 332 | for ( var viewName:String in allView ){ | ||
| 333 | CONFIG::DEBUG{ | ||
| 334 | _debug("ViewAssembleing",viewName); | ||
| 335 | } | ||
| 336 | customizeView(ViewComponentRepository.getComponent(viewName)); | ||
| 337 | CONFIG::DEBUG{ | ||
| 338 | _debug("ViewAssembled",viewName); | ||
| 339 | } | ||
| 340 | } | ||
| 341 | |||
| 342 | CONFIG::DEBUG{ | ||
| 343 | _debug("ViewAssembleEnd"); | ||
| 344 | } | ||
| 345 | callLater( processApplicationStart ); | ||
| 346 | } | ||
| 347 | |||
| 348 | protected override function getDefaultCustomizerClasses():Array{ | ||
| 349 | const styleManager:IStyleManager2 = StyleManagerUtil.getStyleManager(); | ||
| 350 | const customizersDef:CSSStyleDeclaration = styleManager.getStyleDeclaration(".customizers"); | ||
| 351 | const defaultFactory:Function = customizersDef.defaultFactory; | ||
| 352 | |||
| 353 | const result:Array = []; | ||
| 354 | const keys:Array = []; | ||
| 355 | |||
| 356 | var customizers:Object = {}; | ||
| 357 | var customizer:Class; | ||
| 358 | var numKeys:int; | ||
| 359 | |||
| 360 | if (defaultFactory != null){ | ||
| 361 | defaultFactory.prototype = {}; | ||
| 362 | customizers = new defaultFactory(); | ||
| 363 | } | ||
| 364 | |||
| 365 | for( var key:String in customizers ){ | ||
| 366 | keys.push(key); | ||
| 367 | } | ||
| 368 | keys.sort(); | ||
| 369 | numKeys = keys.length; | ||
| 370 | for( var i:int = 0; i < numKeys; i++ ){ | ||
| 371 | customizer = customizers[keys[i]] as Class; | ||
| 372 | result.push(customizer); | ||
| 373 | } | ||
| 374 | CONFIG::DEBUG{ | ||
| 375 | _debug("CustomizerLoaded",result); | ||
| 376 | } | ||
| 377 | return result; | ||
| 378 | } | ||
| 379 | |||
| 380 | e1arkw | 1316 | protected override function doRegisterComponent( target:DisplayObject ):void{ |
| 381 | e1arkw | 1668 | const settings:YuiFrameworkSettings = YuiFrameworkGlobals.public::settings; |
| 382 | |||
| 383 | e1arkw | 1316 | var component:UIComponent = target as UIComponent; |
| 384 | e1arkw | 1519 | if( component == null || !component.initialized ){ |
| 385 | return; | ||
| 386 | } | ||
| 387 | e1arkw | 1668 | if( isView(component) ){ |
| 388 | e1arkw | 1624 | customizeView(component); |
| 389 | e1arkw | 1668 | } else { |
| 390 | if( settings.isAutoMonitoring ){ | ||
| 391 | e1arkw | 1669 | customizeComponent(getDocumentOf(component),component); |
| 392 | e1arkw | 472 | } |
| 393 | e1arkw | 404 | } |
| 394 | e1arkw | 424 | } |
| 395 | e1arkw | 1264 | |
| 396 | e1arkw | 1624 | protected override function doUnregisterComponent(target:DisplayObject):void{ |
| 397 | e1arkw | 1668 | const settings:YuiFrameworkSettings = YuiFrameworkGlobals.public::settings; |
| 398 | |||
| 399 | e1arkw | 1316 | var component:UIComponent = target as UIComponent; |
| 400 | if( component == null || !component.initialized ){ | ||
| 401 | return; | ||
| 402 | } | ||
| 403 | e1arkw | 1206 | if( isView(component)){ |
| 404 | e1arkw | 1624 | uncustomizeView( component as DisplayObjectContainer); |
| 405 | e1arkw | 1668 | } else { |
| 406 | if( settings.isAutoMonitoring ){ | ||
| 407 | e1arkw | 1669 | uncustomizeComponent(getDocumentOf(component),component); |
| 408 | e1arkw | 1264 | } |
| 409 | } | ||
| 410 | e1arkw | 842 | } |
| 411 | e1arkw | 1316 | |
| 412 | e1arkw | 1669 | private function processApplicationRegisteration(component:DisplayObjectContainer):void{ |
| 413 | CONFIG::DEBUG{ | ||
| 414 | _debug("ApplicationRegistered",component.toString()); | ||
| 415 | } | ||
| 416 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; | ||
| 417 | frameworkBridge.application = component; | ||
| 418 | Environment.yui_internal::setRoot( component ); | ||
| 419 | Environment.yui_internal::setParameters( frameworkBridge.parameters ); | ||
| 420 | e1arkw | 1660 | |
| 421 | e1arkw | 1581 | const root:DisplayObject = frameworkBridge.systemManager; |
| 422 | e1arkw | 1506 | CONFIG::UNCAUGHT_ERROR_GLOBAL{ |
| 423 | root.loaderInfo.uncaughtErrorEvents | ||
| 424 | .addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, loaderInfoUncaughtErrorHandler,false,int.MAX_VALUE); | ||
| 425 | } | ||
| 426 | if( root is SystemManager ){ | ||
| 427 | var sm:SystemManager = root as SystemManager; | ||
| 428 | var preloadedRSLs:Dictionary = sm.preloadedRSLs; | ||
| 429 | e1arkw | 1656 | var loaderInfo:LoaderInfo; |
| 430 | e1arkw | 1506 | |
| 431 | for( var item:Object in preloadedRSLs ){ | ||
| 432 | e1arkw | 1656 | loaderInfo = item as LoaderInfo; |
| 433 | e1arkw | 1506 | CONFIG::DEBUG{ |
| 434 | debug(this,"preloadedRSLs:"+loaderInfo.url); | ||
| 435 | } | ||
| 436 | CONFIG::UNCAUGHT_ERROR_GLOBAL{ | ||
| 437 | loaderInfo.loader.uncaughtErrorEvents | ||
| 438 | .addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, loaderInfoUncaughtErrorHandler,false,int.MAX_VALUE); | ||
| 439 | } | ||
| 440 | } | ||
| 441 | } | ||
| 442 | } | ||
| 443 | |||
| 444 | e1arkw | 1669 | private function processApplicationStart():void{ |
| 445 | e1arkw | 1507 | const frameworkBridge:FrameworkBridge = YuiFrameworkGlobals.public::frameworkBridge as FrameworkBridge; |
| 446 | e1arkw | 1625 | const settings:YuiFrameworkSettings = YuiFrameworkGlobals.public::settings; |
| 447 | e1arkw | 1669 | |
| 448 | e1arkw | 1624 | const root:DisplayObject = frameworkBridge.systemManager; |
| 449 | e1arkw | 1507 | const app:UIComponent = frameworkBridge.application as UIComponent; |
| 450 | const rootView:DisplayObjectContainer = frameworkBridge.rootView as DisplayObjectContainer; | ||
| 451 | e1arkw | 1669 | CONFIG::DEBUG{ |
| 452 | _info("ApplicationStart"); | ||
| 453 | } | ||
| 454 | |||
| 455 | e1arkw | 1316 | app.setVisible(true,true); |
| 456 | e1arkw | 1669 | if( rootView != null ){ |
| 457 | if( rootView.hasEventListener(YuiFrameworkEvent.APPLICATION_START)){ | ||
| 458 | rootView.dispatchEvent( new YuiFrameworkEvent(YuiFrameworkEvent.APPLICATION_START)); | ||
| 459 | } | ||
| 460 | rootView.visible = true; | ||
| 461 | } | ||
| 462 | |||
| 463 | e1arkw | 1477 | var allView:Dictionary = ViewComponentRepository.allView; |
| 464 | e1arkw | 1485 | var fevent:YuiFrameworkEvent; |
| 465 | e1arkw | 1477 | for each (var view:UIComponent in allView) |
| 466 | { | ||
| 467 | if( view === rootView ){ | ||
| 468 | continue; | ||
| 469 | } | ||
| 470 | e1arkw | 1485 | if( view.hasEventListener(YuiFrameworkEvent.APPLICATION_START)){ |
| 471 | fevent = new YuiFrameworkEvent(YuiFrameworkEvent.APPLICATION_START); | ||
| 472 | e1arkw | 1477 | view.dispatchEvent( fevent ); |
| 473 | } | ||
| 474 | } | ||
| 475 | e1arkw | 1660 | _isApplicationStarted = true; |
| 476 | e1arkw | 1625 | |
| 477 | e1arkw | 1634 | if( settings.isAutoMonitoring ){ |
| 478 | e1arkw | 1625 | componentMonitoringStart(root); |
| 479 | } | ||
| 480 | e1arkw | 1303 | } |
| 481 | e1arkw | 1669 | |
| 482 | private function processViewRegister( container:DisplayObjectContainer ):void{ | ||
| 483 | if( isView(container)){ | ||
| 484 | const namingConvention:NamingConvention = YuiFrameworkGlobals.public::namingConvention; | ||
| 485 | const componentId:String = namingConvention.getComponentName(container); | ||
| 486 | if( !ViewComponentRepository.hasComponent( componentId )){ | ||
| 487 | ViewComponentRepository.addComponent( container ); | ||
| 488 | CONFIG::DEBUG{ | ||
| 489 | _debug("ViewRegistered",container.toString()); | ||
| 490 | } | ||
| 491 | } | ||
| 492 | e1arkw | 1264 | } |
| 493 | e1arkw | 404 | } |
| 494 | e1arkw | 1669 | |
| 495 | private function processViewUnregister( container:DisplayObjectContainer ):void{ | ||
| 496 | if( isView(container)){ | ||
| 497 | const namingConvention:NamingConvention = YuiFrameworkGlobals.public::namingConvention; | ||
| 498 | const componentId:String = namingConvention.getComponentName(container); | ||
| 499 | if( ViewComponentRepository.hasComponent( componentId )){ | ||
| 500 | ViewComponentRepository.removeComponent( container ); | ||
| 501 | CONFIG::DEBUG{ | ||
| 502 | _debug("ViewUnRegistered",container.toString()); | ||
| 503 | } | ||
| 504 | e1arkw | 404 | } |
| 505 | } | ||
| 506 | e1arkw | 432 | } |
| 507 | e1arkw | 1264 | |
| 508 | e1arkw | 1660 | yui_internal function systemManagerMonitoringStart( root:DisplayObject ):void{ |
| 509 | e1arkw | 1626 | Logging.initialize(); |
| 510 | e1arkw | 1660 | root.addEventListener( |
| 511 | FlexEvent.INIT_COMPLETE, | ||
| 512 | application_initCompleteHandler, | ||
| 513 | true, | ||
| 514 | int.MAX_VALUE | ||
| 515 | ); | ||
| 516 | |||
| 517 | root.addEventListener( | ||
| 518 | FlexEvent.PRELOADER_DONE, | ||
| 519 | application_preloaderDoneHandler, | ||
| 520 | true, | ||
| 521 | int.MAX_VALUE | ||
| 522 | ); | ||
| 523 | |||
| 524 | root.addEventListener( | ||
| 525 | FlexEvent.APPLICATION_COMPLETE, | ||
| 526 | application_applicationCompleteHandler, | ||
| 527 | false, | ||
| 528 | int.MAX_VALUE | ||
| 529 | ); | ||
| 530 | } | ||
| 531 | e1arkw | 1317 | |
| 532 | e1arkw | 1624 | yui_internal function systemManagerMonitoringStop( root:DisplayObject ):void{ |
| 533 | |||
| 534 | e1arkw | 1316 | root.removeEventListener( |
| 535 | FlexEvent.APPLICATION_COMPLETE, | ||
| 536 | e1arkw | 1581 | application_applicationCompleteHandler, |
| 537 | e1arkw | 1316 | false |
| 538 | ); | ||
| 539 | |||
| 540 | root.removeEventListener( | ||
| 541 | FlexEvent.INIT_COMPLETE, | ||
| 542 | e1arkw | 1581 | application_initCompleteHandler, |
| 543 | e1arkw | 1316 | true |
| 544 | ); | ||
| 545 | |||
| 546 | root.removeEventListener( | ||
| 547 | FlexEvent.PRELOADER_DONE, | ||
| 548 | e1arkw | 1581 | application_preloaderDoneHandler, |
| 549 | e1arkw | 1316 | true |
| 550 | ); | ||
| 551 | e1arkw | 1624 | root.removeEventListener( |
| 552 | Event.ADDED_TO_STAGE, | ||
| 553 | systemManager_addedToStageHandler, | ||
| 554 | true | ||
| 555 | ); | ||
| 556 | } | ||
| 557 | e1arkw | 1660 | |
| 558 | yui_internal override function componentMonitoringStart(root:DisplayObject):void{ | ||
| 559 | e1arkw | 1624 | super.componentMonitoringStart(root); |
| 560 | e1arkw | 1660 | root.addEventListener( |
| 561 | FlexEvent.CREATION_COMPLETE, | ||
| 562 | systemManager_creationCompleteHandler, | ||
| 563 | true, | ||
| 564 | int.MAX_VALUE | ||
| 565 | ); | ||
| 566 | } | ||
| 567 | |||
| 568 | yui_internal override function componentMonitoringStop(root:DisplayObject):void{ | ||
| 569 | e1arkw | 1624 | super.componentMonitoringStop(root); |
| 570 | e1arkw | 1660 | root.addEventListener( |
| 571 | FlexEvent.CREATION_COMPLETE, | ||
| 572 | systemManager_creationCompleteHandler, | ||
| 573 | true, | ||
| 574 | int.MAX_VALUE | ||
| 575 | ); | ||
| 576 | } | ||
| 577 | e1arkw | 404 | } |
| 578 | } |
Properties
| Name | Value |
|---|---|
| svn:keywords | Author Revision |
| Repository Top ViewVC Help |
![]() |
| Powered by ViewVC |

