[sandbox.akabana]/trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/mixin/YuiFrameworkMixin.as
Parent Directory
|
Revision Log
Revision 468 -
(show annotations)
Thu Jul 24 02:39:53 2008 JST (4 years, 9 months ago) by e1arkw
File size: 3720 byte(s)
Thu Jul 24 02:39:53 2008 JST (4 years, 9 months ago) by e1arkw
File size: 3720 byte(s)
| 1 | /* |
| 2 | * Copyright 2004-2008 the Seasar Foundation and the Others. |
| 3 | * |
| 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 | package org.seasar.akabana.yui.framework.mixin |
| 17 | { |
| 18 | |
| 19 | import flash.events.Event; |
| 20 | |
| 21 | import mx.core.IFlexModuleFactory; |
| 22 | import mx.core.UIComponent; |
| 23 | import mx.events.FlexEvent; |
| 24 | import mx.managers.ISystemManager; |
| 25 | |
| 26 | import org.seasar.akabana.yui.framework.convention.NamingConvention; |
| 27 | import org.seasar.akabana.yui.framework.core.YuiFrameworkContainer; |
| 28 | import org.seasar.akabana.yui.logging.LogManager; |
| 29 | |
| 30 | [Mixin] |
| 31 | [ResourceBundle("yui_framework")] |
| 32 | /** |
| 33 | * YuiFramework設定用MIXIN |
| 34 | * |
| 35 | */ |
| 36 | public class YuiFrameworkMixin |
| 37 | { |
| 38 | YuiCoreClasses; |
| 39 | LogManager.init(); |
| 40 | YuiFrameworkClasses; |
| 41 | |
| 42 | private static const _logManagerInitialized:Boolean = initLogManager(); |
| 43 | |
| 44 | private static const _this:YuiFrameworkMixin = new YuiFrameworkMixin(); |
| 45 | |
| 46 | private static const _container:YuiFrameworkContainer = new YuiFrameworkContainer(); |
| 47 | |
| 48 | public static function initLogManager():Boolean{ |
| 49 | LogManager.init(); |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | public static function init( flexModuleFactory:IFlexModuleFactory ):void{ |
| 54 | if( flexModuleFactory is ISystemManager ){ |
| 55 | var systemManager:ISystemManager = flexModuleFactory as ISystemManager; |
| 56 | systemManager.addEventListener( |
| 57 | Event.ADDED_TO_STAGE, |
| 58 | _this.addedToStageHandler, |
| 59 | true, |
| 60 | int.MAX_VALUE |
| 61 | ); |
| 62 | systemManager.addEventListener( |
| 63 | FlexEvent.APPLICATION_COMPLETE, |
| 64 | _this.applicationCompleteHandler, |
| 65 | false, |
| 66 | int.MAX_VALUE |
| 67 | ); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | public function set conventions( value:Array ):void{ |
| 72 | var namingConvention_:NamingConvention = new NamingConvention(); |
| 73 | namingConvention_.conventions = value; |
| 74 | _container.namingConvention = namingConvention_; |
| 75 | } |
| 76 | |
| 77 | protected var initialized:Boolean; |
| 78 | |
| 79 | private function addedToStageHandler( event:Event ):void{ |
| 80 | if( event.target is UIComponent ){ |
| 81 | _container.registerComponent(event.target as UIComponent); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | private function applicationCompleteHandler( event:FlexEvent ):void{ |
| 86 | if( event.currentTarget is ISystemManager ){ |
| 87 | var systemManager:ISystemManager = event.currentTarget as ISystemManager; |
| 88 | systemManager.removeEventListener( |
| 89 | Event.ADDED_TO_STAGE, |
| 90 | addedToStageHandler, |
| 91 | true |
| 92 | ); |
| 93 | systemManager.removeEventListener( |
| 94 | FlexEvent.APPLICATION_COMPLETE, |
| 95 | applicationCompleteHandler, |
| 96 | false |
| 97 | ); |
| 98 | if( !initialized ){ |
| 99 | initialized = true; |
| 100 | _container.init(); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| Repository Top ViewVC Help |
![]() |
| Powered by ViewVC |

