﻿package com.controller
{
	
	/**
	 * ...
	 * @author Snehalata Nagaje
	 */
	
	
	import com.comp.ComboboxWidget;
	import flash.display.MovieClip;
	import fl.controls.ComboBox;
	
	public class ComoboBoxController
	{
		static private var instance:ComoboBoxController;
		public var c_xmlCaptivateParams:XML;
		public var c_xmlConfigParams:XML;
		public var c_comoboxEditUIObj:ComboboxWidget;
		public var c_objRootRef;
		
		public function ComoboBoxController()
		{
			
		}
		
		public static function getInstance():ComoboBoxController
		{
			if(instance == null){
				instance =  new ComoboBoxController();
			}
			return instance;
		}
		
		public function execCommand(arg:String, data)
		{
			if (arg == "parseXML")
			{
				setData(data);
			}
			else if (arg == "createComoboxEditUI")
			{
				c_comoboxEditUIObj = new ComboboxWidget();
				c_comoboxEditUIObj.drawEditUI();
			}
			else if (arg == "setRootRef")
			{
				c_objRootRef = data;
			}
			else if (arg == "generateComobox")
			{
				c_comoboxEditUIObj = new ComboboxWidget();
				c_comoboxEditUIObj.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_comoboxEditUIObj.objectToString();
		}
	}
	
}