Permalink
Browse files

Added SaveProfileWindow. Isn't hooked up to save yet

  • Loading branch information...
1 parent 5ccf991 commit 32fa692a1e48a01fe673c7c8008ae5cd3a49d802 @eddiemoore committed Feb 20, 2012
Binary file not shown.
@@ -17,6 +17,8 @@
<s:Label color="#CFCECD" fontSize="20" text="StructureCreator 0.1"/>
+ <view:ProfileButtons />
+
<!-- Profile Select -->
<s:Group width="100%">
<s:layout>
@@ -2,7 +2,9 @@ package com.structurecreator
{
import com.structurecreator.controller.DatabaseCommand;
import com.structurecreator.controller.FileCommand;
+ import com.structurecreator.controller.ProfileCommand;
import com.structurecreator.events.FileEvent;
+ import com.structurecreator.events.ProfileEvent;
import com.structurecreator.events.StructureCreatorEvent;
import com.structurecreator.model.CustomVariableModel;
import com.structurecreator.model.ProjectFolderModel;
@@ -16,12 +18,16 @@ package com.structurecreator
import com.structurecreator.view.CreateButtonMediator;
import com.structurecreator.view.CustomVariablesMediator;
import com.structurecreator.view.CustomVariablesView;
+ import com.structurecreator.view.ProfileButtons;
+ import com.structurecreator.view.ProfileButtonsMediator;
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 com.structurecreator.view.saveprofile.SaveProfileWindow;
+ import com.structurecreator.view.saveprofile.SaveProfileWindowMediator;
import flash.display.DisplayObjectContainer;
import flash.events.Event;
@@ -59,18 +65,30 @@ package com.structurecreator
mediatorMap.mapView(CreateButton, CreateButtonMediator);
mediatorMap.mapView(CustomVariablesView, CustomVariablesMediator);
mediatorMap.mapView(CustomVariableBarView, CustomVariableBarMediator);
+ mediatorMap.mapView(ProfileButtons, ProfileButtonsMediator);
+ mediatorMap.mapView(SaveProfileWindow, SaveProfileWindowMediator);
/* Commands for file creation */
commandMap.mapEvent(FileEvent.START_CREATION, FileCommand, FileEvent);
commandMap.mapEvent(StructureCreatorEvent.APP_STARTED, DatabaseCommand, StructureCreatorEvent);
+ commandMap.mapEvent(ProfileEvent.SAVE_PROFILE, ProfileCommand, ProfileEvent);
/* Listen for creation complete event */
eventDispatcher.addEventListener(StructureCreatorEvent.CREATION_COMPLETE, onCreationComplete);
eventDispatcher.dispatchEvent(new StructureCreatorEvent(StructureCreatorEvent.APP_STARTED));
+ eventDispatcher.addEventListener(ProfileEvent.OPEN_SAVE_WINDOW, onSaveProfile);
super.startup();
}
+ private function onSaveProfile(e:ProfileEvent):void
+ {
+ //TODO open save profile box.
+ var _viewport:SaveProfileWindow = new SaveProfileWindow();
+ //mediatorMap.createMediator(_viewport);
+ _viewport.open();
+ }
+
/**
* On Creation Complete
* Show that all files have been created
@@ -0,0 +1,30 @@
+package com.structurecreator.controller
+{
+ import com.structurecreator.events.ProfileEvent;
+ import com.structurecreator.services.DatabaseService;
+
+ import org.robotlegs.mvcs.Command;
+
+ public class ProfileCommand extends Command
+ {
+ [Inject]
+ public var event:ProfileEvent;
+
+ [Inject]
+ public var service:DatabaseService;
+
+ public function ProfileCommand()
+ {
+ //super();
+ }
+
+ /**
+ * Initialises the creation of a new file
+ */
+ override public function execute():void
+ {
+ trace("Add the profile");
+ service.addProfile(event.name);
+ }
+ }
+}
@@ -0,0 +1,28 @@
+package com.structurecreator.events
+{
+ import flash.events.Event;
+
+ public class ProfileEvent extends Event
+ {
+ public static const OPEN_SAVE_WINDOW:String = 'openSaveWindow';
+ public static const SAVE_PROFILE:String = 'saveProfile';
+
+ private var _name:String;
+
+ public function ProfileEvent(type:String, name:String='')
+ {
+ super(type);
+ _name = name;
+ }
+
+ override public function clone():Event
+ {
+ return new ProfileEvent(type);
+ }
+
+ public function get name():String
+ {
+ return _name;
+ }
+ }
+}
@@ -57,6 +57,7 @@ package com.structurecreator.services
public function addProfile(name:String = ''):void
{
addStatement("INSERT INTO profiles (name) SELECT '" + name +"' WHERE NOT EXISTS (SELECT 1 FROM profiles WHERE name = '" + name + "');");
+ trace("Add Profile " + name);
execute();
}
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx">
+ <s:layout>
+ <s:HorizontalLayout/>
+ </s:layout>
+ <fx:Declarations>
+ <!-- Place non-visual elements (e.g., services, value objects) here -->
+ </fx:Declarations>
+
+ <s:Button id="saveBtn" label="save profile" />
+</s:Group>
@@ -0,0 +1,32 @@
+package com.structurecreator.view
+{
+ import com.structurecreator.events.ProfileEvent;
+
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+
+ import org.robotlegs.mvcs.Mediator;
+
+ public class ProfileButtonsMediator extends Mediator
+ {
+ [Inject]
+ public var view:ProfileButtons;
+
+ public function ProfileButtonsMediator()
+ {
+ }
+
+ override public function onRegister():void
+ {
+ eventMap.mapListener(view.saveBtn, MouseEvent.CLICK, onSaveClick);
+ }
+
+ /**
+ * On Save button Clicked
+ */
+ private function onSaveClick(e:MouseEvent):void
+ {
+ eventDispatcher.dispatchEvent(new ProfileEvent(ProfileEvent.OPEN_SAVE_WINDOW));
+ }
+ }
+}
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ backgroundColor="#666666" width="300" height="120"
+ title="Save Profile">
+ <fx:Declarations>
+ <!-- Place non-visual elements (e.g., services, value objects) here -->
+ </fx:Declarations>
+
+ <s:layout>
+ <s:VerticalLayout paddingTop="10" paddingLeft="10" paddingBottom="10" paddingRight="10" gap="20" />
+ </s:layout>
+
+ <s:Label text="Save Profile As" />
+ <s:Group width="100%">
+ <s:layout>
+ <s:HorizontalLayout />
+ </s:layout>
+ <s:TextInput id="profile_name" width="100%" />
+ <s:Button id="saveBtn" label="Save" />
+ </s:Group>
+
+</s:Window>
@@ -0,0 +1,36 @@
+package com.structurecreator.view.saveprofile
+{
+ import com.structurecreator.events.ProfileEvent;
+
+ import flash.events.MouseEvent;
+
+ import org.robotlegs.mvcs.Mediator;
+
+ public class SaveProfileWindowMediator extends Mediator
+ {
+ [Iinject]
+ public var view:SaveProfileWindow;
+
+ public function SaveProfileWindowMediator()
+ {
+
+ }
+
+ override public function onRegister():void
+ {
+ view.saveBtn.addEventListener(MouseEvent.CLICK, onSaveClick);
+ }
+
+ /**
+ * On Save Click dispatch the name of the profile
+ */
+ protected function onSaveClick(event:MouseEvent):void
+ {
+ if (view.profile_name.text != '')
+ {
+ trace("dispatch profile name");
+ eventDispatcher.dispatchEvent(new ProfileEvent(ProfileEvent.SAVE_PROFILE, view.profile_name.text));
+ }
+ }
+ }
+}

0 comments on commit 32fa692

Please sign in to comment.