利用者向け情報

開発者向け情報

[sandbox.akabana]/trunk/yui-frameworks/yui-framework/src/main/flex/jp/akb7/yui/core/mixin/YuiFrameworkMixin.as

Parent Directory Parent Directory | Revision Log Revision Log


Revision 828 - (hide annotations)
Wed Sep 16 21:26:21 2009 JST (3 years, 8 months ago) by e1arkw
Original Path: trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/mixin/YuiFrameworkMixin.as
File size: 5963 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 431 [ResourceBundle("yui_framework")]
36 e1arkw 560 [ResourceBundle("conventions")]
37     /**
38 e1arkw 495 * YuiFramework初期設定用Mixinクラス
39 e1arkw 493 *
40     * @author $Author$
41     * @version $Revision$
42 e1arkw 404 */
43     public class YuiFrameworkMixin
44     {
45 e1arkw 780 {
46     LogConfigurationFactory;
47 e1arkw 785 registerClassAlias(ConfigurationProvider.FACTORY_CLASS_NAME,LogConfigurationFactory);
48 e1arkw 780 }
49    
50 e1arkw 828 private static var _this:YuiFrameworkMixin;
51    
52     private static var _container:YuiFrameworkContainer;
53    
54 e1arkw 404 public static function init( flexModuleFactory:IFlexModuleFactory ):void{
55 e1arkw 780
56 e1arkw 518 LogManager.init();
57 e1arkw 657
58 e1arkw 518 _this = new YuiFrameworkMixin();
59     _container = new YuiFrameworkContainer();
60    
61 e1arkw 404 if( flexModuleFactory is ISystemManager ){
62 e1arkw 734 _container.systemManager = flexModuleFactory as ISystemManager;
63     var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(_container.systemManager);
64 e1arkw 716
65 e1arkw 717 systemManager_
66     .addEventListener(
67     Event.ADDED_TO_STAGE,
68     _this.addedToStageHandler,
69     true,
70     int.MAX_VALUE
71     );
72     systemManager_
73     .addEventListener(
74     FlexEvent.APPLICATION_COMPLETE,
75     _this.applicationCompleteHandler,
76     false,
77     int.MAX_VALUE
78     );
79 e1arkw 716
80     if( systemManager_ != flexModuleFactory ){
81     (flexModuleFactory as ISystemManager)
82     .addEventListener(
83     FlexEvent.APPLICATION_COMPLETE,
84     _this.applicationCompleteHandler,
85     false,
86     int.MAX_VALUE
87     );
88     }
89 e1arkw 657 }
90 e1arkw 404 }
91    
92     public function set conventions( value:Array ):void{
93     var namingConvention_:NamingConvention = new NamingConvention();
94     namingConvention_.conventions = value;
95     _container.namingConvention = namingConvention_;
96     }
97    
98 e1arkw 422 protected var initialized:Boolean;
99    
100 e1arkw 404 private function addedToStageHandler( event:Event ):void{
101 e1arkw 468 if( event.target is UIComponent ){
102     _container.registerComponent(event.target as UIComponent);
103     }
104 e1arkw 404 }
105 e1arkw 492
106     private function addedHandler( event:Event ):void{
107     if( event.target is UIComponent ){
108     _container.registerComponent(event.target as UIComponent);
109     }
110 e1arkw 683 }
111    
112     private function removedHandler( event:Event ):void{
113     if( event.target is UIComponent ){
114     _container.unregisterComponent(event.target as UIComponent);
115     }
116     }
117 e1arkw 404
118     private function applicationCompleteHandler( event:FlexEvent ):void{
119     if( event.currentTarget is ISystemManager ){
120 e1arkw 734 var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(_container.systemManager);
121 e1arkw 717 systemManager_
122     .removeEventListener(
123     FlexEvent.APPLICATION_COMPLETE,
124     applicationCompleteHandler,
125     false
126     );
127 e1arkw 716
128     if( systemManager_ != event.currentTarget ){
129     (event.currentTarget as ISystemManager)
130     .removeEventListener(
131     FlexEvent.APPLICATION_COMPLETE,
132     applicationCompleteHandler,
133     false
134     );
135     }
136 e1arkw 717 systemManager_
137     .removeEventListener(
138     Event.ADDED_TO_STAGE,
139     _this.addedToStageHandler,
140     true
141     );
142     systemManager_
143     .addEventListener(
144     Event.ADDED,
145     _this.addedHandler,
146     true,
147     int.MAX_VALUE
148     );
149     systemManager_
150     .addEventListener(
151     Event.REMOVED_FROM_STAGE,
152     _this.removedHandler,
153     true,
154     int.MAX_VALUE
155     );
156 e1arkw 422 if( !initialized ){
157     initialized = true;
158 e1arkw 472 _container.initialize();
159 e1arkw 422 }
160 e1arkw 404 }
161     }
162     }
163     }

Properties

Name Value
svn:keywords Author Revision

Repository Top
ViewVC Help  
ViewVC logotype
Powered by ViewVC