Skip to content

Commit

Permalink
hello git
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhooks committed Apr 25, 2010
0 parents commit f16e24f
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.swc -crlf -diff
26 changes: 26 additions & 0 deletions .gitignore
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
14 changes: 14 additions & 0 deletions src/ModularDoodads.mxml
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 src/robotlegs/examples/modulardoodads/ModularDoodadsContext.as
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);
}
}
}
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);
}
}
}
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>
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);
}
}
}
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();
}
}
}
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);
}
}
}
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));
}
}
}

0 comments on commit f16e24f

Please sign in to comment.