Permalink
Browse files

Created Project folder and schema selection

  • Loading branch information...
1 parent 0963ad6 commit 232c651f25bd6edfcc6c541084490cd4cf479df4 @eddiemoore committed Feb 15, 2012
Binary file not shown.
@@ -1,11 +1,12 @@
package com.structurecreator
{
+ import com.structurecreator.model.ProjectFolderModel;
import com.structurecreator.view.CreateButton;
import com.structurecreator.view.CreateButtonMediator;
- import com.structurecreator.view.ProjectFolderButton;
- import com.structurecreator.view.ProjectFolderButtonMediator;
- import com.structurecreator.view.SchemaButton;
- import com.structurecreator.view.SchemaButtonMediator;
+ import com.structurecreator.view.ProjectFolderMediator;
+ import com.structurecreator.view.ProjectFolderView;
+ import com.structurecreator.view.SchemaSelectMediator;
+ import com.structurecreator.view.SchemaSelectView;
import flash.display.DisplayObjectContainer;
@@ -21,9 +22,10 @@ package com.structurecreator
override public function startup():void
{
trace("App Started");
+ injector.mapSingleton(ProjectFolderModel);
- //mediatorMap.mapView(ProjectFolderButton, ProjectFolderButtonMediator);
- mediatorMap.mapView(SchemaButton, SchemaButtonMediator);
+ mediatorMap.mapView(ProjectFolderView, ProjectFolderMediator);
+ mediatorMap.mapView(SchemaSelectView, SchemaSelectMediator);
mediatorMap.mapView(CreateButton, CreateButtonMediator);
super.startup();
@@ -0,0 +1,19 @@
+package com.structurecreator.events
+{
+ import flash.events.Event;
+
+ public class ProjectFolderEvent extends Event
+ {
+ public static const PROJECT_FOLDER_SELECTED:String = "projectFolderSelected";
+
+ public function ProjectFolderEvent(type:String)
+ {
+ super(type);
+ }
+
+ override public function clone():Event
+ {
+ return new ProjectFolderEvent(type);
+ }
+ }
+}
@@ -0,0 +1,19 @@
+package com.structurecreator.events
+{
+ import flash.events.Event;
+
+ public class SchemaEvent extends Event
+ {
+ public static const SCHEMA_SELECTED:String = "schemaSelected";
+
+ public function SchemaEvent(type:String)
+ {
+ super(type);
+ }
+
+ override public function clone():Event
+ {
+ return new SchemaEvent(type);
+ }
+ }
+}
@@ -1,12 +1,15 @@
package com.structurecreator.model
{
+ import com.structurecreator.events.ProjectFolderEvent;
+
+ import flash.events.Event;
import flash.filesystem.File;
import org.robotlegs.mvcs.Actor;
public class ProjectFolderModel extends Actor
{
- private var _projectFolder:File;
+ private var _projectFolder:File = File.documentsDirectory;
public function ProjectFolderModel()
{
@@ -17,9 +20,15 @@ package com.structurecreator.model
return _projectFolder;
}
- public function set projectFolder(folder:File):void
+ public function selectProjectFolder():void
+ {
+ projectFolder.browseForDirectory("Select Project Folder");
+ projectFolder.addEventListener(Event.SELECT, onProjectFolderSelected);
+ }
+
+ protected function onProjectFolderSelected(event:Event):void
{
- _projectFolder = folder;
+ eventDispatcher.dispatchEvent(new ProjectFolderEvent(ProjectFolderEvent.PROJECT_FOLDER_SELECTED));
}
}
}
@@ -0,0 +1,35 @@
+package com.structurecreator.model
+{
+ import com.structurecreator.events.SchemaEvent;
+
+ import flash.events.Event;
+ import flash.filesystem.File;
+
+ import org.robotlegs.mvcs.Actor;
+
+ public class SchemaModel extends Actor
+ {
+ private var _schemaFile:File = File.documentsDirectory;
+
+ public function SchemaModel()
+ {
+
+ }
+
+ public function get schemaFile():File
+ {
+ return _schemaFile;
+ }
+
+ public function selectSchemaFile():void
+ {
+ schemaFile.browse();
+ schemaFile.addEventListener(Event.SELECT, onSchemaSelected);
+ }
+
+ protected function onSchemaSelected(event:Event):void
+ {
+ dispatch(new SchemaEvent(SchemaEvent.SCHEMA_SELECTED));
+ }
+ }
+}
@@ -1,5 +1,8 @@
package com.structurecreator.view
{
+ import com.structurecreator.events.ProjectFolderEvent;
+ import com.structurecreator.model.ProjectFolderModel;
+
import flash.events.MouseEvent;
import org.robotlegs.mvcs.Mediator;
@@ -9,6 +12,9 @@ package com.structurecreator.view
[Inject]
public var view:ProjectFolderView;
+ [Inject]
+ public var model:ProjectFolderModel;
+
public function ProjectFolderMediator()
{
@@ -17,11 +23,17 @@ package com.structurecreator.view
override public function onRegister():void
{
eventMap.mapListener(view.browse, MouseEvent.CLICK, onClick);
+ eventMap.mapListener(eventDispatcher, ProjectFolderEvent.PROJECT_FOLDER_SELECTED, onProjectFolderSelected);
+ }
+
+ private function onProjectFolderSelected(e:ProjectFolderEvent):void
+ {
+ view.projectFolderTI.text = model.projectFolder.nativePath;
}
private function onClick(e:MouseEvent):void
{
-
+ model.selectProjectFolder();
}
}
}

0 comments on commit 232c651

Please sign in to comment.