| 19 |
import flash.events.Event; |
import flash.events.Event; |
| 20 |
import flash.net.registerClassAlias; |
import flash.net.registerClassAlias; |
| 21 |
|
|
| 22 |
|
import mx.core.ClassFactory; |
| 23 |
|
import mx.core.IFactory; |
| 24 |
import mx.core.IFlexModuleFactory; |
import mx.core.IFlexModuleFactory; |
|
import mx.core.UIComponent; |
|
|
import mx.events.FlexEvent; |
|
| 25 |
import mx.managers.ISystemManager; |
import mx.managers.ISystemManager; |
| 26 |
|
import mx.resources.ResourceManager; |
| 27 |
|
import mx.styles.CSSStyleDeclaration; |
| 28 |
|
import mx.styles.StyleManager; |
| 29 |
|
|
| 30 |
|
import org.seasar.akabana.yui.core.yui_internal; |
| 31 |
|
import org.seasar.akabana.yui.framework.YuiFrameworkGlobals; |
| 32 |
|
import org.seasar.akabana.yui.framework.bridge.FrameworkBridge; |
| 33 |
import org.seasar.akabana.yui.framework.convention.NamingConvention; |
import org.seasar.akabana.yui.framework.convention.NamingConvention; |
| 34 |
import org.seasar.akabana.yui.framework.core.YuiFrameworkContainer; |
import org.seasar.akabana.yui.framework.core.YuiFrameworkContainer; |
| 35 |
import org.seasar.akabana.yui.framework.util.SystemManagerUtil; |
import org.seasar.akabana.yui.framework.core.event.FrameworkEvent; |
| 36 |
import org.seasar.akabana.yui.logging.LogManager; |
import org.seasar.akabana.yui.logging.LogManager; |
| 37 |
import org.seasar.akabana.yui.logging.config.ConfigurationProvider; |
import org.seasar.akabana.yui.logging.config.ConfigurationProvider; |
| 38 |
import org.seasar.akabana.yui.logging.config.factory.LogConfigurationFactory; |
import org.seasar.akabana.yui.logging.config.factory.LogConfigurationFactory; |
| 51 |
LogConfigurationFactory; |
LogConfigurationFactory; |
| 52 |
registerClassAlias(ConfigurationProvider.FACTORY_CLASS_NAME,LogConfigurationFactory); |
registerClassAlias(ConfigurationProvider.FACTORY_CLASS_NAME,LogConfigurationFactory); |
| 53 |
} |
} |
| 54 |
|
|
| 55 |
private static var _this:YuiFrameworkMixin; |
private static var _this:YuiFrameworkMixin; |
| 56 |
|
|
| 57 |
private static var _container:YuiFrameworkContainer; |
private static var _container:YuiFrameworkContainer; |
| 58 |
|
|
| 59 |
|
private static var _namingConventionClassFactory:IFactory; |
| 60 |
|
|
| 61 |
public static function init( flexModuleFactory:IFlexModuleFactory ):void{ |
public static function init( flexModuleFactory:IFlexModuleFactory ):void{ |
|
|
|
| 62 |
LogManager.init(); |
LogManager.init(); |
| 63 |
|
|
| 64 |
_this = new YuiFrameworkMixin(); |
_this = new YuiFrameworkMixin(); |
| 65 |
_container = new YuiFrameworkContainer(); |
_container = new YuiFrameworkContainer(); |
| 66 |
|
YuiFrameworkGlobals.yui_internal::frameworkBridge = FrameworkBridge.initialize(); |
| 67 |
|
|
| 68 |
if( flexModuleFactory is ISystemManager ){ |
if( flexModuleFactory is ISystemManager ){ |
| 69 |
_container.systemManager = flexModuleFactory as ISystemManager; |
var systemManager_:ISystemManager = flexModuleFactory as ISystemManager; |
|
var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(_container.systemManager); |
|
| 70 |
|
|
| 71 |
systemManager_ |
systemManager_ |
| 72 |
.addEventListener( |
.addEventListener( |
| 73 |
Event.ADDED_TO_STAGE, |
FrameworkEvent.APPLICATION_MONITOR_START, |
| 74 |
_this.addedToStageHandler, |
applicationMonitorStartHandler, |
| 75 |
true, |
false, |
| 76 |
int.MAX_VALUE |
int.MAX_VALUE |
| 77 |
); |
); |
| 78 |
systemManager_ |
_container.yui_internal::monitoringSystemManager(systemManager_); |
|
.addEventListener( |
|
|
FlexEvent.APPLICATION_COMPLETE, |
|
|
_this.applicationCompleteHandler, |
|
|
false, |
|
|
int.MAX_VALUE |
|
|
); |
|
|
|
|
|
if( systemManager_ != flexModuleFactory ){ |
|
|
(flexModuleFactory as ISystemManager) |
|
|
.addEventListener( |
|
|
FlexEvent.APPLICATION_COMPLETE, |
|
|
_this.applicationCompleteHandler, |
|
|
false, |
|
|
int.MAX_VALUE |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
public function set conventions( value:Array ):void{ |
|
|
var namingConvention_:NamingConvention = new NamingConvention(); |
|
|
namingConvention_.conventions = value; |
|
|
_container.namingConvention = namingConvention_; |
|
|
} |
|
|
|
|
|
protected var initialized:Boolean; |
|
|
|
|
|
private function addedToStageHandler( event:Event ):void{ |
|
|
if( event.target is UIComponent ){ |
|
|
_container.registerComponent(event.target as UIComponent); |
|
| 79 |
} |
} |
| 80 |
} |
} |
|
|
|
|
private function addedHandler( event:Event ):void{ |
|
|
if( event.target is UIComponent ){ |
|
|
_container.registerComponent(event.target as UIComponent); |
|
|
} |
|
|
} |
|
|
|
|
|
private function removedHandler( event:Event ):void{ |
|
|
if( event.target is UIComponent ){ |
|
|
_container.unregisterComponent(event.target as UIComponent); |
|
|
} |
|
|
} |
|
| 81 |
|
|
| 82 |
private function applicationCompleteHandler( event:FlexEvent ):void{ |
protected static function applicationMonitorStartHandler(event:Event):void{ |
| 83 |
if( event.currentTarget is ISystemManager ){ |
initNamingConventionClassFactory(); |
| 84 |
var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(_container.systemManager); |
initNamingConvention(); |
|
systemManager_ |
|
|
.removeEventListener( |
|
|
FlexEvent.APPLICATION_COMPLETE, |
|
|
applicationCompleteHandler, |
|
|
false |
|
|
); |
|
|
|
|
|
if( systemManager_ != event.currentTarget ){ |
|
|
(event.currentTarget as ISystemManager) |
|
|
.removeEventListener( |
|
|
FlexEvent.APPLICATION_COMPLETE, |
|
|
applicationCompleteHandler, |
|
|
false |
|
|
); |
|
|
} |
|
|
|
|
|
systemManager_ |
|
|
.addEventListener( |
|
|
Event.REMOVED_FROM_STAGE, |
|
|
_this.removedHandler, |
|
|
true, |
|
|
int.MAX_VALUE |
|
|
); |
|
|
|
|
|
if( !initialized ){ |
|
|
initialized = true; |
|
|
_container.initialize(); |
|
|
} |
|
|
} |
|
| 85 |
} |
} |
| 86 |
|
|
| 87 |
|
protected static function initNamingConvention():void{ |
| 88 |
|
var namingConvention:NamingConvention = _namingConventionClassFactory.newInstance() as NamingConvention; |
| 89 |
|
namingConvention.conventions = ResourceManager.getInstance().getStringArray("conventions","package"); |
| 90 |
|
YuiFrameworkGlobals.yui_internal::namingConvention = namingConvention; |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
protected static function initNamingConventionClassFactory():void{ |
| 94 |
|
var namingConventionClassFactoryDef:CSSStyleDeclaration = StyleManager.getStyleDeclaration("org.seasar.akabana.yui.framework.core.YuiFrameworkSettings"); |
| 95 |
|
if( namingConventionClassFactoryDef == null ){ |
| 96 |
|
_namingConventionClassFactory = new ClassFactory(NamingConvention); |
| 97 |
|
} else { |
| 98 |
|
var classFactory:Class = namingConventionClassFactoryDef.getStyle("namingConventionClass") as Class; |
| 99 |
|
_namingConventionClassFactory = new ClassFactory(classFactory); |
| 100 |
|
} |
| 101 |
|
} |
| 102 |
} |
} |
| 103 |
} |
} |