[sandbox.akabana]/trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/mixin/YuiFrameworkMixin.as
Parent Directory
|
Revision Log
Revision 867 -
(hide annotations)
Fri Oct 16 15:02:01 2009 JST (3 years, 7 months ago) by e1arkw
File size: 5469 byte(s)
Fri Oct 16 15:02:01 2009 JST (3 years, 7 months ago) by e1arkw
File size: 5469 byte(s)
| 1 | e1arkw | 404 | /* |
| 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 | e1arkw | 785 | import flash.net.registerClassAlias; |
| 21 | e1arkw | 404 | |
| 22 | import mx.core.IFlexModuleFactory; | ||
| 23 | e1arkw | 448 | import mx.core.UIComponent; |
| 24 | e1arkw | 404 | import mx.events.FlexEvent; |
| 25 | import mx.managers.ISystemManager; | ||
| 26 | |||
| 27 | e1arkw | 422 | import org.seasar.akabana.yui.framework.convention.NamingConvention; |
| 28 | e1arkw | 404 | import org.seasar.akabana.yui.framework.core.YuiFrameworkContainer; |
| 29 | e1arkw | 716 | import org.seasar.akabana.yui.framework.util.SystemManagerUtil; |
| 30 | e1arkw | 431 | import org.seasar.akabana.yui.logging.LogManager; |
| 31 | e1arkw | 785 | import org.seasar.akabana.yui.logging.config.ConfigurationProvider; |
| 32 | e1arkw | 780 | import org.seasar.akabana.yui.logging.config.factory.LogConfigurationFactory; |
| 33 | e1arkw | 404 | |
| 34 | [Mixin] | ||
| 35 | e1arkw | 560 | [ResourceBundle("conventions")] |
| 36 | /** | ||
| 37 | e1arkw | 495 | * YuiFramework初期設定用Mixinクラス |
| 38 | e1arkw | 493 | * |
| 39 | * @author $Author$ | ||
| 40 | * @version $Revision$ | ||
| 41 | e1arkw | 404 | */ |
| 42 | public class YuiFrameworkMixin | ||
| 43 | { | ||
| 44 | e1arkw | 780 | { |
| 45 | LogConfigurationFactory; | ||
| 46 | e1arkw | 785 | registerClassAlias(ConfigurationProvider.FACTORY_CLASS_NAME,LogConfigurationFactory); |
| 47 | e1arkw | 780 | } |
| 48 | |||
| 49 | e1arkw | 828 | private static var _this:YuiFrameworkMixin; |
| 50 | |||
| 51 | private static var _container:YuiFrameworkContainer; | ||
| 52 | |||
| 53 | e1arkw | 404 | public static function init( flexModuleFactory:IFlexModuleFactory ):void{ |
| 54 | e1arkw | 780 | |
| 55 | e1arkw | 518 | LogManager.init(); |
| 56 | e1arkw | 657 | |
| 57 | e1arkw | 518 | _this = new YuiFrameworkMixin(); |
| 58 | _container = new YuiFrameworkContainer(); | ||
| 59 | |||
| 60 | e1arkw | 404 | if( flexModuleFactory is ISystemManager ){ |
| 61 | e1arkw | 734 | _container.systemManager = flexModuleFactory as ISystemManager; |
| 62 | var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(_container.systemManager); | ||
| 63 | e1arkw | 716 | |
| 64 | e1arkw | 717 | systemManager_ |
| 65 | .addEventListener( | ||
| 66 | Event.ADDED_TO_STAGE, | ||
| 67 | _this.addedToStageHandler, | ||
| 68 | true, | ||
| 69 | int.MAX_VALUE | ||
| 70 | ); | ||
| 71 | systemManager_ | ||
| 72 | .addEventListener( | ||
| 73 | FlexEvent.APPLICATION_COMPLETE, | ||
| 74 | _this.applicationCompleteHandler, | ||
| 75 | false, | ||
| 76 | int.MAX_VALUE | ||
| 77 | ); | ||
| 78 | e1arkw | 716 | |
| 79 | if( systemManager_ != flexModuleFactory ){ | ||
| 80 | (flexModuleFactory as ISystemManager) | ||
| 81 | .addEventListener( | ||
| 82 | FlexEvent.APPLICATION_COMPLETE, | ||
| 83 | _this.applicationCompleteHandler, | ||
| 84 | false, | ||
| 85 | int.MAX_VALUE | ||
| 86 | ); | ||
| 87 | } | ||
| 88 | e1arkw | 657 | } |
| 89 | e1arkw | 404 | } |
| 90 | |||
| 91 | public function set conventions( value:Array ):void{ | ||
| 92 | var namingConvention_:NamingConvention = new NamingConvention(); | ||
| 93 | namingConvention_.conventions = value; | ||
| 94 | _container.namingConvention = namingConvention_; | ||
| 95 | } | ||
| 96 | |||
| 97 | e1arkw | 422 | protected var initialized:Boolean; |
| 98 | |||
| 99 | e1arkw | 404 | private function addedToStageHandler( event:Event ):void{ |
| 100 | e1arkw | 468 | if( event.target is UIComponent ){ |
| 101 | _container.registerComponent(event.target as UIComponent); | ||
| 102 | } | ||
| 103 | e1arkw | 404 | } |
| 104 | e1arkw | 492 | |
| 105 | private function addedHandler( event:Event ):void{ | ||
| 106 | if( event.target is UIComponent ){ | ||
| 107 | _container.registerComponent(event.target as UIComponent); | ||
| 108 | } | ||
| 109 | e1arkw | 683 | } |
| 110 | |||
| 111 | private function removedHandler( event:Event ):void{ | ||
| 112 | if( event.target is UIComponent ){ | ||
| 113 | _container.unregisterComponent(event.target as UIComponent); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | e1arkw | 404 | |
| 117 | private function applicationCompleteHandler( event:FlexEvent ):void{ | ||
| 118 | if( event.currentTarget is ISystemManager ){ | ||
| 119 | e1arkw | 734 | var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(_container.systemManager); |
| 120 | e1arkw | 717 | systemManager_ |
| 121 | .removeEventListener( | ||
| 122 | FlexEvent.APPLICATION_COMPLETE, | ||
| 123 | applicationCompleteHandler, | ||
| 124 | false | ||
| 125 | ); | ||
| 126 | e1arkw | 716 | |
| 127 | if( systemManager_ != event.currentTarget ){ | ||
| 128 | (event.currentTarget as ISystemManager) | ||
| 129 | .removeEventListener( | ||
| 130 | FlexEvent.APPLICATION_COMPLETE, | ||
| 131 | applicationCompleteHandler, | ||
| 132 | false | ||
| 133 | ); | ||
| 134 | } | ||
| 135 | e1arkw | 867 | |
| 136 | e1arkw | 717 | systemManager_ |
| 137 | .addEventListener( | ||
| 138 | Event.REMOVED_FROM_STAGE, | ||
| 139 | _this.removedHandler, | ||
| 140 | true, | ||
| 141 | int.MAX_VALUE | ||
| 142 | e1arkw | 867 | ); |
| 143 | |||
| 144 | e1arkw | 422 | if( !initialized ){ |
| 145 | initialized = true; | ||
| 146 | e1arkw | 472 | _container.initialize(); |
| 147 | e1arkw | 422 | } |
| 148 | e1arkw | 404 | } |
| 149 | } | ||
| 150 | } | ||
| 151 | } |
Properties
| Name | Value |
|---|---|
| svn:keywords | Author Revision |
| Repository Top ViewVC Help |
![]() |
| Powered by ViewVC |

