@@ -49,46 +49,84 @@ package org.bigbluebutton.modules.layout.managers
49
49
import org.bigbluebutton.modules.layout.model.WindowLayout ;
50
50
import org.bigbluebutton.util.i18n.ResourceUtil ;
51
51
52
- public class LayoutManager extends EventDispatcher {
53
- private var _layouts : LayoutDefinitionFile = null ;
54
- private var _canvas : MDICanvas = null ;
55
- private var _globalDispatcher : Dispatcher = new Dispatcher();
56
- private var _locked : Boolean = false ;
57
- private var _currentLayout : LayoutDefinition = null ;
58
- private var _detectContainerChange : Boolean = true ;
59
- private var _containerDeactivated : Boolean = false ;
60
- private var _sendCurrentLayoutUpdateTimer : Timer = new Timer (500 ,1 );
61
- private var _applyCurrentLayoutTimer : Timer = new Timer (150 ,1 );
62
- private var _customLayoutsCount : int = 0 ;
63
- private var _eventsToDelay : Array = new Array (MDIManagerEvent. WINDOW_RESTORE ,
64
- MDIManagerEvent. WINDOW_MINIMIZE ,
65
- MDIManagerEvent. WINDOW_MAXIMIZE );
66
-
67
- public function LayoutManager () {
68
- _applyCurrentLayoutTimer . addEventListener (TimerEvent . TIMER , function (e: TimerEvent ): void {
69
- applyLayout(_currentLayout );
70
- });
71
- _sendCurrentLayoutUpdateTimer . addEventListener (TimerEvent . TIMER , function (e: TimerEvent ): void {
72
- sendLayoutUpdate(updateCurrentLayout());
73
- });
74
- }
52
+ public class LayoutManager extends EventDispatcher {
53
+ private var _layouts : LayoutDefinitionFile = null ;
54
+ private var _canvas : MDICanvas = null ;
55
+ private var _globalDispatcher : Dispatcher = new Dispatcher();
56
+ private var _locked : Boolean = false ;
57
+ private var _currentLayout : LayoutDefinition = null ;
58
+ private var _detectContainerChange : Boolean = true ;
59
+ private var _containerDeactivated : Boolean = false ;
60
+ private var _sendCurrentLayoutUpdateTimer : Timer = new Timer (500 ,1 );
61
+ private var _applyCurrentLayoutTimer : Timer = new Timer (150 ,1 );
62
+ private var _delayToSendLayoutsToCombobox : Timer = new Timer (60 ,0 );
63
+ private var _customLayoutsCount : int = 0 ;
64
+ private var comboboxIsInitialized: Boolean = false ;
65
+ private var _eventsToDelay : Array = new Array (MDIManagerEvent. WINDOW_RESTORE ,
66
+ MDIManagerEvent. WINDOW_MINIMIZE ,
67
+ MDIManagerEvent. WINDOW_MAXIMIZE );
68
+
69
+
70
+ public function LayoutManager () {
71
+ _applyCurrentLayoutTimer . addEventListener (TimerEvent . TIMER , function (e: TimerEvent ): void {
72
+ applyLayout(_currentLayout );
73
+ });
74
+ _sendCurrentLayoutUpdateTimer . addEventListener (TimerEvent . TIMER , function (e: TimerEvent ): void {
75
+ sendLayoutUpdate(updateCurrentLayout());
76
+ });
77
+
78
+ _delayToSendLayoutsToCombobox . addEventListener (TimerEvent . TIMER , function (e: TimerEvent ): void {
79
+ checkIfCanSendLayoutToCombobox();
80
+ });
81
+ }
82
+
83
+
84
+ public function sendPopulateComboboxEvent ():void {
85
+ LogUtil. debug ("Sending layout to populate combobox" );
86
+ var sendLayoutsLoaded: LayoutsLoadedEvent = new LayoutsLoadedEvent(LayoutsLoadedEvent. SEND_LAYOUTS_LOADED_EVENT );
87
+ sendLayoutsLoaded. layouts = _layouts ;
88
+ _globalDispatcher . dispatchEvent (sendLayoutsLoaded);
89
+ }
90
+
91
+
92
+ public function initDelayTimerUntilComboboxIsInitialized ():void {
93
+ _delayToSendLayoutsToCombobox . start ();
94
+ }
95
+
96
+
97
+ public function checkIfCanSendLayoutToCombobox ():void {
98
+ if (comboboxIsInitialized) {
99
+ if (_delayToSendLayoutsToCombobox != null ) {
100
+ _delayToSendLayoutsToCombobox . stop ();
101
+ }
102
+ sendPopulateComboboxEvent();
103
+ }
104
+ }
75
105
76
106
public function loadServerLayouts (layoutUrl :String ):void {
77
107
LogUtil. debug ("LayoutManager: loading server layouts from " + layoutUrl);
78
108
var loader : LayoutLoader = new LayoutLoader();
79
109
loader . addEventListener (LayoutsLoadedEvent. LAYOUTS_LOADED_EVENT , function (e: LayoutsLoadedEvent): void {
80
110
if (e. success) {
81
111
_layouts = e. layouts;
82
- LogUtil. debug ("LayoutManager: layouts loaded successfully" );
83
-
84
-
112
+ if (comboboxIsInitialized) {
113
+ sendPopulateComboboxEvent();
114
+ }
115
+ else {
116
+ initDelayTimerUntilComboboxIsInitialized();
117
+ }
118
+ LogUtil. debug ("LayoutManager: layouts loaded successfully" );
85
119
} else {
86
120
LogUtil. error ("LayoutManager: layouts not loaded (" + e. error . message + ")" );
87
121
}
88
122
});
89
123
loader . loadFromUrl(layoutUrl);
90
124
}
91
125
126
+ public function comboboxInitialized ():void {
127
+ comboboxIsInitialized = true ;
128
+ }
129
+
92
130
public function saveLayoutsToFile ():void {
93
131
var _fileRef : FileReference = new FileReference ();
94
132
_fileRef . addEventListener (Event . COMPLETE , function (e: Event ): void {
@@ -106,13 +144,15 @@ package org.bigbluebutton.modules.layout.managers
106
144
/*
107
145
* \TODO why do I need to create a new Event for this?
108
146
*/
109
- var layoutsLoaded: LayoutsLoadedEvent = new LayoutsLoadedEvent();
110
- layoutsLoaded. layouts = _layouts ;
111
- _globalDispatcher . dispatchEvent (layoutsLoaded);
147
+ // var layoutsLoaded:LayoutsLoadedEvent = new LayoutsLoadedEvent();
148
+ // layoutsLoaded.layouts = _layouts;
149
+ // _globalDispatcher.dispatchEvent(layoutsLoaded);
112
150
/*
113
151
* it will update the ComboBox label, and will go back to this class
114
152
* to apply the default layout
115
153
*/
154
+
155
+ sendPopulateComboboxEvent();
116
156
_globalDispatcher . dispatchEvent (new LayoutEvent (LayoutEvent . APPLY_DEFAULT_LAYOUT_EVENT ));
117
157
118
158
Alert . show (ResourceUtil. getInstance (). getString ('bbb.layout.load.complete' ), "" , Alert . OK , _canvas );
@@ -346,5 +386,5 @@ package org.bigbluebutton.modules.layout.managers
346
386
if (_canvas != null )
347
387
applyLayout(_currentLayout );
348
388
}
349
- }
350
- }
389
+ }
390
+ }
0 commit comments