利用者向け情報

開発者向け情報

[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 717 - (show annotations)
Sat Apr 11 21:03:28 2009 JST (4 years, 1 month ago) by e1arkw
File size: 5576 byte(s)
遅延ロードによって、SystemManagerが複数ある場合の不具合に対応
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.framework.util.SystemManagerUtil;
29 import org.seasar.akabana.yui.logging.LogManager;
30
31 [Mixin]
32 [ResourceBundle("yui_framework")]
33 [ResourceBundle("conventions")]
34 /**
35 * YuiFramework初期設定用Mixinクラス
36 *
37 * @author $Author$
38 * @version $Revision$
39 */
40 public class YuiFrameworkMixin
41 {
42 private static var _this:YuiFrameworkMixin;
43
44 private static var _container:YuiFrameworkContainer;
45
46 public static function init( flexModuleFactory:IFlexModuleFactory ):void{
47 LogManager.init();
48
49 _this = new YuiFrameworkMixin();
50 _container = new YuiFrameworkContainer();
51
52 if( flexModuleFactory is ISystemManager ){
53 var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(flexModuleFactory as ISystemManager);
54
55 systemManager_
56 .addEventListener(
57 Event.ADDED_TO_STAGE,
58 _this.addedToStageHandler,
59 true,
60 int.MAX_VALUE
61 );
62 systemManager_
63 .addEventListener(
64 FlexEvent.APPLICATION_COMPLETE,
65 _this.applicationCompleteHandler,
66 false,
67 int.MAX_VALUE
68 );
69
70 if( systemManager_ != flexModuleFactory ){
71 (flexModuleFactory as ISystemManager)
72 .addEventListener(
73 FlexEvent.APPLICATION_COMPLETE,
74 _this.applicationCompleteHandler,
75 false,
76 int.MAX_VALUE
77 );
78 }
79 }
80 }
81
82 public function set conventions( value:Array ):void{
83 var namingConvention_:NamingConvention = new NamingConvention();
84 namingConvention_.conventions = value;
85 _container.namingConvention = namingConvention_;
86 }
87
88 protected var initialized:Boolean;
89
90 private function addedToStageHandler( event:Event ):void{
91 if( event.target is UIComponent ){
92 _container.registerComponent(event.target as UIComponent);
93 }
94 }
95
96 private function addedHandler( event:Event ):void{
97 if( event.target is UIComponent ){
98 _container.registerComponent(event.target as UIComponent);
99 }
100 }
101
102 private function removedHandler( event:Event ):void{
103 if( event.target is UIComponent ){
104 _container.unregisterComponent(event.target as UIComponent);
105 }
106 }
107
108 private function applicationCompleteHandler( event:FlexEvent ):void{
109 if( event.currentTarget is ISystemManager ){
110 var systemManager_:ISystemManager = SystemManagerUtil.getRootSystemManager(event.currentTarget as ISystemManager);
111 systemManager_
112 .removeEventListener(
113 FlexEvent.APPLICATION_COMPLETE,
114 applicationCompleteHandler,
115 false
116 );
117
118 if( systemManager_ != event.currentTarget ){
119 (event.currentTarget as ISystemManager)
120 .removeEventListener(
121 FlexEvent.APPLICATION_COMPLETE,
122 applicationCompleteHandler,
123 false
124 );
125 }
126 systemManager_
127 .removeEventListener(
128 Event.ADDED_TO_STAGE,
129 _this.addedToStageHandler,
130 true
131 );
132 systemManager_
133 .addEventListener(
134 Event.ADDED,
135 _this.addedHandler,
136 true,
137 int.MAX_VALUE
138 );
139 systemManager_
140 .addEventListener(
141 Event.REMOVED_FROM_STAGE,
142 _this.removedHandler,
143 true,
144 int.MAX_VALUE
145 );
146 if( !initialized ){
147 initialized = true;
148 _container.initialize();
149 }
150 }
151 }
152 }
153 }

Properties

Name Value
svn:keywords Author Revision

Repository Top
ViewVC Help  
ViewVC logotype
Powered by ViewVC