Browse files

Added Custom Variables Views and Mediator

  • Loading branch information...
1 parent ca300ba commit 3433766bf32ef32ce70c8bd84e7356cb77edb6a4 @eddiemoore committed Feb 15, 2012
View
BIN bin-debug/StructureCreator.swf
Binary file not shown.
View
8 src/com/structurecreator/MainContext.as
@@ -1,16 +1,21 @@
package com.structurecreator
{
import com.structurecreator.events.StructureCreatorEvent;
+ import com.structurecreator.model.CustomVariableModel;
import com.structurecreator.model.ProjectFolderModel;
import com.structurecreator.model.SchemaModel;
import com.structurecreator.model.StructureCreatorModel;
import com.structurecreator.model.schemas.XMLSchema;
import com.structurecreator.view.CreateButton;
import com.structurecreator.view.CreateButtonMediator;
+ import com.structurecreator.view.CustomVariablesMediator;
+ import com.structurecreator.view.CustomVariablesView;
import com.structurecreator.view.ProjectFolderMediator;
import com.structurecreator.view.ProjectFolderView;
import com.structurecreator.view.SchemaSelectMediator;
import com.structurecreator.view.SchemaSelectView;
+ import com.structurecreator.view.customvars.CustomVariableBarMediator;
+ import com.structurecreator.view.customvars.CustomVariableBarView;
import flash.display.DisplayObjectContainer;
import flash.events.Event;
@@ -32,10 +37,13 @@ package com.structurecreator
injector.mapSingleton(SchemaModel);
injector.mapSingleton(XMLSchema);
injector.mapSingleton(StructureCreatorModel);
+ injector.mapSingleton(CustomVariableModel);
mediatorMap.mapView(ProjectFolderView, ProjectFolderMediator);
mediatorMap.mapView(SchemaSelectView, SchemaSelectMediator);
mediatorMap.mapView(CreateButton, CreateButtonMediator);
+ mediatorMap.mapView(CustomVariablesView, CustomVariablesMediator);
+ mediatorMap.mapView(CustomVariableBarView, CustomVariableBarMediator);
eventDispatcher.addEventListener(StructureCreatorEvent.CREATION_COMPLETE, onCreationComplete);
View
19 src/com/structurecreator/events/CustomVarsEvent.as
@@ -0,0 +1,19 @@
+package com.structurecreator.events
+{
+ import flash.events.Event;
+
+ public class CustomVarsEvent extends Event
+ {
+ public static var CUSTOM_VAR_ADDED:String = 'customVarAdded';
+
+ public function CustomVarsEvent(type:String)
+ {
+ super(type);
+ }
+
+ override public function clone():Event
+ {
+ return new CustomVarsEvent(type);
+ }
+ }
+}
View
20 src/com/structurecreator/model/CustomVariableModel.as
@@ -1,12 +1,30 @@
package com.structurecreator.model
{
+ import com.structurecreator.events.CustomVarsEvent;
+ import com.structurecreator.model.vo.CustomVariableVO;
+
import org.robotlegs.mvcs.Actor;
public class CustomVariableModel extends Actor
{
+ private var _customVars:Vector.<CustomVariableVO> = new Vector.<CustomVariableVO>();
+
public function CustomVariableModel()
{
- super();
+
+ }
+
+ public function get customVars():Vector.<CustomVariableVO>
+ {
+ return _customVars;
+ }
+
+ public function addCustomVariable():void
+ {
+ trace("Add a custom variable");
+ var cv:CustomVariableVO = new CustomVariableVO();
+ customVars.push(cv);
+ eventDispatcher.dispatchEvent(new CustomVarsEvent(CustomVarsEvent.CUSTOM_VAR_ADDED));
}
}
}
View
12 src/com/structurecreator/model/vo/CustomVariableVO.as
@@ -7,18 +7,30 @@ package com.structurecreator.model.vo
public function CustomVariableVO()
{
+ _variable = "variable";
+ _value = "value";
}
public function get variable():String
{
return _variable;
}
+
+ public function set variable(value:String):void
+ {
+ _variable = value;
+ }
public function get value():String
{
return _value;
}
+ public function set value(value:String):void
+ {
+ _value = value;
+ }
+
}
}
View
21 src/com/structurecreator/view/CustomVariablesMediator.as
@@ -1,26 +1,45 @@
package com.structurecreator.view
{
+ import com.structurecreator.events.CustomVarsEvent;
+ import com.structurecreator.model.CustomVariableModel;
+ import com.structurecreator.view.customvars.CustomVariableBarView;
+
import flash.events.MouseEvent;
import org.robotlegs.mvcs.Mediator;
+ import spark.components.DataRenderer;
+
public class CustomVariablesMediator extends Mediator
{
[Inject]
public var view:CustomVariablesView;
+ [Inject]
+ public var model:CustomVariableModel;
+
public function CustomVariablesMediator()
{
}
override public function onRegister():void
{
eventMap.mapListener(view.add, MouseEvent.CLICK, addCustomVariable);
+ eventMap.mapListener(eventDispatcher, CustomVarsEvent.CUSTOM_VAR_ADDED, onCustomVarAdded);
+ }
+
+ private function onCustomVarAdded(e:CustomVarsEvent):void
+ {
+ trace("Added Custom Variable");
+ var cvb:CustomVariableBarView = new CustomVariableBarView();
+ trace(model.customVars.length, cvb.height);
+ cvb.y = model.customVars.length * cvb.height;
+ view.customVarsHolder.addElement(cvb);
}
private function addCustomVariable(e:MouseEvent):void
{
-
+ model.addCustomVariable();
}
}
}
View
15 src/com/structurecreator/view/CustomVariablesView.mxml
@@ -5,8 +5,17 @@
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
- <s:Scroller width="100%" height="100%">
-
+ <s:layout>
+ <s:VerticalLayout />
+ </s:layout>
+ <s:Label text="Custom Variables" />
+ <s:Scroller width="100%" height="100%" id="scroller" >
+ <s:Group id="customVarsHolder">
+ <s:layout>
+ <s:VerticalLayout gap="10" />
+ </s:layout>
+
+ </s:Group>
</s:Scroller>
- <s:Button id="add" label="+" width="30" right="0" bottom="0" />
+ <s:Button id="add" label="+" width="30" />
</s:Group>
View
31 src/com/structurecreator/view/customvars/CustomVariableBarMediator.as
@@ -0,0 +1,31 @@
+package com.structurecreator.view.customvars
+{
+ import com.structurecreator.model.CustomVariableModel;
+
+ import flash.events.KeyboardEvent;
+
+ import org.robotlegs.mvcs.Mediator;
+
+ public class CustomVariableBarMediator extends Mediator
+ {
+ [Inject]
+ public var view:CustomVariableBarView;
+
+ [Inject]
+ public var model:CustomVariableModel;
+
+ public function CustomVariableBarMediator()
+ {
+ }
+
+ override public function onRegister():void
+ {
+ view.variableTI.addEventListener(KeyboardEvent.KEY_UP, onKeyUp)
+ }
+
+ protected function onKeyUp(event:KeyboardEvent):void
+ {
+ trace("Update custom var VO");
+ }
+ }
+}
View
13 src/com/structurecreator/view/customvars/CustomVariableBarView.mxml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ autoDrawBackground="true"
+ height="20"
+ width="100%">
+ <s:HGroup width="100%" paddingRight="10">
+ <s:TextInput text="variable" width="100%" id="variableTI" />
+ <s:TextInput text="value" width="100%" id="valueTI" />
+ </s:HGroup>
+
+</s:ItemRenderer>

0 comments on commit 3433766

Please sign in to comment.