Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Can only add one custom variable at a time

  • Loading branch information...
commit e1fd68f537b9ded82dba17f806dfeb01d25b93dc 1 parent e5ca1f4
@eddiemoore authored
View
BIN  bin-debug/StructureCreator.swf
Binary file not shown
View
7 src/com/structurecreator/MainContext.as
@@ -3,6 +3,7 @@ package com.structurecreator
import com.structurecreator.controller.DatabaseCommand;
import com.structurecreator.controller.FileCommand;
import com.structurecreator.controller.ProfileCommand;
+ import com.structurecreator.events.CustomVarsEvent;
import com.structurecreator.events.FileEvent;
import com.structurecreator.events.ProfileEvent;
import com.structurecreator.events.StructureCreatorEvent;
@@ -85,10 +86,16 @@ package com.structurecreator
eventDispatcher.dispatchEvent(new StructureCreatorEvent(StructureCreatorEvent.APP_STARTED));
eventDispatcher.addEventListener(ProfileEvent.OPEN_SAVE_WINDOW, onOpenSaveProfile);
eventDispatcher.addEventListener(ProfileEvent.SAVE_PROFILE, onSaveProfile);
+ eventDispatcher.addEventListener(CustomVarsEvent.CANNOT_ADD_VAR, onCannotAddVar);
super.startup();
}
+ private function onCannotAddVar(e:CustomVarsEvent):void
+ {
+ Alert.show("You can't add a new custom variable until the previous one is filled in", "Can't add Custom Variable");
+ }
+
/**
* Opens Save Profile window
*/
View
1  src/com/structurecreator/events/CustomVarsEvent.as
@@ -5,6 +5,7 @@ package com.structurecreator.events
public class CustomVarsEvent extends Event
{
public static var CUSTOM_VAR_ADDED:String = 'customVarAdded';
+ public static var CANNOT_ADD_VAR:String = 'cannotAddVar';
public function CustomVarsEvent(type:String)
{
View
15 src/com/structurecreator/model/CustomVariableModel.as
@@ -55,10 +55,17 @@ package com.structurecreator.model
{
trace("Add a custom variable");
//TODO check if last is empty
-
- var cv:CustomVariableVO = new CustomVariableVO();
- customVars.push(cv);
- eventDispatcher.dispatchEvent(new CustomVarsEvent(CustomVarsEvent.CUSTOM_VAR_ADDED));
+ var lastItem:CustomVariableVO = customVars.length > 0 ? customVars[customVars.length - 1] as CustomVariableVO : null;
+ if (lastItem && lastItem.value == 'value' && lastItem.variable == 'variable')
+ {
+ eventDispatcher.dispatchEvent(new CustomVarsEvent(CustomVarsEvent.CANNOT_ADD_VAR));
+ }
+ else
+ {
+ var cv:CustomVariableVO = new CustomVariableVO();
+ customVars.push(cv);
+ eventDispatcher.dispatchEvent(new CustomVarsEvent(CustomVarsEvent.CUSTOM_VAR_ADDED));
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.