PageRenderTime 18ms CodeModel.GetById 8ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/src/org/ishafoundation/archives/transcript/components/studio/text/TranscriptTextPane.mxml

http://transcriptstudio4isha.googlecode.com/
Macromedia eXtensible Markup Language | 124 lines | 106 code | 18 blank | 0 comment | 0 complexity | 2be5adbe78a4625be817c5c2c568f707 MD5 | raw file
  1<!--
  2   Transcript Studio for Isha Foundation: An XML based application that allows users to define 
  3   and store contextual metadata for contiguous sections within a text document. 
  4
  5   Copyright 2008 Mark Carter, Swami Kevala
  6
  7   This file is part of Transcript Studio for Isha Foundation.
  8
  9   Transcript Studio for Isha Foundation is free software: you can redistribute it and/or modify it 
 10   under the terms of the GNU General Public License as  published by the Free Software 
 11   Foundation, either version 3 of the License, or (at your option) any later version.
 12
 13   Transcript Studio for Isha Foundation is distributed in the hope that it will be useful, but 
 14   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 15   FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 16
 17   You should have received a copy of the GNU General Public License along with 
 18   Transcript Studio for Isha Foundation. If not, see http://www.gnu.org/licenses/.
 19-->
 20<mx:VDividedBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:textNS="org.ishafoundation.archives.transcript.components.studio.text.*" resizeToContent="true" creationComplete="init()">
 21	<mx:Script>
 22    <![CDATA[
 23    	import org.ishafoundation.archives.transcript.model.ReferenceManager;
 24    	import org.ishafoundation.archives.transcript.model.GeneralNodeProperties;
 25    	import org.ishafoundation.archives.transcript.model.TranscriptTextSelection;
 26    	import name.carter.mark.flex.util.Utils;
 27    	import mx.events.PropertyChangeEvent;
 28    	import mx.binding.utils.ChangeWatcher;
 29    	import name.carter.mark.flex.project.mdoc.MContentProperties;
 30    	import name.carter.mark.flex.project.mdoc.MSegmentProperties;
 31    	import name.carter.mark.flex.project.mdoc.MNode;
 32    	import name.carter.mark.flex.project.mdoc.MDocument;
 33    	import name.carter.mark.flex.project.mdoc.MSuperNode;
 34    	import name.carter.mark.flex.project.mdoc.MSuperNodeProperties;
 35    	import name.carter.mark.flex.project.mdoc.MSegment;
 36    	import name.carter.mark.flex.project.mdoc.MSuperContent;
 37    	import name.carter.mark.flex.project.mdoc.MSuperSegment;
 38    	import name.carter.mark.flex.project.mdoc.TaggableMNode;
 39    	import org.ishafoundation.archives.transcript.model.Transcript;
 40    	import name.carter.mark.flex.util.icon.IconUtils;
 41    	
 42    	[Bindable]
 43		public var referenceMgr:ReferenceManager;
 44		
 45		[Bindable]
 46		public var allowTextEdit:Boolean = true;
 47
 48		private var _transcript:Transcript;
 49		
 50		[Bindable]
 51		public var ttSelection:TranscriptTextSelection;
 52		
 53		private function init():void {
 54			this.addEventListener(TranscriptTextEvent.SELECTION_CHANGE, function(evt:TranscriptTextEvent):void {
 55				select(evt.affectedTtSelection);				
 56			});
 57			this.addEventListener(TranscriptTextEvent.DATA_CHANGE, function(evt:TranscriptTextEvent):void {
 58				redrawAndSelect(evt.affectedTtSelection);
 59			});			
 60		}
 61		
 62		[Bindable]
 63		public function set transcript(transcript:Transcript):void {
 64			trace("Setting transcript");
 65			this._transcript = transcript;
 66			this.transcriptTextArea.transcript = transcript;
 67			select(null);
 68			var speakers:Array = transcript.mdoc.getAllPropertyValues(MSegmentProperties.SPEAKER_PROP_NAME).toArray();
 69			if (speakers.indexOf(MSegmentProperties.SPEAKER_DEFAULT) < 0) {
 70				speakers.unshift(MSegmentProperties.SPEAKER_DEFAULT);
 71			}
 72			if (speakers.indexOf(MSegmentProperties.SPEAKER_SADHGURU) < 0) {
 73				speakers.unshift(MSegmentProperties.SPEAKER_SADHGURU);
 74			}
 75			this.generalNodePropertiesPane.speakers = speakers;
 76			// add any spoken languages in the XML but not in the built in list
 77			var spokenLanguages:Array = transcript.mdoc.getAllPropertyValues(MContentProperties.SPOKEN_LANGUAGE_PROP_NAME).toArray();
 78			for each (var spokenLanguage:String in spokenLanguages) {
 79				if (this.generalNodePropertiesPane.spokenLanguages.indexOf(spokenLanguage) < 0) {
 80					this.generalNodePropertiesPane.spokenLanguages.push(spokenLanguage);
 81				}
 82			}
 83		}
 84		
 85		public function get transcript():Transcript {
 86			return this._transcript;
 87		}
 88		
 89		public function selectMarkup(markup:MSuperNode):void {
 90			select(TranscriptTextSelection.createSuperNodeInstance(markup));
 91		}
 92		
 93		public function redrawAndSelectMarkup(markup:MSuperNode):void {
 94			redrawAndSelect(TranscriptTextSelection.createSuperNodeInstance(markup));
 95		}
 96		
 97		public function select(newSelection:TranscriptTextSelection):void {
 98			this.ttSelection = null; // hack - to trigger bindings
 99			if (newSelection != null) {
100				this.ttSelection = newSelection;
101			}
102			this.generalNodePropertiesPane.ttSelection = newSelection;
103			this.transcriptTextArea.select(newSelection);
104		}
105		
106		public function redrawAndSelect(ttSelection:TranscriptTextSelection):void {
107			this.ttSelection = null; // hack - to trigger bindings
108			this.ttSelection = ttSelection;
109			this.generalNodePropertiesPane.ttSelection = ttSelection;
110			this.transcriptTextArea.redraw(ttSelection);				
111		}
112		
113		public function setPropertiesPaneVisibility(visible:Boolean):void {
114			this.nodePropertiesPane.includeInLayout = visible;
115			this.nodePropertiesPane.visible = visible;
116		}		
117		
118    ]]>
119	</mx:Script>
120	<textNS:TranscriptTextArea id="transcriptTextArea" width="100%" height="75%" referenceMgr="{this.referenceMgr}"/>
121	<mx:TabNavigator id="nodePropertiesPane" width="100%" height="25%" minWidth="350" minHeight="200" includeInLayout="false">
122		<textNS:GeneralNodePropertiesPane id="generalNodePropertiesPane" allowTextEdit="{allowTextEdit}" label="Selected Text" width="100%"/>
123	</mx:TabNavigator>		
124</mx:VDividedBox>