Index: gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/gssim/editors/archive/ExperimentStatisticsWindow.mxml
===================================================================
--- gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/gssim/editors/archive/ExperimentStatisticsWindow.mxml	(revision 22)
+++ gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/gssim/editors/archive/ExperimentStatisticsWindow.mxml	(revision 27)
@@ -42,5 +42,5 @@
 			//viewer.addEventListener("configurationLoaded", configurationLoadedEventHandler);
 			viewer.expId = i;
-			viewer.expName = experiment.name;
+			viewer.expName = (experiment != null ? experiment.name : "");
 			viewer.service = new VineRemoteObjectProxy(parentApplication.service, i);
 			resourceChart.addChild(viewer);
@@ -49,5 +49,5 @@
 			var gannt : GanntChart = new GanntChart();
 			gannt.expId = i;
-			gannt.expName = experiment.name;
+			gannt.expName = (experiment != null ? experiment.name : "");
 			gannt.service = new VineRemoteObjectProxy(parentApplication.service, i);
 			ganntChart.addChild(gannt);
@@ -57,6 +57,7 @@
 		{
 			//resourceChart.getChildAt(0).removeEventListener("configurationLoaded", configurationLoadedEventHandler);
-			
-			properties.loadFromHashmap(parentApplication.gsSimStudioModel.resourceChartComponents['' + experiment.PK].experimentConfiguration);
+			if (experiment != null)
+				if (parentApplication.gsSimStudioModel.resourceChartComponents['' + experiment.PK] != null)
+					properties.loadFromHashmap(parentApplication.gsSimStudioModel.resourceChartComponents['' + experiment.PK].experimentConfiguration);
 			
 		}
Index: gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/charts/GanntChart.mxml
===================================================================
--- gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/charts/GanntChart.mxml	(revision 22)
+++ gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/charts/GanntChart.mxml	(revision 27)
@@ -7,5 +7,5 @@
 	xmlns:fx="http://ns.adobe.com/mxml/2009"  
 	width="100%" creationComplete="init()"
-	height="100%" xmlns:charts="com.iwobanas.charts.*" xmlns:data="gssim.gssimstudio.editor.charting.data.*" xmlns:charts1="gssim.gssimstudio.editor.charts.*" 
+	height="100%" xmlns:charts="com.iwobanas.charts.*" xmlns:data="gssim.gssimstudio.editor.charting.data.*" xmlns:charts1="gssim.gssimstudio.editor.charts.*" xmlns:code="http://code.google.com/p/flexlib/" 
 >
 	
