﻿package com.controller
{
	
	/**
	 * ...
	 * @author Snehalata Nagaje
	 */
	
	
	import com.comp.DropDownWidget;
	import flash.display.MovieClip;
	
	public class DropDownController
	{
		static private var instance:DropDownController;
		public var c_xmlCaptivateParams:XML;
		public var c_xmlConfigParams:XML;
		public var c_dropDownWidget:DropDownWidget;
		public var c_objRootRef;
		
		public function DropDownController()
		{
			
		}
		
		public static function getInstance():DropDownController
		{
			if(instance == null){
				instance =  new DropDownController();
			}
			return instance;
		}
		
		public function execCommand(arg:String, data)
		{
			if (arg == "parseXML")
			{
				setData(data);
			}
			else if (arg == "createDropDownEditUI")
			{
				c_dropDownWidget = new DropDownWidget();
				c_dropDownWidget.drawEditUI();
			}
			else if (arg == "setRootRef")
			{
				c_objRootRef = data;
			}
			else if (arg == "generateDropDown")
			{
				c_dropDownWidget = new DropDownWidget();
				c_dropDownWidget.generateComoboBox();
			}
		}
		
		
		
		/**
		* This function sets the XML data according to which the table is to be drawn.
		* If there is empty string passed, that means a default table is to be drawn.
		* @param strCaptivateXML Description This is xml in the form of string and carries all the parameters last set by the user. The data for each cell and modification done to the table resides in this xml only.
		*/
		private function setData(strCaptivateXML:String):void
		{
			c_xmlCaptivateParams = new XML(strCaptivateXML);
		}
		
		/**
		* This function always returns the latest XML whenever called.
		*/
		public function getModifiedXML():String
		{
			//trace("Data Object ::: "+inObjData);
			XML.prettyIndent = 0;
			XML.prettyPrinting = false;
			
			return c_dropDownWidget.objectToString();
		}
	}
	
}