利用者向け情報

開発者向け情報

[sandbox.akabana]/trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/mixin/YuiFrameworkMixin.as

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:keywords Author Revision

Repository Top
ViewVC Help  
ViewVC logotype
Powered by ViewVC