@@ -17,4 +17,10 @@
 	<fx:Script>
 	    <![CDATA[
+			import flexlib.scheduling.samples.ScheduleData;
+			import flexlib.scheduling.scheduleClasses.ColoredScheduleEntry;
+			import flexlib.scheduling.scheduleClasses.LayoutScrollEvent;
+			import flexlib.scheduling.scheduleClasses.SimpleScheduleEntry;
+			import flexlib.scheduling.util.DateUtil;
+			
 			import gssim.gssimstudio.editor.script.command.SaveToPNGCommand;
 			import gssim.gssimstudio.editor.script.views.ViewsHelper;
@@ -24,4 +30,5 @@
 			import mx.charts.chartClasses.AxisLabelSet;
 			import mx.collections.ArrayCollection;
+			import mx.collections.IList;
 			import mx.controls.Alert;
 			import mx.controls.HScrollBar;
@@ -29,6 +36,8 @@
 			import mx.controls.scrollClasses.ScrollBar;
 			import mx.events.FlexEvent;
+			import mx.events.ListEvent;
 			import mx.events.ResizeEvent;
 			import mx.events.ScrollEvent;
+			import mx.events.ScrollEventDirection;
 			import mx.events.SliderEvent;
 			import mx.messaging.management.ObjectInstance;
@@ -38,5 +47,31 @@
 	
 			[Bindable]
-			public var expId : int;
+			private var startDate : Date;
+			[Bindable]
+			private var endDate : Date;
+			[Bindable]
+			private var zoom : Number;
+			[Bindable]
+			private var scheduleViewerWidth : Number = 635;
+			[Bindable]
+			private var scheduleViewerHeight : Number = 4*50;
+			[Bindable]
+			private var dataProvider : IList;
+			[Bindable]
+			private var rowDataProvider : IList= new ArrayCollection();
+			private var listIndex:Number = 1;
+			private var isVZoomed:Boolean = false;
+			[Bindable]
+			private var vZoom:Number;
+			private var historyLength : int = 2;
+			private var lastPosRowList:Number = 0;
+			private var tempRowDataProvider:IList;
+			private var tempDataProvider:IList;
+			private var reservations:Object = new Object();
+			private var tasks:Object = new Object();
+			
+			
+			[Bindable]
+			public var expId : int = -1;
 			[Bindable]
 			public var expName : String;
@@ -44,26 +79,4 @@
 			[Bindable]
 			protected var date : Date = new Date();
-
-			private function formatDate(value:Date, previousValue:Date, axis:DateTimeAxis) : String 
-			{      
-				var percent : Number = 1;//_hZoom / 100;
-				var limit : Number = (hAxis.maximum.getTime() - hAxis.minimum.getTime()) * 0.07;
-				
-				if (hAxis.maximum.getTime() - value.getTime() > limit)
-				{
-					var dateLabel : String = df.format(value);
-					var dateLabelLongSec : String = dateLabel;
-					if (value.seconds < 10)
-					{
-						dateLabelLongSec = dateLabel.substring(0, dateLabel.length - 1);
-						dateLabelLongSec += "0" + value.seconds;
-					}
-					return dateLabelLongSec;
-				}
-				else
-				{
-					return "";
-				}
-			}
 			
 			private function saveAsPNG() : void
@@ -76,10 +89,208 @@
 			protected function initChart() : void
 			{
-				
-			}
+				initDataProvider();
+				vZoom = 50;
+				rowsList.selectedIndex = 0;
+				setVerticalScrollPosition(0);
+			}
+			
+			/* start of copy */
+			
+			protected function initFake() : void
+			{
+				
+			}
+			
+			/*
+			private function setTimeframe():void {
+				startDate = DateUtil.clearTime(new Date((new Date()).getTime() - DateUtil.DAY_IN_MILLISECONDS * historyLength));
+				endDate = getEndDate(startDate);
+			}
+			
+			private function getEndDate(startDate:Date):Date {
+				var duration:Number = DateUtil.DAY_IN_MILLISECONDS * (historyLength + 1);
+				var endDate:Date = new Date(startDate.getTime() + duration);
+				return endDate;
+			}
+			*/
+			
+			private function initDataProvider():void {
+				
+				dataProvider = new ArrayCollection();
+				getRowsData();
+				scheduleViewer.invalidateDisplayList();
+				this.validateNow();
+				rowsList.verticalScrollPosition = lastPosRowList;
+				rowsList.selectedIndex = listIndex;
+				
+			}
+			
+			private function randomInt(max:Number):Number {
+				return Math.floor(Math.random() * max);
+			}
+			
+			private function getRowsData():void {
+				
+				var data : ArrayCollection = parentApplication.gsSimStudioModel.ganntChartComponents['' + expId].allocationList;
+				
+				startDate = new Date(3000);
+				endDate = new Date(0);
+				
+				tempDataProvider = new ArrayCollection();
+				tempRowDataProvider = new ArrayCollection();
+				var resMap : Object = new Object();
+				
+				for( var i : Number = 0; i < data.length; i++ )
+				{
+					if (!resMap.hasOwnProperty(data[i].unitId))
+					{
+						resMap[data[i].unitId] = new ArrayCollection();
+						tempRowDataProvider.addItem("Unit " + data[i].unitId);
+					}
+					
+					var dummycolor : uint = 0x999999 + randomInt( 0x777777 );
+					
+					resMap[data[i].unitId].addItem(createColoredEntry(data[i].taskId, data[i].begin, data[i].end, dummycolor, 1,0,1));
+					
+					if (data[i].begin < startDate) startDate = new data[i].begin;
+					if (data[i].end > endDate) endDate = new data[i].end;
+				}
+				
+				for each (var key : String in resMap)
+				{
+					tempDataProvider.addItem(resMap[key]);
+				}
+				
+				dataProvider = tempDataProvider;
+				rowDataProvider = tempRowDataProvider;
+				
+				Alert.show("finished! " + startDate + " " + endDate);
+			}
+			
+			private function createColoredEntry(i:Number, startTime:Number, endTime:Number, color:uint, levelStart:int, levelCount:int, levelTotal:int):SimpleScheduleEntry {
+				var entry:ColoredScheduleEntry = new ColoredScheduleEntry();
+				entry.startDate = new Date(startTime);//DateUtil.setTime( new Date(), startTime );
+				entry.endDate = new Date(endTime);//DateUtil.addTime( DateUtil.copyDate( entry.startDate ), duration );
+				entry.label = "Reservation " + i;
+				entry.backgroundColor = color;
+				/*
+				entry.levelStart = levelStart;
+				entry.levelCount = levelCount;
+				entry.levelTotal = levelTotal;
+				*/
+				return entry;
+			}
+			/* end of copy */
 			
 			protected function init():void
 			{
-				parentApplication.addModelUpdatedSingleCallbacks(service.getTasksAllocationsFromDb(expId), initChart);
+				if (expId != -1)
+					parentApplication.addModelUpdatedSingleCallbacks(service.getTasksAllocationsFromDb(expId), initChart);
+				else
+					initFake();
+			}
+			
+			private function onScrollTimeline( position : Number ) : void
+			{
+				scheduleViewer.xPosition = position;
+			}
+			
+			private function onScrollScheduleViewer( event : ScrollEvent ) : void
+			{
+				if( event.direction == ScrollEventDirection.HORIZONTAL )
+				{
+					timeline.xPosition = event.position;
+				}
+			}
+			
+			private function scrollList( event : LayoutScrollEvent ) : void
+			{
+				if( event.direction == ScrollEventDirection.VERTICAL )
+				{
+					rowsList.verticalScrollPosition = event.position;      
+				}
+			}
+			
+			protected function rowsList_itemClickHandler(event:ListEvent):void {
+				listIndex = event.rowIndex;
+			}
+			
+			private function onZoom(value:Number):void {
+				zoom = value;
+			}
+			
+			private function onZoomVertical(value:Number):void {
+				//if(value >= 10){
+				var verScrollPos:Number = scheduleViewer.verticalScrollPosition;
+				//scheduleViewer.zoomRow(value);
+				var posPix:Number = verScrollPos / scheduleViewer.rowHeight;
+				var posItem:Number = Math.ceil(posPix) * scheduleViewer.rowHeight;
+				
+				
+				//scheduleViewer.navigator.entryLayoutImpl.contentHeight = rowDataProvider.length * value;
+				//scheduleViewer.yPosition =posItem * value;
+				//rowsList.verticalScrollPosition
+				//setVerticalScrollPosition(posItem * value);
+				
+				//if(rowsList.selectedIndex == -1)
+				//	rowsList.selectedIndex = 0;
+				var beforeValue:Number = scheduleViewer.rowHeight;
+				scheduleViewer.rowHeight = value;
+				if (rowsList.selectedIndex == -1) {
+					rowsList.selectedIndex = 0;
+					setVerticalScrollPosition(0);
+				} else {
+					/*if((IList(rowsList.dataProvider).length - (rowsList.selectedIndex+1))*value < rowsList.height){
+					//scheduleViewer.yPosition = (rowsList.selectedIndex + (IList(rowsList.dataProvider).length - (rowsList.selectedIndex+1)))* value;
+					var pos : Number = scheduleViewer.yPosition / value;
+					scheduleViewer.yPosition = rowsList.selectedIndex * value;
+					rowsList.verticalScrollPosition = scheduleViewer.yPosition;
+					}else{*/
+					//rowsList.of
+					isVZoomed = true;
+					if (beforeValue > value) {
+						scheduleViewer.yPosition = rowsList.selectedIndex * (value - 1);
+						
+						rowsList.validateDisplayList();
+					}
+					scheduleViewer.yPosition = rowsList.selectedIndex * value;
+					listIndex = rowsList.selectedIndex;
+					rowsList.verticalScrollPosition = rowsList.selectedIndex;
+					rowsList.validateDisplayList();
+					this.validateNow();
+					
+					
+					//}
+				}
+				
+				//scheduleViewer.yOffset = value;
+				//rowsList.rowHeight = value;
+				//var item : EntryLayoutItem = scheduleViewer.navigator.entryLayoutImpl.findLayoutItem( scheduleViewer.selectedItem );
+				//rowsList.verticalScrollPosition = scheduleViewer.navigator.convertPixelToItemPosition(item.y);
+				//}
+				//else{
+				//scheduleViewer.zoomRow( 10);
+				//scheduleViewer.yOffset = 10;
+				//rowsList.rowHeight = 10;
+				//rowsList.verticalScrollPosition = lastPosRowList;
+				
+				//}
+			}
+			
+			private function setVerticalScrollPosition(value:Number):void {
+				/*var event : ScrollEvent = new ScrollEvent( ScrollEvent.SCROLL );
+				event.direction = ScrollEventDirection.VERTICAL;
+				event.position = value;
+				event.delta = 0;//scheduleViewer.verticalScrollPosition - value;
+				event.detail = "custom";
+				//scheduleViewer.verticalScrollPosition = value;
+				scheduleViewer.dispatchEvent( event );*/
+				
+				var itemScrollEvent:LayoutScrollEvent = new LayoutScrollEvent(LayoutScrollEvent.PIXEL_SCROLL);
+				itemScrollEvent.direction = ScrollEventDirection.VERTICAL;
+				itemScrollEvent.position = value;
+				itemScrollEvent.delta = 0;//scheduleViewer.verticalScrollPosition - value;
+				itemScrollEvent.detail = "custom";
+				scheduleViewer.dispatchEvent(itemScrollEvent);
 			}
 			
@@ -116,46 +327,118 @@
 			<mx:Label text="{resourceManager.getString('Charts', 'CreatedFor')} {expName} {resourceManager.getString('Charts', 'Day')} {date}" width="100%" styleName="subtitle"/>
 			<mx:HBox width="100%" height="100%">
-				<mx:VBox width="100%" height="100%">
-				
-					<!--~~~~~~~~~~ RESOURCE VIEWER ~~~~~~~~~~-->
-					<mx:AreaChart 
-						id="resourceViewer" height="100%" width="100%"
-				        paddingRight="5" paddingLeft="5"
-						dataProvider="{parentApplication.gsSimStudioModel.resourceChartComponents['' + expId].resourceTimelineList}"
-				    >
-				        <mx:horizontalAxis>
-				            <mx:DateTimeAxis 
-				            	id="hAxis" 
-				            	dataUnits="seconds" 
-				            	alignLabelsToUnits="false" 
-				            	labelFunction="formatDate" 
-				            	title="{resourceManager.getString('Charts', 'SimulationTime')}"
-				             />
-				        </mx:horizontalAxis>
-				
-				        <mx:verticalAxis>
-				            <mx:LinearAxis 
-				            	id="vAxis" 
-				            	baseAtZero="false" 
-				            	maximumLabelPrecision="1" 
-				            	autoAdjust="false" 
-				            	title="{resourceManager.getString('Charts', 'CPU')}"
-				            />
-				        </mx:verticalAxis>
-				
-						<mx:series>
-				            <mx:AreaSeries 
-								filterData="false"
-				            	yField="usage" 
-				            	xField="timestamp" 
-				            	form="step" 
-				            	areaFill="{sc3}" 
-				            />
-				        </mx:series>
-					     
-				    </mx:AreaChart>
-				    <!--~~~~~~~~~~ END OF RESOURCE VIEWER ~~~~~~~~~~-->
-				    
-				</mx:VBox>
+				<s:VGroup>
+					<s:VGroup height="{ timeline.height }">
+						<mx:Label text="Machines"/>
+					</s:VGroup>
+					<mx:List id="rowsList" width="135" height="{ scheduleViewerHeight }"
+							 dataProvider="{ rowDataProvider }" rowHeight="{ scheduleViewer.rowHeight }"
+							 verticalAlign="middle" verticalScrollPolicy="off"
+							 itemClick="rowsList_itemClickHandler(event)" selectable="true">
+						
+						
+					</mx:List>
+					
+				</s:VGroup>
+				
+				<s:VGroup>
+					<code:Timeline id="timeline" width="{ scheduleViewerWidth }" borderStyle="none"
+									  endDate="{ endDate }" scroll="onScrollTimeline( event.position );"
+									  startDate="{ startDate }" zoom="{ zoom }"/>
+					
+					<code:ScheduleViewer id="scheduleViewer" width="{ scheduleViewerWidth }"
+											height="{ scheduleViewerHeight }" borderStyle="none"
+											dataProvider="{ dataProvider }" endDate="{ endDate }"
+											entryLayout="flexlib.scheduling.scheduleClasses.layout.SimpleLayout"
+											entryRenderer="flexlib.scheduling.scheduleClasses.renderers.ColoredSolidScheduleEntryRenderer"
+											horizontalLinesViewer="flexlib.scheduling.samples.AlternatingHorizontalLinesViewer"
+											horizontalScrollPolicy="off" itemScroll="scrollList( event )"
+											pixelScroll="onScrollScheduleViewer( event )"
+											pixelScrollEnabled="false" startDate="{ startDate }"
+											verticalLinesViewer="flexlib.scheduling.samples.SolidVerticalLinesViewer"
+											zoom="{ zoom }" /> <!--currentStateChange="viewerComplete(event)" click="onClickEntry(event)"/>-->
+					<s:HGroup width="{ scheduleViewerWidth }">
+						<s:Group>
+							<s:Rect width="100%" height="100%">
+								<s:stroke>
+									<s:SolidColorStroke color="0x999999" weight="1"/>
+								</s:stroke>
+							</s:Rect>
+							<!--
+							<s:HGroup left="10" top="10" right="10" bottom="10">
+								
+								<s:Label text="set number of hosts for page:" top="5"/>
+								<s:NumericStepper id="hostsOnPage" minimum="1" maximum="50" value="{ hostsOnPageVal }"/>
+								<s:Button id="setHostsOnPage" click="setHostsOnPage_clickHandler(event)" label="Set"/>
+								<s:Rect width="50" height="1"/>
+								<s:Label text="page number:" top="5"/>
+								<s:NumericStepper id="pageStepper" value="{ pageNumber }" minimum="1"
+												  change="changePage(event)"/>
+							</s:HGroup>
+							-->
+							
+						</s:Group>
+						<s:HGroup width="100%">
+							<s:Label text="Zoom:" top="5"/>
+							<s:HSlider width="100%" id="zoomSlider" change="onZoom( zoomSlider.value );" liveDragging="true"
+									   maximum="1000" minimum="1" snapInterval="1" value="{ zoom }"/>
+						</s:HGroup>
+					</s:HGroup>
+					<s:Group>
+						<s:Rect width="100%" height="100%">
+							<s:stroke>
+								<s:SolidColorStroke color="0x999999" weight="1"/>
+							</s:stroke>
+						</s:Rect>
+						<!--
+						<s:HGroup width="{ scheduleViewerWidth }" left="10" top="10" right="10" bottom="10">
+							
+							<s:Label text="Goto:" top="5"/>
+							<s:Button label="Now" click="gotoNow();"/>
+							<s:Button label="Selected" click="gotoSelectedEntry();"/>
+							<s:Rect width="100%"/>
+							<s:Button label="Matrix" click="openMatrix()"/>
+							<s:Label text="History (days):" top="5"/>
+							<s:TextInput id="srcHistory" width="25" text="2"/>
+							<s:Button label="Apply"
+									  click="historyLength = int(srcHistory.text); onReservationsReady();"/>
+						</s:HGroup>
+						-->
+					</s:Group>
+					<s:Group>
+						<s:Rect width="100%" height="100%">
+							<s:stroke>
+								<s:SolidColorStroke color="0x999999" weight="1"/>
+							</s:stroke>
+						</s:Rect>
+						<!--
+						<s:HGroup width="{ scheduleViewerWidth }" left="10" top="10" right="10" bottom="10">
+							<s:Label text="Show:" top="15"/>
+							
+							<s:RadioButton id="onlyJob" label="Only Reservations" groupName="groupByType" selected="true"
+										   value="onlyJob"/>
+							<s:RadioButton id="onlyTask" label="Only Tasks" groupName="groupByType" value="onlyTask"/>
+							<s:RadioButton id="both" label="Reservations and Tasks" groupName="groupByType"
+										   value="both"/>
+							<s:Rect width="33%" height="1"/>
+							<s:Label text="Group by:" top="5"/>
+							
+							<s:RadioButton id="Job" label="Job" groupName="groupByRBG" selected="true" value="Job"/>
+							<s:RadioButton id="Task" label="Task" groupName="groupByRBG" value="Task"/>
+							<s:RadioButton id="ProcessGroup" label="Process Group" groupName="groupByRBG"
+										   value="ProcessGroup"/>
+						</s:HGroup>
+						-->
+					</s:Group>
+					
+				</s:VGroup>
+				<s:VGroup width="60" height="100%">
+					<mx:Spacer height="{ timeline.height + (scheduleViewer.height - vZoomSlider.height) / 4 }"/>
+					<mx:Label text="V Zoom"/>
+					<mx:VSlider id="vZoomSlider" change="onZoomVertical(vZoomSlider.value);"
+								liveDragging="true" maximum="{scheduleViewerHeight}" minimum="10" snapInterval="2"
+								value="{ vZoom }"/>
+					
+					
+				</s:VGroup>
 			</mx:HBox>
 		</mx:VBox>
Index: gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/GSSimStudio.mxml
===================================================================
--- gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/GSSimStudio.mxml	(revision 15)
+++ gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/app/gssim/gssimstudio/editor/GSSimStudio.mxml	(revision 27)
@@ -12,5 +12,5 @@
 				preloader="gssim.gssimstudio.editor.script.preloader.CustomPreloader"
 				paddingLeft="0" paddingRight="0"
-				paddingTop="0" paddingBottom="0">
+				paddingTop="0" paddingBottom="0" xmlns:charts="gssim.gssimstudio.editor.charts.*">
 	
 <fx:Metadata>
@@ -127,3 +127,6 @@
 </s:SkinnableContainer>
 	
+	<!-- this is to prevent the style collission when loading this component dynamically -->
+	<charts:GanntChart visible="false" includeInLayout="false"/>
+	
 </vine:VineApplication>
