利用者向け情報

開発者向け情報

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1480 - (hide annotations)
Tue Feb 15 17:50:47 2011 JST (2 years, 3 months ago) by e1arkw
Original Path: trunk/yui/yui-framework/src/main/flex/org/seasar/akabana/yui/framework/core/YuiFrameworkContainer.as
File size: 17203 byte(s)
名前空間からバージョン表記を削除しました。
1 e1arkw 404 /*
2 e1arkw 1316 * Copyright 2004-2010 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 e1arkw 404 package org.seasar.akabana.yui.framework.core
17     {
18 e1arkw 1316 CONFIG::FP10{
19     import __AS3__.vec.Vector;
20     }
21    
22     CONFIG::UNCAUGHT_ERROR_GLOBAL{
23     import flash.events.UncaughtErrorEvent;
24     }
25    
26 e1arkw 404 import flash.events.Event;
27 e1arkw 1475 import flash.errors.IllegalOperationError;
28 e1arkw 863 import flash.system.Capabilities;
29 e1arkw 1316 import flash.display.DisplayObjectContainer;
30     import flash.display.DisplayObject;
31 e1arkw 1477 import flash.utils.Dictionary;
32 e1arkw 1316
33 e1arkw 404 import mx.core.UIComponent;
34     import mx.events.FlexEvent;
35 e1arkw 716 import mx.managers.ISystemManager;
36 e1arkw 1316 import mx.managers.SystemManager;
37 e1arkw 1475 import mx.managers.CursorManager;
38     import mx.managers.PopUpManager;
39     import mx.managers.DragManager;
40     import mx.styles.IStyleManager2;
41     import mx.styles.CSSStyleDeclaration;
42 e1arkw 1316
43 e1arkw 760 import org.seasar.akabana.yui.core.Environment;
44 e1arkw 1480 import org.seasar.akabana.yui.core.ns.yui_internal;
45 e1arkw 1316
46 e1arkw 955 import org.seasar.akabana.yui.framework.YuiFrameworkGlobals;
47 e1arkw 828 import org.seasar.akabana.yui.framework.core.event.FrameworkEvent;
48 e1arkw 404 import org.seasar.akabana.yui.framework.customizer.IComponentCustomizer;
49 e1arkw 1264 import org.seasar.akabana.yui.framework.customizer.IViewCustomizer;
50     import org.seasar.akabana.yui.framework.customizer.IElementCustomizer;
51 e1arkw 683 import org.seasar.akabana.yui.framework.error.YuiFrameworkContainerError;
52 e1arkw 1264 import org.seasar.akabana.yui.framework.util.UIComponentUtil;
53 e1arkw 1316 import org.seasar.akabana.yui.framework.util.StyleManagerUtil;
54 e1arkw 1264 import org.seasar.akabana.yui.framework.core.event.RuntimeErrorEvent;
55 e1arkw 1431 import org.seasar.akabana.yui.framework.logging.debug;
56 e1arkw 1475 import org.seasar.akabana.yui.framework.logging.dump;
57 e1arkw 1431 import org.seasar.akabana.yui.framework.logging.Logging;
58 e1arkw 1480 import org.seasar.akabana.yui.core.ns.yui_internal;
59 e1arkw 1316
60     use namespace yui_internal;
61    
62 e1arkw 1034 [ExcludeClass]
63 e1arkw 903 public final class YuiFrameworkContainer extends YuiFrameworkContainerBase
64 e1arkw 1316 {
65     {
66     CursorManager;
67     PopUpManager;
68     DragManager;
69 e1arkw 1303 }
70    
71 e1arkw 1468 private static var _container:IYuiFrameworkContainer;
72 e1arkw 1316
73 e1arkw 903 public static function get yuicontainer():IYuiFrameworkContainer{
74 e1arkw 834 return _container;
75 e1arkw 683 }
76 e1arkw 1316
77 e1arkw 560 public function YuiFrameworkContainer(){
78 e1arkw 834 super();
79     if( _container == null ){
80     _container = this;
81     } else {
82     throw new YuiFrameworkContainerError("container is already created.");
83 e1arkw 1316 }
84 e1arkw 404 }
85 e1arkw 1316
86     public function addExternalSystemManager(sm:ISystemManager ):void{
87     addRootDisplayObject(sm as DisplayObject);
88 e1arkw 903 }
89 e1arkw 1264
90 e1arkw 1316 public function removeExternalSystemManager(sm:ISystemManager ):void{
91     removeRootDisplayObject(sm as DisplayObject);
92     }
93    
94     public override function customizeView( container:DisplayObjectContainer ):void{
95     var view:UIComponent = container as UIComponent;
96 e1arkw 1336 if( !view.initialized ){
97     CONFIG::DEBUG {
98 e1arkw 1431 debug(this,"customizeView:"+view+" is not initialize.");
99 e1arkw 1336 }
100 e1arkw 1316 return;
101     }
102 e1arkw 1264 CONFIG::DEBUG{
103 e1arkw 1431 debug(this,"customizeView:"+view+",owner:"+view.owner);
104 e1arkw 1264 }
105     var viewcustomizer_:IViewCustomizer;
106 e1arkw 1206 for each( var customizer_:IElementCustomizer in _customizers ){
107 e1arkw 1264 viewcustomizer_ = customizer_ as IViewCustomizer;
108     if( viewcustomizer_ != null ){
109 e1arkw 1316 viewcustomizer_.customizeView( view );
110 e1arkw 1264 }
111 e1arkw 903 }
112     }
113 e1arkw 1316
114     public override function uncustomizeView( container:DisplayObjectContainer ):void{
115     var view:UIComponent = container as UIComponent;
116     if( !view.initialized ){
117 e1arkw 1336 CONFIG::DEBUG {
118 e1arkw 1431 debug(this,"customizeView:"+view+" is not initialize.");
119 e1arkw 1336 }
120 e1arkw 1316 return;
121     }
122     CONFIG::DEBUG{
123 e1arkw 1431 debug(this,"uncustomizeView:"+view+",owner:"+view.owner);
124 e1arkw 1316 }
125 e1arkw 903 var numCustomizers:int = customizers.length;
126 e1arkw 1264 var viewcustomizer_:IViewCustomizer;
127 e1arkw 903 for( var i:int = numCustomizers-1; i >= 0; i-- ){
128 e1arkw 1213 viewcustomizer_ = customizers[i] as IViewCustomizer;
129 e1arkw 1264 if( viewcustomizer_ != null ){
130 e1arkw 1316 viewcustomizer_.uncustomizeView( view );
131 e1arkw 1264 }
132 e1arkw 903 }
133     }
134 e1arkw 1264
135 e1arkw 1316 public override function customizeComponent( container:DisplayObjectContainer, child:DisplayObject ):void{
136     var view:UIComponent = container as UIComponent;
137     var component:UIComponent = child as UIComponent;
138     if( !view.initialized || !component.initialized){
139 e1arkw 1336 CONFIG::DEBUG{
140 e1arkw 1431 debug(this,"customizeComponent:"+view+" is not initialize.");
141 e1arkw 1336 }
142 e1arkw 1316 return;
143     }
144     CONFIG::DEBUG{
145 e1arkw 1431 debug(this,"customizeComponent:start, "+child+",owner:"+container);
146 e1arkw 1316 }
147 e1arkw 1264 var componentcustomizer_:IComponentCustomizer;
148     for each( var customizer_:IElementCustomizer in _customizers ){
149     componentcustomizer_ = customizer_ as IComponentCustomizer;
150     if( componentcustomizer_ != null ){
151 e1arkw 1316 componentcustomizer_.customizeComponent( view, component );
152 e1arkw 1264 }
153     }
154 e1arkw 1346 CONFIG::DEBUG{
155 e1arkw 1431 debug(this,"customizeComponent:end, "+child+",owner:"+container);
156 e1arkw 1346 }
157 e1arkw 1264 }
158    
159 e1arkw 1316 public override function uncustomizeComponent( container:DisplayObjectContainer, child:DisplayObject ):void{
160     var view:UIComponent = container as UIComponent;
161     var component:UIComponent = child as UIComponent;
162 e1arkw 1336 if( !view.initialized ){
163     CONFIG::DEBUG{
164 e1arkw 1431 debug(this,"uncustomizeComponent:"+view+" is not initialize.");
165 e1arkw 1336 }
166 e1arkw 1316 return;
167     }
168     CONFIG::DEBUG{
169 e1arkw 1431 debug(this,"uncustomizeComponent:start, "+child+",owner:"+container);
170 e1arkw 1316 }
171 e1arkw 1264 var numCustomizers:int = customizers.length;
172     var componentcustomizer_:IComponentCustomizer;
173     for( var i:int = numCustomizers-1; i >= 0; i-- ){
174     componentcustomizer_ = customizers[i] as IComponentCustomizer;
175     if( componentcustomizer_ != null ){
176 e1arkw 1316 componentcustomizer_.uncustomizeComponent( view, component );
177 e1arkw 1264 }
178     }
179 e1arkw 1346 CONFIG::DEBUG{
180 e1arkw 1431 debug(this,"uncustomizeComponent:end, "+child+",owner:"+container);
181 e1arkw 1346 }
182 e1arkw 1316 }
183    
184 e1arkw 1125 private function applicationInitCompleteHandler( event:Event ):void{
185 e1arkw 1475 Logging.initialize();
186 e1arkw 1316 CONFIG::DEBUG_EVENT{
187 e1arkw 1475 dump(this,event);
188 e1arkw 1316 }
189 e1arkw 1125 }
190 e1arkw 1316
191 e1arkw 1125 private function applicationPreloaderDoneHandler( event:Event ):void{
192 e1arkw 1316 CONFIG::DEBUG_EVENT{
193 e1arkw 1475 dump(this,event);
194 e1arkw 903 }
195 e1arkw 1477 if( event.currentTarget is ISystemManager ){
196     var sm:ISystemManager = event.currentTarget as ISystemManager;
197     super.yui_internal::systemManagerMonitoringStart(sm as DisplayObject);
198     } else {
199     throw new IllegalOperationError("Illegal SystemManager"+event.currentTarget);
200     }
201 e1arkw 1316 YuiFrameworkGlobals.initNamingConvention();
202     CONFIG::DEBUG{
203 e1arkw 1431 debug(this,getMessage("ApplicationConventions",YuiFrameworkGlobals.public::namingConvention.conventions.toString()));
204 e1arkw 1316 }
205 e1arkw 903 }
206 e1arkw 1316
207     private function applicationCompleteHandler( event:FlexEvent ):void{
208     CONFIG::DEBUG_EVENT{
209 e1arkw 1475 dump(this,event);
210 e1arkw 1264 }
211 e1arkw 1316 applicationMonitoringStop(event.currentTarget as DisplayObject);
212 e1arkw 903 }
213 e1arkw 1303
214 e1arkw 1316 private function creationCompleteHandler(event:FlexEvent):void{
215     CONFIG::DEBUG_EVENT{
216 e1arkw 1475 dump(this,event);
217 e1arkw 1316 }
218     doAssembleComponent(event.target as DisplayObject);
219 e1arkw 1303 }
220    
221 e1arkw 1316 protected override function doRegisterComponent( target:DisplayObject ):void{
222     var component:UIComponent = target as UIComponent;
223     super.doRegisterComponent(component);
224 e1arkw 1303 }
225    
226 e1arkw 1316 protected override function doUnregisterComponent(target:DisplayObject):void{
227     var component:UIComponent = target as UIComponent;
228     if( isView(component)){
229     super.doUnregisterComponent(component);
230     } else if(isComponent(component)){
231     var document:UIComponent = component.document as UIComponent;
232     if( document != null && document.initialized && isView(document)){
233     processDisassembleViewChild(document,component);
234 e1arkw 472 }
235 e1arkw 404 }
236 e1arkw 424 }
237 e1arkw 1264
238 e1arkw 1316 protected override function doAssembleComponent( target:DisplayObject ):void{
239     var component:UIComponent = target as UIComponent;
240     if( component == null || !component.initialized ){
241     return;
242     }
243 e1arkw 1206 if( isView(component)){
244 e1arkw 1316 processAssembleView(component);
245 e1arkw 1240 } else if(isComponent(component)){
246 e1arkw 1264 var document:UIComponent = component.document as UIComponent;
247     if( document != null && document.initialized && isView(document)){
248 e1arkw 1316 processAssembleViewChild(document,component);
249 e1arkw 1264 }
250     }
251 e1arkw 842 }
252 e1arkw 1316
253     protected override function processApplicationStart():void{
254 e1arkw 1373 const app:UIComponent = YuiFrameworkGlobals.public::frameworkBridge.application as UIComponent;
255 e1arkw 1477 const rootView:DisplayObjectContainer = YuiFrameworkGlobals.public::frameworkBridge.rootView as DisplayObjectContainer;
256 e1arkw 1316 app.setVisible(true,true);
257 e1arkw 1373 super.processApplicationStart();
258 e1arkw 1477
259     var allView:Dictionary = ViewComponentRepository.allView;
260     var fevent:FrameworkEvent;
261     for each (var view:UIComponent in allView)
262     {
263     if( view === rootView ){
264     continue;
265     }
266     if( view.hasEventListener(FrameworkEvent.APPLICATION_START)){
267     fevent = new FrameworkEvent(FrameworkEvent.APPLICATION_START);
268     view.dispatchEvent( fevent );
269     }
270     }
271 e1arkw 1303 }
272    
273 e1arkw 1316 protected override function getDefaultCustomizerClasses():Array{
274     const styleManager:IStyleManager2 = StyleManagerUtil.getStyleManager();
275     const customizersDef:CSSStyleDeclaration = styleManager.getStyleDeclaration(".customizers");
276     const defaultFactory:Function = customizersDef.defaultFactory;
277    
278     const result:Array = [];
279     const keys:Array = [];
280    
281     var customizers:Object = {};
282     if (defaultFactory != null)
283     {
284     defaultFactory.prototype = {};
285     customizers = new defaultFactory();
286 e1arkw 1264 }
287 e1arkw 1316
288     var customizer:Class;
289     for( var key:String in customizers ){
290     keys.push(key);
291 e1arkw 424 }
292 e1arkw 1316 keys.sort();
293     for( var i:int = 0; i < keys.length; i++ ){
294     customizer = customizers[keys[i]] as Class;
295     result.push(customizer);
296     }
297     CONFIG::DEBUG{
298 e1arkw 1431 debug(this,"default customizers is "+result);
299 e1arkw 1316 }
300     return result;
301 e1arkw 404 }
302 e1arkw 1409
303 e1arkw 1317 yui_internal override function applicationInitialize():void{
304 e1arkw 1316 if( _customizers == null ){
305     _customizers = getDefaultCustomizers();
306     }
307     CONFIG::DEBUG{
308 e1arkw 1431 debug(this,getMessage("ViewComponentAssembleStart"));
309 e1arkw 1316 }
310    
311 e1arkw 1445 var allView:Dictionary = ViewComponentRepository.allView;
312 e1arkw 1316 var view:UIComponent;
313 e1arkw 1445 for ( var viewName:String in allView ){
314 e1arkw 1316 CONFIG::DEBUG{
315 e1arkw 1431 debug(this,getMessage("ViewComponentAssembleing",viewName));
316 e1arkw 404 }
317 e1arkw 1316 view = ViewComponentRepository.getComponent(viewName) as UIComponent;
318     if( view != null && view.initialized ){
319     processAssembleView(view);
320     }
321     CONFIG::DEBUG{
322 e1arkw 1431 debug(this,getMessage("ViewComponentAssembled",viewName));
323 e1arkw 1316 }
324 e1arkw 404 }
325 e1arkw 1316
326     CONFIG::DEBUG{
327 e1arkw 1431 debug(this,getMessage("ViewComponentAssembleEnd"));
328 e1arkw 468 }
329 e1arkw 1316 _isApplicationStarted = true;
330     callLater( processApplicationStart );
331 e1arkw 432 }
332 e1arkw 1264
333 e1arkw 1316 yui_internal override function isView(component:DisplayObject):Boolean{
334     if( component == null || !(component is UIComponent)){
335     return false;
336 e1arkw 1264 }
337 e1arkw 1316 if( YuiFrameworkGlobals.public::frameworkBridge.isContainer(component)){
338     return YuiFrameworkGlobals.public::namingConvention.isViewClassName( getCanonicalName(component) );
339     } else {
340     return false;
341 e1arkw 404 }
342 e1arkw 468 }
343 e1arkw 1264
344 e1arkw 1316 yui_internal override function isComponent( target:DisplayObject ):Boolean{
345     var component:UIComponent = target as UIComponent;
346     if( component == null || component.id == null || !(component is UIComponent)){
347     return false;
348 e1arkw 1264 }
349 e1arkw 1316 return YuiFrameworkGlobals.public::frameworkBridge.isComponent(component);
350 e1arkw 1264 }
351 e1arkw 1316
352 e1arkw 1317 yui_internal override function applicationMonitoringStart(root:DisplayObject):void{
353     root.addEventListener(
354     FlexEvent.CREATION_COMPLETE,
355     creationCompleteHandler,
356     true,
357     int.MAX_VALUE
358     );
359     super.yui_internal::applicationMonitoringStart(root);
360     }
361    
362 e1arkw 1316 yui_internal override function applicationMonitoringStop(root:DisplayObject):void{
363     root.removeEventListener(
364     FlexEvent.APPLICATION_COMPLETE,
365     applicationCompleteHandler,
366     false
367     );
368    
369     root.removeEventListener(
370     FlexEvent.INIT_COMPLETE,
371     applicationInitCompleteHandler,
372     true
373     );
374    
375     root.removeEventListener(
376     FlexEvent.PRELOADER_DONE,
377     applicationPreloaderDoneHandler,
378     true
379     );
380     super.applicationMonitoringStop(root);
381 e1arkw 842 }
382 e1arkw 1316
383     yui_internal override function systemManagerMonitoringStart( root:DisplayObject ):void{
384     root.addEventListener(
385     FlexEvent.INIT_COMPLETE,
386     applicationInitCompleteHandler,
387     true,
388     int.MAX_VALUE
389     );
390    
391     root.addEventListener(
392     FlexEvent.PRELOADER_DONE,
393     applicationPreloaderDoneHandler,
394     true,
395     int.MAX_VALUE
396     );
397    
398     root.addEventListener(
399     FlexEvent.APPLICATION_COMPLETE,
400     applicationCompleteHandler,
401     false,
402     int.MAX_VALUE
403     );
404     }
405    
406     yui_internal override function systemManagerMonitoringStop(root:DisplayObject):void{
407     const application_:DisplayObjectContainer = YuiFrameworkGlobals.public::frameworkBridge.application;
408     if( application_ != null ){
409     root.removeEventListener(
410     FlexEvent.CREATION_COMPLETE,
411     creationCompleteHandler,
412     true
413     );
414 e1arkw 1071 }
415 e1arkw 1316 super.yui_internal::systemManagerMonitoringStop(root);
416 e1arkw 1071 }
417 e1arkw 404 }
418     }

Properties

Name Value
svn:keywords Author Revision

Repository Top
ViewVC Help  
ViewVC logotype
Powered by ViewVC