Permalink
Browse files

miscellaneous fixes

  • Loading branch information...
1 parent 47acb91 commit b0988571408b95ec0d70e8514f3da30b86cae766 @darscan committed Mar 29, 2012
View
@@ -0,0 +1,2 @@
+Thumbs.db
+.DS_Store
Binary file not shown.
@@ -6,17 +6,14 @@
xmlns:example="org.robotlegs.example.*"
xmlns:views="org.robotlegs.example.view.*">
- <fx:Script>
- <![CDATA[
-
- ]]>
- </fx:Script>
<fx:Declarations>
<rl2:ContextBuilderTag>
+ <example:LoggerConfig/>
<mvcs:MVCSBundle/>
<example:AppConfig />
</rl2:ContextBuilderTag>
</fx:Declarations>
- <views:MainView />
+ <views:MainView width="100%" height="100%" />
+
</s:Application>
@@ -5,74 +5,59 @@
* Time: 1:36 PM
* To change this template use File | Settings | File Templates.
*/
-package org.robotlegs.example {
- import flash.display.DisplayObject;
- import flash.display.DisplayObjectContainer;
-
- import org.as3commons.logging.level.DEBUG;
-
- import org.hamcrest.object.instanceOf;
-
- import org.robotlegs.example.controller.GetSomeTextCommand;
- import org.robotlegs.example.model.ExampleModel;
- import org.robotlegs.example.service.ExampleService;
- import org.robotlegs.example.service.IExampleService;
- import org.robotlegs.example.view.MainView;
- import org.robotlegs.example.view.api.INewWindow;
- import org.robotlegs.example.view.mediator.MainViewMediator;
- import org.robotlegs.example.view.api.IMainView;
- import org.robotlegs.example.view.events.GetSomeTextEvent;
- import org.robotlegs.example.view.mediator.NewWindowMediator;
-
- import org.swiftsuspenders.Injector;
-
- import robotlegs.bender.extensions.eventCommandMap.api.IEventCommandMap;
- import robotlegs.bender.extensions.mediatorMap.api.IMediatorMap;
- import robotlegs.bender.framework.context.api.IContext;
- import robotlegs.bender.framework.context.api.IContextExtension;
-
- import spark.components.Application;
-
- use namespace DEBUG;
-
- public class AppConfig implements IContextExtension{
- private var injector : Injector;
- private var mediatorMap:IMediatorMap;
- private var commandMap:IEventCommandMap;
-
- private var _context:IContext;
-
-
- public function extend(context:IContext):void {
- _context = context;
- context.logLevel = DEBUG;
- context.addConfigHandler(instanceOf(DisplayObject), handleContextView);
- }
-
- private function handleContextView(contextView:DisplayObjectContainer):void {
-
-
- injector = _context.injector;
- mediatorMap = injector.getInstance(IMediatorMap);
- commandMap = injector.getInstance(IEventCommandMap);
-
- // View
- mediatorMap.mapView(IMainView).toMediator(MainViewMediator);
- mediatorMap.mapView(INewWindow).toMediator(NewWindowMediator);
-
- // Model
- injector.map(ExampleModel);
-
- // service
- injector.map(IExampleService).toSingleton(ExampleService);
-
- // controller
- commandMap.map(GetSomeTextEvent.GET_SOME_TEXT, GetSomeTextEvent).toCommand(GetSomeTextCommand);
-
- const main:MainView = new MainView();
- main.percentWidth = 100;
- main.percentHeight = 100;
- Application(contextView).addElement(main);
- }
- }
+package org.robotlegs.example
+{
+ import flash.display.DisplayObjectContainer;
+ import org.robotlegs.example.controller.GetSomeTextCommand;
+ import org.robotlegs.example.model.ExampleModel;
+ import org.robotlegs.example.service.ExampleService;
+ import org.robotlegs.example.service.IExampleService;
+ import org.robotlegs.example.view.MainView;
+ import org.robotlegs.example.view.api.IMainView;
+ import org.robotlegs.example.view.api.INewWindow;
+ import org.robotlegs.example.view.events.GetSomeTextEvent;
+ import org.robotlegs.example.view.mediator.MainViewMediator;
+ import org.robotlegs.example.view.mediator.NewWindowMediator;
+ import org.swiftsuspenders.Injector;
+ import robotlegs.bender.extensions.eventCommandMap.api.IEventCommandMap;
+ import robotlegs.bender.extensions.mediatorMap.api.IMediatorMap;
+ import spark.components.Application;
+
+ public class AppConfig
+ {
+
+ /*============================================================================*/
+ /* Public Properties */
+ /*============================================================================*/
+
+ [Inject]
+ public var injector:Injector;
+
+ [Inject]
+ public var mediatorMap:IMediatorMap;
+
+ [Inject]
+ public var commandMap:IEventCommandMap;
+
+ /*============================================================================*/
+ /* Public Functions */
+ /*============================================================================*/
+
+ [PostConstruct]
+ public function init():void
+ {
+ // View
+ mediatorMap.mapView(IMainView).toMediator(MainViewMediator);
+ mediatorMap.mapView(INewWindow).toMediator(NewWindowMediator);
+
+ // Model
+ injector.map(ExampleModel);
+
+ // service
+ injector.map(IExampleService).toSingleton(ExampleService);
+
+ // controller
+ commandMap.map(GetSomeTextEvent.GET_SOME_TEXT, GetSomeTextEvent).toCommand(GetSomeTextCommand);
+ }
+ }
}
@@ -0,0 +1,24 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2011 the original author or authors. All Rights Reserved.
+//
+// NOTICE: You are permitted to use, modify, and distribute this file
+// in accordance with the terms of the license agreement accompanying it.
+//------------------------------------------------------------------------------
+
+package org.robotlegs.example
+{
+ import robotlegs.bender.extensions.logging.LoggingExtension;
+ import robotlegs.bender.framework.context.api.IContext;
+ import robotlegs.bender.framework.context.api.IContextExtension;
+ import robotlegs.bender.framework.logging.api.LogLevel;
+
+ public class LoggerConfig implements IContextExtension
+ {
+
+ public function extend(context:IContext):void
+ {
+ context.extend(LoggingExtension);
+ context.logLevel = LogLevel.DEBUG;
+ }
+ }
+}
@@ -9,16 +9,21 @@ package org.robotlegs.example.controller {
import org.robotlegs.example.service.IExampleService;
import org.robotlegs.example.view.events.GetSomeTextEvent;
- public class GetSomeTextCommand {
+ import robotlegs.bender.framework.logging.api.ILogger;
+
+ public class GetSomeTextCommand {
[Inject]
public var event:GetSomeTextEvent;
[Inject]
public var service:IExampleService;
+
+ [Inject]
+ public var logger:ILogger;
public function execute():void{
- trace("3. Now we're in the command which will then tell the service to load data:::::::::")
+ logger.debug("3. Now we're in the command which will then tell the service to load data:::::::::")
service.load();
}
}
@@ -10,16 +10,22 @@ package org.robotlegs.example.model {
import org.robotlegs.example.model.event.ExampleModelUpdate;
import org.robotlegs.example.model.vo.AnswerVO;
- public class ExampleModel extends BaseActor{
+ import robotlegs.bender.framework.logging.api.ILogger;
+
+ public class ExampleModel extends BaseActor{
+
+ [Inject]
+ public var logger:ILogger;
+
public function ExampleModel() {
}
public function createMessage(jsonObject:Object):void {
- trace("5. We're now in the model prepping the data::::::::");
- trace("6. We are going to pass the answer object to the Example Model Update Event::::: " + jsonObject.data.answer);
+ logger.debug("5. We're now in the model prepping the data::::::::");
+ logger.debug("6. We are going to pass the answer object to the Example Model Update Event::::: " + jsonObject.data.answer);
var valueObject:AnswerVO = new AnswerVO();
valueObject.answer = jsonObject.data.answer;
- trace("7. Dispatch event to let the ui know we've changed:::::::::::")
+ logger.debug("7. Dispatch event to let the ui know we've changed:::::::::::")
dispatch(new ExampleModelUpdate(ExampleModelUpdate.MODEL_UPDATED, valueObject));
}
}
@@ -14,12 +14,17 @@ package org.robotlegs.example.service {
import flash.net.URLLoader;
import flash.net.URLRequest;
- public class ExampleService extends BaseActor implements IExampleService{
+ import robotlegs.bender.framework.logging.api.ILogger;
+
+ public class ExampleService extends BaseActor implements IExampleService{
private var urlLoader:URLLoader;
[Inject]
public var exampleModel:ExampleModel;
+ [Inject]
+ public var logger:ILogger;
+
public function ExampleService() {
super();
}
@@ -35,7 +40,7 @@ package org.robotlegs.example.service {
private function onLoadTreeComplete(event:Event):void {
if (urlLoader.data) {
- trace("4. We're now in the service onComplete::::::::");
+ logger.debug("4. We're now in the service onComplete::::::::");
// this import collides with the Flex SDK's implementation of JSON support for AIR apps
// we're using as3corelib to support json
var jsonObject:Object = JSON.parse(urlLoader.data);
@@ -44,7 +49,7 @@ package org.robotlegs.example.service {
}
private function onLoadTreeIOError(event:IOErrorEvent):void {
- trace("ERROR")
+ logger.error("ERROR")
}
}
@@ -21,6 +21,7 @@
private var _returnText:String;
+ // note: can not inject here - RL does not inject into views by default
[Inject]
public var viewManager:IViewManager;
@@ -21,6 +21,7 @@
PopUpManager.removePopUp(this);
}
+ [Bindable]
public function get helloMessage():String {
return _helloMessage;
}
@@ -20,8 +20,9 @@ package org.robotlegs.example.view.mediator {
import robotlegs.bender.bundles.mvcs.impl.Mediator;
import robotlegs.bender.extensions.viewManager.api.IViewManager;
+ import robotlegs.bender.framework.logging.api.ILogger;
- import spark.components.TitleWindow;
+ import spark.components.TitleWindow;
public class MainViewMediator extends Mediator {
@@ -32,30 +33,40 @@ package org.robotlegs.example.view.mediator {
[Inject]
public var viewManager:IViewManager;
+ [Inject]
+ public var logger:ILogger;
+
public function MainViewMediator() {
super();
}
override public function initialize():void {
+ logger.debug("initialize");
addViewListener(GetSomeTextEvent.GET_SOME_TEXT, handleGetText, GetSomeTextEvent);
addContextListener(ExampleModelUpdate.MODEL_UPDATED, handleModelUpdate, ExampleModelUpdate)
addViewListener(OpenPopupEvent.OPEN, onOpenPopup, OpenPopupEvent);
}
- private function onOpenPopup(event:OpenPopupEvent):void {
+ override public function destroy():void
+ {
+ logger.debug("destroy");
+ super.destroy();
+ }
+
+ private function onOpenPopup(event:OpenPopupEvent):void {
var newReportWindow:TitleWindow = new NewWindow();
viewManager.addContainer(newReportWindow);
PopUpManager.addPopUp(newReportWindow, FlexGlobals.topLevelApplication as DisplayObject);
PopUpManager.centerPopUp(newReportWindow);
}
private function handleGetText(event:GetSomeTextEvent):void {
- trace("2. Redundant dispatch it seems::::: ");
+ logger.debug("2. Redundant dispatch it seems::::: ");
dispatch(event);
}
private function handleModelUpdate(event:ExampleModelUpdate):void {
- trace("8. Listen to the Context for changes in the event map. " +
+ logger.debug("8. Listen to the Context for changes in the event map. " +
"Then lets catch the answer in the Main View Mediator and pass it to the Main View::::: " + event.model.answer);
view.returnText = event.model.answer;
}
@@ -12,27 +12,33 @@ package org.robotlegs.example.view.mediator {
import org.robotlegs.example.view.events.OpenPopupEvent;
import robotlegs.bender.bundles.mvcs.impl.Mediator;
+ import robotlegs.bender.framework.logging.api.ILogger;
- public class NewWindowMediator extends Mediator{
+ public class NewWindowMediator extends Mediator{
[Inject]
public var view:INewWindow;
+ [Inject]
+ public var logger:ILogger;
+
override public function initialize():void {
+ logger.debug("initialize");
addViewListener(GetSomeTextEvent.GET_SOME_TEXT, onGetSomeText, GetSomeTextEvent);
addContextListener(ExampleModelUpdate.MODEL_UPDATED, handleModelUpdate, ExampleModelUpdate);
}
override public function destroy():void {
- removeViewListener(GetSomeTextEvent.GET_SOME_TEXT, onGetSomeText, GetSomeTextEvent);
+ logger.debug("destroy");
+ super.destroy();
}
private function onGetSomeText(event:GetSomeTextEvent):void {
- trace("We made it into the NewWindowMediator and are mediated!");
+ logger.debug("We made it into the NewWindowMediator and are mediated!");
dispatch(event);
}
private function handleModelUpdate(event:ExampleModelUpdate):void {
- trace("We're have now received the update from the model.");
+ logger.debug("We're have now received the update from the model.");
view.helloMessage = event.model.answer;
}
}

0 comments on commit b098857

Please sign in to comment.