@@ -24,12 +24,12 @@ import org.mvcexpress.MvcExpress;
2424 */
2525public class MvcExpressLogger {
2626
27- static private const LOG_LABEL : String = "LOG" ;
28- static private const MESSAGES_LABEL : String = "MESSAGES" ;
29- static private const MEDIATORS_LABEL : String = "MEDIATORS" ;
30- static private const PROXIES_LABEL : String = "PROXIES" ;
31- static private const COMMANDS_LABEL : String = "COMMANDS" ;
32- static private const VISUALIZER_LABEL : String = "VISUALIZER" ;
27+ static public const LOG_TAB : String = "LOG" ;
28+ static public const MESSAGES_TAB : String = "MESSAGES" ;
29+ static public const MEDIATORS_TAB : String = "MEDIATORS" ;
30+ static public const PROXIES_TAB : String = "PROXIES" ;
31+ static public const COMMANDS_TAB : String = "COMMANDS" ;
32+ static public const VISUALIZER_TAB : String = "VISUALIZER" ;
3333 //
3434 static private var allowInstantiation: Boolean ;
3535 static private var instance: MvcExpressLogger;
@@ -62,14 +62,15 @@ public class MvcExpressLogger {
6262 private var isRenderWaiting: Boolean = false ;
6363 private var autoLogCheckBox: CheckBox ;
6464 private var useAutoScroll: Boolean = true ;
65+ private var initTab: String ;
6566
6667 public function MvcExpressLogger () {
6768 if (! allowInstantiation) {
6869 throw Error ("MvcExpressLogger is singleton and will be instantiated with first use or MvcExpressLogger.init() or MvcExpressLogger.showIn()" );
6970 }
7071 }
7172
72- static public function init (stage :Stage , x :int = 0 , y :int = 0 , width :int = 600 , height :int = 400 , alpha :Number = 0.9 , autoShow :Boolean = false , openKeyCode :int = 192 , isCtrlKeyNeeded :Boolean = true , isShiftKeyNeeded :Boolean = false , isAltKeyNeeded :Boolean = false ):void {
73+ static public function init (stage :Stage , x :int = 0 , y :int = 0 , width :int = 600 , height :int = 400 , alpha :Number = 0.9 , autoShow :Boolean = false , initTab : String = "LOG" , openKeyCode :int = 192 , isCtrlKeyNeeded :Boolean = true , isShiftKeyNeeded :Boolean = false , isAltKeyNeeded :Boolean = false ):void {
7374
7475 if (! instance) {
7576 allowInstantiation = true ;
@@ -86,6 +87,7 @@ public class MvcExpressLogger {
8687 instance. width = width ;
8788 instance. height = height ;
8889 instance. alpha = alpha ;
90+ instance. initTab = initTab;
8991 instance. openKeyCode = openKeyCode;
9092 instance. isCtrlKeyNeeded = isCtrlKeyNeeded;
9193 instance. isShiftKeyNeeded = isShiftKeyNeeded;
@@ -130,42 +132,42 @@ public class MvcExpressLogger {
130132 setTimeout(resolveCurrentModuleName, 1 );
131133 } else {
132134 switch (currentTabButtonName) {
133- case LOG_LABEL :
135+ case LOG_TAB :
134136 render();
135137 break ;
136- case MESSAGES_LABEL :
138+ case MESSAGES_TAB :
137139 if (logType == "••" || logType == "•>" ) {
138140 if (! isRenderWaiting) {
139141 isRenderWaiting = true ;
140142 setTimeout(render, 1 );
141143 }
142144 }
143145 break ;
144- case MEDIATORS_LABEL :
146+ case MEDIATORS_TAB :
145147 if (logType == "§§" ) {
146148 if (! isRenderWaiting) {
147149 isRenderWaiting = true ;
148150 setTimeout(render, 1 );
149151 }
150152 }
151153 break ;
152- case PROXIES_LABEL :
154+ case PROXIES_TAB :
153155 if (logType == "¶¶" ) {
154156 if (! isRenderWaiting) {
155157 isRenderWaiting = true ;
156158 setTimeout(render, 1 );
157159 }
158160 }
159161 break ;
160- case COMMANDS_LABEL :
162+ case COMMANDS_TAB :
161163 if (logType == "©©" ) {
162164 if (! isRenderWaiting) {
163165 isRenderWaiting = true ;
164166 setTimeout(render, 1 );
165167 }
166168 }
167169 break ;
168- case VISUALIZER_LABEL :
170+ case VISUALIZER_TAB :
169171 break ;
170172 default :
171173 }
@@ -213,31 +215,31 @@ public class MvcExpressLogger {
213215
214216 allButtons = new Vector .< PushButton> ();
215217
216- var logButton: PushButton = new PushButton(logWindow, 0 , - 0 , LOG_LABEL , handleButtonClick);
218+ var logButton: PushButton = new PushButton(logWindow, 0 , - 0 , LOG_TAB , handleButtonClick);
217219 logButton. toggle = true ;
218220 logButton. width = 50 ;
219221 logButton. x = moduleStepper. x + moduleStepper. width + 10 ;
220222 allButtons. push (logButton);
221223
222- var messageMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , MESSAGES_LABEL , handleButtonClick);
224+ var messageMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , MESSAGES_TAB , handleButtonClick);
223225 messageMapingButton. toggle = true ;
224226 messageMapingButton. width = 60 ;
225227 messageMapingButton. x = allButtons[ allButtons. length - 1 ] . x + allButtons[ allButtons. length - 1 ] . width + 5 ;
226228 allButtons. push (messageMapingButton);
227229
228- var mediatorMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , MEDIATORS_LABEL , handleButtonClick);
230+ var mediatorMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , MEDIATORS_TAB , handleButtonClick);
229231 mediatorMapingButton. toggle = true ;
230232 mediatorMapingButton. width = 60 ;
231233 mediatorMapingButton. x = allButtons[ allButtons. length - 1 ] . x + allButtons[ allButtons. length - 1 ] . width + 5 ;
232234 allButtons. push (mediatorMapingButton);
233235
234- var proxyMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , PROXIES_LABEL , handleButtonClick);
236+ var proxyMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , PROXIES_TAB , handleButtonClick);
235237 proxyMapingButton. toggle = true ;
236238 proxyMapingButton. width = 50 ;
237239 proxyMapingButton. x = allButtons[ allButtons. length - 1 ] . x + allButtons[ allButtons. length - 1 ] . width + 5 ;
238240 allButtons. push (proxyMapingButton);
239241
240- var commandMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , COMMANDS_LABEL , handleButtonClick);
242+ var commandMapingButton: PushButton = new PushButton(logWindow, 0 , - 0 , COMMANDS_TAB , handleButtonClick);
241243 commandMapingButton. toggle = true ;
242244 commandMapingButton. width = 60 ;
243245 commandMapingButton. x = allButtons[ allButtons. length - 1 ] . x + allButtons[ allButtons. length - 1 ] . width + 5 ;
@@ -252,7 +254,7 @@ public class MvcExpressLogger {
252254 autoLogCheckBox. x = allButtons[ allButtons. length - 1 ] . x + allButtons[ allButtons. length - 1 ] . width + 70 ;
253255 autoLogCheckBox. selected = true ;
254256
255- var visualizerButton: PushButton = new PushButton(logWindow, 0 , - 0 , VISUALIZER_LABEL , handleButtonClick);
257+ var visualizerButton: PushButton = new PushButton(logWindow, 0 , - 0 , VISUALIZER_TAB , handleButtonClick);
256258 visualizerButton. toggle = true ;
257259 visualizerButton. width = 60 ;
258260 visualizerButton. x = 600 ;
@@ -264,7 +266,19 @@ public class MvcExpressLogger {
264266
265267 resolveCurrentModuleName();
266268
267- handleButtonClick();
269+ delayedAutoButtonClick()
270+ }
271+
272+ private function delayedAutoButtonClick ():void {
273+ if (! currentTabButtonName) {
274+ resolveCurrentModuleName();
275+ if (currentModuleName != "" ) {
276+ handleButtonClick();
277+ } else {
278+ setTimeout(delayedAutoButtonClick, 100 );
279+ }
280+ }
281+
268282 }
269283
270284 private function handleClearLog (event :MouseEvent ):void {
@@ -319,8 +333,17 @@ public class MvcExpressLogger {
319333 if (event) {
320334 var targetButton: PushButton = (event. target as PushButton);
321335 } else {
336+ // select first button by default.
322337 targetButton = allButtons[ 0 ];
323338 targetButton. selected = true ;
339+ // if initTab properly passed - start with that tab.
340+ for (var j: int = 0 ; j < allButtons. length ; j++ ) {
341+ if (allButtons[ j] . label == initTab) {
342+ targetButton = allButtons[ j];
343+ targetButton. selected = true ;
344+ break ;
345+ }
346+ }
324347 }
325348
326349 if (currentTogleButton != targetButton) {
@@ -337,10 +360,10 @@ public class MvcExpressLogger {
337360 }
338361 currentTabButtonName = targetButton. label ;
339362
340- autoLogCheckBox. visible = (currentTabButtonName == LOG_LABEL )
363+ autoLogCheckBox. visible = (currentTabButtonName == LOG_TAB )
341364
342365 switch (currentTabButtonName) {
343- case VISUALIZER_LABEL :
366+ case VISUALIZER_TAB :
344367 currentScreen = new MvcExpressVisualizerScreen(width - 6 , height - 52 );
345368 currentScreen. x = 3 ;
346369 currentScreen. y = 25 ;
@@ -368,27 +391,27 @@ public class MvcExpressLogger {
368391 isRenderWaiting = false ;
369392
370393 switch (currentTabButtonName) {
371- case LOG_LABEL :
394+ case LOG_TAB :
372395 (currentScreen as MvcExpressLogScreen). showLog(logText);
373396 (currentScreen as MvcExpressLogScreen). scrollDown(useAutoScroll);
374397 break ;
375- case MESSAGES_LABEL :
398+ case MESSAGES_TAB :
376399 (currentScreen as MvcExpressLogScreen). showLog(ModuleManager . listMappedMessages(currentModuleName));
377400 (currentScreen as MvcExpressLogScreen). scrollDown(false );
378401 break ;
379- case MEDIATORS_LABEL :
402+ case MEDIATORS_TAB :
380403 (currentScreen as MvcExpressLogScreen). showLog(ModuleManager . listMappedMediators(currentModuleName));
381404 (currentScreen as MvcExpressLogScreen). scrollDown(false );
382405 break ;
383- case PROXIES_LABEL :
406+ case PROXIES_TAB :
384407 (currentScreen as MvcExpressLogScreen). showLog(ModuleManager . listMappedProxies(currentModuleName));
385408 (currentScreen as MvcExpressLogScreen). scrollDown(false );
386409 break ;
387- case COMMANDS_LABEL :
410+ case COMMANDS_TAB :
388411 (currentScreen as MvcExpressLogScreen). showLog(ModuleManager . listMappedCommands(currentModuleName));
389412 (currentScreen as MvcExpressLogScreen). scrollDown(false );
390413 break ;
391- case VISUALIZER_LABEL :
414+ case VISUALIZER_TAB :
392415
393416 break ;
394417 default :
0 commit comments