-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f16e24f
Showing
10 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.swc -crlf -diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/.settings/* | ||
|
||
/html-template/* | ||
/bin-debug/* | ||
/bin-release/* | ||
/bin/* | ||
docs/* | ||
obj/* | ||
|
||
.actionScriptProperties | ||
.flexProperties | ||
.flexLibProperties | ||
.FlexUnitSettings | ||
.project | ||
|
||
Icon | ||
Thumbs.db | ||
.DS_Store | ||
dist/* | ||
report/* | ||
doc/* | ||
|
||
src/FlexUnitApplication.mxml | ||
*.iml | ||
*.ipr | ||
*.iws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
xmlns:modulardoodads="robotlegs.examples.modulardoodads.*" xmlns:logger="robotlegs.examples.modulardoodads.modules.logger.*"> | ||
<fx:Declarations> | ||
<modulardoodads:ModularDoodadsContext contextView="{this}"/> | ||
</fx:Declarations> | ||
<s:layout> | ||
<s:VerticalLayout/> | ||
</s:layout> | ||
<s:Button id="logIt" label="LOG IT!"/> | ||
<logger:LoggerModule/> | ||
</s:Application> |
28 changes: 28 additions & 0 deletions
28
src/robotlegs/examples/modulardoodads/ModularDoodadsContext.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package robotlegs.examples.modulardoodads | ||
{ | ||
import flash.display.DisplayObjectContainer; | ||
|
||
import org.robotlegs.core.IInjector; | ||
import org.robotlegs.utilities.modular.mvcs.ModuleContext; | ||
|
||
import robotlegs.examples.modulardoodads.modules.logger.LoggerModule; | ||
import robotlegs.examples.modulardoodads.view.ModuleDoodadsMediator; | ||
|
||
/** | ||
* This Context extend ModuleContext so that it will create the injector mappings | ||
* for the <code>ModuleEventDispatcher</code> and <code>ModuleCommandMap</code>. | ||
* | ||
* @author Joel Hooks | ||
* | ||
*/ | ||
public class ModularDoodadsContext extends ModuleContext | ||
{ | ||
override public function startup():void | ||
{ | ||
//map the LoggerModule so that its instances will | ||
//be properly injected with the injector. | ||
viewMap.mapType(LoggerModule); | ||
mediatorMap.mapView(ModularDoodads, ModuleDoodadsMediator); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/robotlegs/examples/modulardoodads/common/events/LoggingEvent.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package robotlegs.examples.modulardoodads.common.events | ||
{ | ||
import flash.events.Event; | ||
|
||
public class LoggingEvent extends Event | ||
{ | ||
public static const MESSAGE:String = "LoggingEvent.MESSAGE"; | ||
|
||
private var _message:String; | ||
|
||
public function get message():String | ||
{ | ||
return _message; | ||
} | ||
|
||
private var _payload:Object; | ||
|
||
public function get payload():Object | ||
{ | ||
return _payload; | ||
} | ||
|
||
public function LoggingEvent(type:String, message:String, payload:Object=null, bubbles:Boolean=false, cancelable:Boolean=false) | ||
{ | ||
super(type, bubbles, cancelable); | ||
_message=message; | ||
_payload=payload; | ||
} | ||
|
||
override public function clone():Event | ||
{ | ||
return new LoggingEvent(type,message,payload,bubbles,cancelable); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/robotlegs/examples/modulardoodads/modules/logger/LoggerModule.mxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
implements="org.robotlegs.utilities.modular.core.IModule" | ||
layout="absolute" width="100%"> | ||
<fx:Script> | ||
<![CDATA[ | ||
import org.robotlegs.core.IContext; | ||
import org.robotlegs.core.IInjector; | ||
import org.robotlegs.utilities.modular.core.IModule; | ||
protected var context:IContext; | ||
[Bindable] | ||
public var messages:String = ""; | ||
public function addLoggingMessage(message:String):void | ||
{ | ||
if(messages) | ||
messages += "\r"; | ||
messages += message; | ||
messageDisplay.validateNow(); | ||
messageDisplay.scroller.verticalScrollBar.value = messageDisplay.scroller.verticalScrollBar.maximum; | ||
} | ||
/** | ||
* We need to initialize our context by setting the parent | ||
* injector for the module. This is actually injected by the | ||
* shell, so no need to worry about it! | ||
*/ | ||
[Inject] | ||
public function set parentInjector(value:IInjector):void | ||
{ | ||
context = new LoggerModuleContext(this, value); | ||
} | ||
]]> | ||
</fx:Script> | ||
<fx:Declarations> | ||
<!-- Place non-visual elements (e.g., services, value objects) here --> | ||
</fx:Declarations> | ||
<s:TextArea id="messageDisplay" text="{messages}"/> | ||
</mx:Module> |
31 changes: 31 additions & 0 deletions
31
src/robotlegs/examples/modulardoodads/modules/logger/LoggerModuleContext.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package robotlegs.examples.modulardoodads.modules.logger | ||
{ | ||
import flash.display.DisplayObjectContainer; | ||
|
||
import org.robotlegs.core.IInjector; | ||
import org.robotlegs.utilities.modular.mvcs.ModuleContext; | ||
|
||
import robotlegs.examples.modulardoodads.modules.logger.view.LoggerModuleMediator; | ||
|
||
public class LoggerModuleContext extends ModuleContext | ||
{ | ||
/** | ||
* Because this module <b>requires</b> an injector we need to use its constructor to initialize | ||
* the context properly. | ||
* | ||
* @param contextView | ||
* @param injector | ||
* | ||
*/ | ||
public function LoggerModuleContext(contextView:DisplayObjectContainer, injector:IInjector) | ||
{ | ||
super(contextView, true, injector); | ||
} | ||
|
||
override public function startup():void | ||
{ | ||
trace("WE HAVE SUB-CONTEXT!!"); | ||
mediatorMap.mapView(LoggerModule, LoggerModuleMediator); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/robotlegs/examples/modulardoodads/modules/logger/model/LogMessageModel.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package robotlegs.examples.modulardoodads.modules.logger.model | ||
{ | ||
import org.robotlegs.mvcs.Actor; | ||
|
||
public class LogMessageModel extends Actor | ||
{ | ||
public function LogMessageModel() | ||
{ | ||
super(); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/robotlegs/examples/modulardoodads/modules/logger/view/LoggerModuleMediator.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package robotlegs.examples.modulardoodads.modules.logger.view | ||
{ | ||
import org.robotlegs.utilities.modular.mvcs.ModuleMediator; | ||
|
||
import robotlegs.examples.modulardoodads.common.events.LoggingEvent; | ||
import robotlegs.examples.modulardoodads.modules.logger.LoggerModule; | ||
|
||
public class LoggerModuleMediator extends ModuleMediator | ||
{ | ||
[Inject] | ||
public var view:LoggerModule; | ||
|
||
override public function onRegister():void | ||
{ | ||
eventMap.mapListener(moduleDispatcher, LoggingEvent.MESSAGE, handleLoggingeMessage); | ||
} | ||
|
||
protected function handleLoggingeMessage(event:LoggingEvent):void | ||
{ | ||
view.addLoggingMessage(event.message); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/robotlegs/examples/modulardoodads/view/ModuleDoodadsMediator.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package robotlegs.examples.modulardoodads.view | ||
{ | ||
import flash.events.MouseEvent; | ||
|
||
import org.robotlegs.utilities.modular.mvcs.ModuleMediator; | ||
|
||
import robotlegs.examples.modulardoodads.common.events.LoggingEvent; | ||
|
||
public class ModuleDoodadsMediator extends ModuleMediator | ||
{ | ||
[Inject] | ||
public var view:ModularDoodads; | ||
|
||
override public function onRegister():void | ||
{ | ||
eventMap.mapListener(view.logIt, MouseEvent.CLICK, handleLogItClicked); | ||
} | ||
|
||
protected function handleLogItClicked(event:MouseEvent):void | ||
{ | ||
redispatchToModules(new LoggingEvent(LoggingEvent.MESSAGE, "SHIT BALLS!", null)); | ||
} | ||
} | ||
} |