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