PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/src/org/ishafoundation/archives/transcript/components/studio/session/SessionMetadataPane.mxml

http://transcriptstudio4isha.googlecode.com/
Macromedia eXtensible Markup Language | 147 lines | 138 code | 9 blank | 0 comment | 0 complexity | acc36795d8d3142d913bf027638e4c92 MD5 | raw file
  1<?xml version="1.0" encoding="utf-8"?>
  2<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="creationCompleteHandler()" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10">
  3	<mx:Script>
  4	<![CDATA[
  5		import org.ishafoundation.archives.transcript.model.ReferenceManager;
  6		import org.ishafoundation.archives.transcript.model.EventMetadata;
  7		import mx.controls.Alert;
  8		import org.ishafoundation.archives.transcript.model.SessionMetadata;
  9		import mx.events.PropertyChangeEvent;
 10		import mx.binding.utils.ChangeWatcher;
 11		import name.carter.mark.flex.util.collection.HashSet;
 12		import name.carter.mark.flex.util.collection.ISet;
 13		import mx.utils.StringUtil;
 14		import mx.formatters.DateBase;
 15		import name.carter.mark.flex.util.Utils;
 16		import name.carter.mark.flex.util.XMLUtils;
 17		import mx.collections.ArrayCollection;
 18		
 19		[Bindable]
 20		public var referenceMgr:ReferenceManager;
 21		
 22		[Bindable]
 23		public var selectableStartAtRange:Object;
 24		
 25		private var _sessionMetadata:SessionMetadata;
 26		
 27		private function creationCompleteHandler():void {
 28			var hourArr:Array = [];
 29			for (var hour:int = 0; hour < 24; hour++) {
 30				var hourStr:String = hour.toString();
 31				while (hourStr.length < 2) {
 32					hourStr = "0" + hourStr;
 33				}
 34				hourArr.push(hourStr);
 35			}
 36			hourComboBox.dataProvider = hourArr;
 37			hourComboBox.selectedIndex = hourArr.length / 2;
 38			var minuteArr:Array = [];
 39			for (var minute:int = 0; minute < 60; minute++) {
 40				var minuteStr:String = minute.toString();
 41				if (minute % 15 == 0) {
 42					while (minuteStr.length < 2) {
 43						minuteStr = "0" + minuteStr;
 44					}
 45					minuteArr.push(minuteStr);
 46				}
 47			}
 48			minuteComboBox.dataProvider = minuteArr;
 49			//minuteComboBox.selectedIndex = minuteArr.length / 2;
 50		}
 51		
 52		[Bindable]
 53		public function get sessionMetadata():SessionMetadata {
 54			return _sessionMetadata;
 55		}
 56		
 57		public function set sessionMetadata(newProps:SessionMetadata):void {
 58			if (newProps === _sessionMetadata) {
 59				return;
 60			}
 61			_sessionMetadata = newProps;
 62			sessionSubTitleTextInput.text = _sessionMetadata.subTitle;
 63			var startAt:Date = _sessionMetadata.startAt;
 64			startAtDateField.selectedDate = startAt;
 65			if (_sessionMetadata.startAtIncludesTime()) {
 66				unknownTimeCheckBox.selected = false;
 67				hourComboBox.selectedItem = fixWidth(startAt.hours, 2);
 68				minuteComboBox.selectedItem = fixWidth(startAt.minutes, 2);
 69			}
 70			else {
 71				unknownTimeCheckBox.selected = true;
 72			}
 73			startAtChangeHandler();
 74			notesTextArea.text = _sessionMetadata.notes;
 75		}
 76		
 77		private static function fixWidth(value:int, minLength:int):String {
 78			var result:String = value.toString();
 79			while (result.length < minLength) {
 80				result = "0" + result;
 81			} 
 82			return result;
 83		}
 84		
 85		private function startAtChangeHandler():void {
 86			var startAt:Date = startAtDateField.selectedDate;
 87			if (startAt == null) {
 88				sessionMetadata.setStartAt(null, false);
 89			}
 90			else {
 91				// maybe we need to incorporate the time too
 92				if (!unknownTimeCheckBox.selected) {
 93					startAt.hours = int(hourComboBox.selectedItem);
 94					startAt.minutes = int(minuteComboBox.selectedItem);
 95					sessionMetadata.setStartAt(startAt, true);
 96				}
 97				else {
 98					sessionMetadata.setStartAt(startAt, false);
 99				}
100			}
101			mainGrid.executeChildBindings(true);
102		} 
103		
104	]]>
105	</mx:Script>
106	<mx:Boolean id="ready">{true}</mx:Boolean>
107	<mx:Grid id="mainGrid" width="100%" height="100%">
108		<mx:GridRow width="100%">
109			<mx:GridItem height="100%" horizontalAlign="right" verticalAlign="middle">
110				<mx:Label text="Session Sub Title"/>
111			</mx:GridItem>
112			<mx:GridItem width="100%" height="100%" verticalAlign="middle">
113				<mx:TextInput width="100%" id="sessionSubTitleTextInput" change="{sessionMetadata.subTitle = sessionSubTitleTextInput.text}"/>
114			</mx:GridItem>
115		</mx:GridRow>
116		<mx:GridRow width="100%">
117			<mx:GridItem height="100%" horizontalAlign="right" verticalAlign="middle">
118				<mx:Label text="Session Date"/>
119			</mx:GridItem>
120			<mx:GridItem width="100%" height="100%" verticalAlign="middle">
121				<mx:DateField id="startAtDateField" formatString="DD/MM/YYYY" change="{startAtChangeHandler()}" selectableRange="{selectableStartAtRange}"/>
122			</mx:GridItem>
123		</mx:GridRow>
124		<mx:GridRow width="100%" enabled="{startAtDateField.selectedDate != null}">
125			<mx:GridItem height="100%" horizontalAlign="right" verticalAlign="middle">
126				<mx:Label text="Scheduled Start Time"/>
127			</mx:GridItem>
128			<mx:GridItem width="100%" height="100%" verticalAlign="middle">
129				<mx:HBox horizontalGap="2" enabled="{!unknownTimeCheckBox.selected}" verticalAlign="middle">
130					<mx:ComboBox width="55" id="hourComboBox" rowCount="13" change="{startAtChangeHandler()}"/>
131					<mx:Label text=":" textAlign="center" maxWidth="10"/>
132					<mx:ComboBox width="55" id="minuteComboBox" rowCount="12" change="{startAtChangeHandler()}"/>
133					<mx:Label text="(hh:mm)"/>					
134				</mx:HBox>
135				<mx:CheckBox label="unknown" labelPlacement="left" width="100%" textAlign="right" id="unknownTimeCheckBox" change="{startAtChangeHandler()}"/>
136			</mx:GridItem>
137		</mx:GridRow>
138		<mx:GridRow width="100%" height="100%">
139			<mx:GridItem height="100%" horizontalAlign="right" verticalAlign="top" paddingTop="2">
140				<mx:Label text="Notes"/>
141			</mx:GridItem>
142			<mx:GridItem width="100%" height="100%" verticalAlign="middle">
143				<mx:TextArea id="notesTextArea" width="100%" height="100%" change="{sessionMetadata.notes = notesTextArea.text}"/>
144			</mx:GridItem>
145		</mx:GridRow>
146	</mx:Grid>
147</mx:VBox>