Permalink
Browse files

Profile Select now selects data from database

  • Loading branch information...
1 parent f6286cc commit 7d1672b30b9564e5471edbd0c4717b511f439716 @eddiemoore committed Feb 21, 2012
View
BIN bin-debug/StructureCreator.swf
Binary file not shown.
View
3 src/com/structurecreator/MainContext.as
@@ -20,6 +20,8 @@ package com.structurecreator
import com.structurecreator.view.CustomVariablesView;
import com.structurecreator.view.ProfileButtons;
import com.structurecreator.view.ProfileButtonsMediator;
+ import com.structurecreator.view.ProfileSelect;
+ import com.structurecreator.view.ProfileSelectMediator;
import com.structurecreator.view.ProjectFolderMediator;
import com.structurecreator.view.ProjectFolderView;
import com.structurecreator.view.SchemaSelectMediator;
@@ -60,6 +62,7 @@ package com.structurecreator
injector.mapClass(MicrosoftXFileService, MicrosoftXFileService);
/* Map views to their mediators */
+ mediatorMap.mapView(ProfileSelect, ProfileSelectMediator);
mediatorMap.mapView(ProjectFolderView, ProjectFolderMediator);
mediatorMap.mapView(SchemaSelectView, SchemaSelectMediator);
mediatorMap.mapView(CreateButton, CreateButtonMediator);
View
1 src/com/structurecreator/events/ProfileEvent.as
@@ -6,6 +6,7 @@ package com.structurecreator.events
{
public static const OPEN_SAVE_WINDOW:String = 'openSaveWindow';
public static const SAVE_PROFILE:String = 'saveProfile';
+ public static const PROFILE_CHANGED:String = 'profileChanged';
private var _name:String;
View
28 src/com/structurecreator/view/ProfileSelectMediator.as
@@ -1,12 +1,16 @@
package com.structurecreator.view
{
import com.structurecreator.events.DatabaseEvent;
+ import com.structurecreator.events.ProfileEvent;
import com.structurecreator.services.DatabaseService;
import flash.events.Event;
+ import mx.collections.ArrayCollection;
+
import org.robotlegs.mvcs.Mediator;
+ import spark.components.ComboBox;
import spark.events.IndexChangeEvent;
public class ProfileSelectMediator extends Mediator
@@ -17,6 +21,9 @@ package com.structurecreator.view
[Inject]
public var model:DatabaseService;
+ [Bindable]
+ private var provider:ArrayCollection;
+
public function ProfileSelectMediator()
{
}
@@ -25,11 +32,31 @@ package com.structurecreator.view
{
eventMap.mapListener(view, Event.CHANGE, onChange);
eventDispatcher.addEventListener(DatabaseEvent.DATABASE_UPDATED, onDatabaseUpdated);
+ updateProfiles();
}
private function onDatabaseUpdated(e:DatabaseEvent):void
{
+ updateProfiles();
+ }
+
+ private function updateProfiles():void
+ {
+ var profiles:Array = model.selectAllProfiles();
+ //trace(profiles[0].name);
+
+ if (profiles.length > 0)
+ view.enabled = true;
+ else
+ view.enabled = false;
+ provider = new ArrayCollection();
+ for (var i:uint = 0; i < profiles.length; i++)
+ {
+ trace(profiles[i].name);
+ provider.addItem( { label:profiles[i].name, data:profiles[i].profile_id } );
+ }
+ view.dataProvider = provider;
}
/**
@@ -38,6 +65,7 @@ package com.structurecreator.view
protected function onChange(event:IndexChangeEvent):void
{
trace("Profile Select Box Change");
+ eventDispatcher.dispatchEvent(new ProfileEvent(ProfileEvent.PROFILE_CHANGED, String(view.selectedItem.data)));
}
}
}

0 comments on commit 7d1672b

Please sign in to comment.