/src/org/ishafoundation/archives/transcript/components/studio/text/GeneralNodePropertiesPane.mxml
http://transcriptstudio4isha.googlecode.com/ · Macromedia eXtensible Markup Language · 259 lines · 235 code · 24 blank · 0 comment · 0 complexity · 5f3e9f4ae58064a73ea2783eeffa11c3 MD5 · raw file
- <?xml version="1.0" encoding="utf-8"?>
-
- <!--
- Transcript Studio for Isha Foundation: An XML based application that allows users to define
- and store contextual metadata for contiguous sections within a text document.
-
- Copyright 2008 Mark Carter, Swami Kevala
-
- This file is part of Transcript Studio for Isha Foundation.
-
- Transcript Studio for Isha Foundation is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or (at your option) any later version.
-
- Transcript Studio for Isha Foundation is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- Transcript Studio for Isha Foundation. If not, see http://www.gnu.org/licenses/.
- -->
-
- <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="left" backgroundColor="#FFFFFF" enabled="{this.generalProps != null}" creationComplete="init()" minWidth="400" minHeight="200" paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5">
- <mx:Script>
- <![CDATA[
- import name.carter.mark.flex.project.mdoc.MSuperSegment;
- import mx.binding.utils.ChangeWatcher;
- import name.carter.mark.flex.project.mdoc.MSegmentSubset;
- import name.carter.mark.flex.project.mdoc.MSegmentRange;
- import mx.controls.Alert;
- import name.carter.mark.flex.project.mdoc.MSegment;
- import org.ishafoundation.archives.transcript.model.TranscriptTextSelection;
- import name.carter.mark.flex.util.Utils;
- import mx.collections.ArrayCollection;
- import org.ishafoundation.archives.transcript.model.Transcript;
- import mx.utils.StringUtil;
- import org.ishafoundation.archives.transcript.model.GeneralNodeProperties;
-
- [Bindable]
- public var generalProps:GeneralNodeProperties;
- [Bindable]
- private var _ttSelection:TranscriptTextSelection;
- [Bindable]
- public var allowTextEdit:Boolean = true;
-
- [Bindable]
- public var speakers:Array;
- [Bindable]
- public var spokenLanguages:Array = ["english", "tamil", "other"];
-
- [Bindable]
- public var sourceIds:Array;
-
- public function init():void {
- }
-
- public function set ttSelection(newValue:TranscriptTextSelection):void {
- this._ttSelection = newValue;
- if (this._ttSelection == null || this._ttSelection.selectedObj is MSuperSegment) {
- this.generalProps = null;
- }
- else {
- this.generalProps = GeneralNodeProperties.createInstance(this._ttSelection);
- }
- }
-
- private static function allowMultipleSegments(ttSelection:TranscriptTextSelection):Boolean {
- var allowMultipleSegments:Boolean = ttSelection.toSegmentRange() != null;
- if (ttSelection.toSegment() != null) {
- // check if the segment is also an inline
- var segment:MSegment = ttSelection.toSegment();
- if (segment.toContentRange().toSuperContent() != null) {
- // don't allow the contents of an inline to go multi-segment
- allowMultipleSegments = false;
- }
- }
- return allowMultipleSegments;
- }
-
- private function somethingChanged(affectedObj:Object = null):void {
- if (affectedObj == null) {
- // this panel always changes something (so don't pass null to the event)
- affectedObj = _ttSelection.selectedObj;
- }
- var ttSelection:TranscriptTextSelection = new TranscriptTextSelection(affectedObj);
- var event:Event = new TranscriptTextEvent(TranscriptTextEvent.DATA_CHANGE, ttSelection);
- dispatchEvent(event);
- }
-
- private function confidentialChanged():void {
- var newValue:Boolean = new Boolean(confidentialRadioButtonGroup.selectedValue);
- trace("Confidential changed: " + newValue);
- generalProps.confidential = newValue;
- somethingChanged();
- }
-
- private function speakerChanged():void {
- if (speakerComboBox.selectedItem == null) {
- // user is entering some text
- return;
- }
- var newValue:String = speakerComboBox.selectedItem.toString();
- trace("Speaker changed: " + newValue);
- generalProps.speaker = newValue;
- somethingChanged();
- }
-
- private function speakerHandler():void {
- if (speakerComboBox.selectedItem == null) {
- // user edited a new speaker?
- var newValue:String = Utils.normalizeSpace(speakerComboBox.text).toLowerCase();
- if (newValue.length > 0) {
- if (speakers.indexOf(newValue) < 0) {
- trace("New speaker set: " + newValue);
- speakers.push(newValue);
- }
- generalProps.speaker = newValue;
- somethingChanged();
- }
- }
- }
-
- private function spokenLanguageChanged():void {
- var newValue:String = languageComboBox.selectedItem.toString();
- trace("SpokenLanguage changed: " + newValue);
- generalProps.spokenLanguage = newValue;
- somethingChanged();
- }
-
- private function emphasisChanged():void {
- var newValue:Boolean = new Boolean(emphasisRadioButtonGroup.selectedValue);
- trace("Emphasis changed: " + newValue);
- generalProps.emphasis = newValue;
- somethingChanged();
- }
-
- private function textChanged(newTextArray:Array):void {
- if (newTextArray.length == 0) {
- Alert.show("Cannot remove all text. Try deleting the text instead.\n\nRestoring original text.");
- textStack.executeBindings(true);
- return;
- }
- var affectedObj:Object = _ttSelection.editText(newTextArray);
- if (affectedObj == null) {
- return;
- }
- somethingChanged(affectedObj);
- }
-
- private function segmentTextChanged():void {
- if (!textTextArea.editable) {
- // obviously it didnt change really
- return;
- }
- var newTextArray:Array = new Array();
- var newSegmentTexts:Array = textTextArea.text.split("\r");
- for each (var newSegmentText:String in newSegmentTexts) {
- newSegmentText = Utils.normalizeSpace(newSegmentText);
- if (newSegmentText.length > 0) {
- newTextArray.push(newSegmentText);
- }
- }
- textChanged(newTextArray);
- }
-
- private function subSegmentTextChanged():void {
- textTextInput.text = Utils.normalizeSpace(textTextInput.text);
- if (textTextInput.text.length == 0) {
- textChanged([]);
- }
- else {
- textChanged([textTextInput.text]);
- }
- }
-
- private static function getTextAreaText(ttSelection:TranscriptTextSelection):String {
- var range:MSegmentRange = ttSelection.toSegmentRange();
- if (range == null) {
- // this would be called when the text area is hidden
- return "";
- }
- return range.getTextCondensed();
- }
-
- private static function getTextInputText(ttSelection:TranscriptTextSelection):String {
- if (ttSelection.toSegmentSubset() == null) {
- // cannot show on one line - must be a range - so show nothing
- // note - if we don't do this and the user selects the whole doc - then very slow
- return "";
- }
- else {
- return ttSelection.getText();
- }
- }
- ]]>
- </mx:Script>
- <mx:HBox width="100%" horizontalGap="30">
- <mx:VBox width="100%" height="100%">
- <mx:ViewStack id="textStack" width="100%" height="100%" selectedIndex="{allowMultipleSegments(_ttSelection) ? 0 : 1}">
- <mx:HBox width="100%" height="100%">
- <mx:TextArea id="textTextArea" width="100%" height="100%" minHeight="60" editable="{allowTextEdit && _ttSelection.allowEditText()}" text="{getTextAreaText(_ttSelection)}" focusOut="segmentTextChanged()"/>
- </mx:HBox>
- <mx:HBox width="100%">
- <mx:TextInput id="textTextInput" width="100%" editable="{allowTextEdit}" text="{getTextInputText(_ttSelection)}" enter="subSegmentTextChanged()" focusOut="subSegmentTextChanged()"/>
- </mx:HBox>
- </mx:ViewStack>
- </mx:VBox>
- <mx:Grid horizontalAlign="center">
- <mx:GridRow height="100%" id="speakerGridRow" enabled="{generalProps != null && generalProps.speakerEnabled}">
- <mx:GridItem width="100%" height="100%" verticalAlign="middle">
- <mx:Label width="100%" textAlign="right" text="Speaker" paddingBottom="2" paddingTop="2"/>
- </mx:GridItem>
- <mx:GridItem width="100%" height="100%">
- <mx:ComboBox id="speakerComboBox" width="100%" enabled="{allowTextEdit}" dataProvider="{speakers}" editable="true" selectedIndex="{generalProps.speaker == null ? -1 : speakers.indexOf(generalProps.speaker)}" prompt="Select..." change="speakerChanged()" enter="speakerHandler()" focusOut="speakerHandler()"/>
- </mx:GridItem>
- <mx:GridItem height="100%">
- <mx:RadioButton label="mixed" enabled="false" id="speakerMixedRadioButton" selected="{generalProps.speaker == null}"/>
- </mx:GridItem>
- </mx:GridRow>
- <mx:GridRow height="100%">
- <mx:GridItem width="100%" height="100%" verticalAlign="middle">
- <mx:Label width="100%" textAlign="right" text="Spoken Language" paddingBottom="2" paddingTop="2"/>
- </mx:GridItem>
- <mx:GridItem width="100%" height="100%">
- <mx:ComboBox id="languageComboBox" width="100%" enabled="{allowTextEdit}" dataProvider="{spokenLanguages}" prompt="Select..." editable="false" selectedIndex="{generalProps.spokenLanguage == null ? -1 : spokenLanguages.indexOf(generalProps.spokenLanguage)}" change="spokenLanguageChanged()"/>
- </mx:GridItem>
- <mx:GridItem height="100%">
- <mx:RadioButton label="mixed" id="spokenLanguageMixedRadioButton" enabled="false" selected="{generalProps.spokenLanguage == null}"/>
- </mx:GridItem>
- </mx:GridRow>
- <mx:GridRow height="100%" enabled="{generalProps != null && generalProps.emphasisEnabled}">
- <mx:GridItem width="100%" height="100%" verticalAlign="middle">
- <mx:Label width="100%" textAlign="right" text="Emphasized" paddingBottom="2" paddingTop="2"/>
- </mx:GridItem>
- <mx:GridItem width="100%" height="100%">
- <mx:RadioButtonGroup id="emphasisRadioButtonGroup" enabled="{allowTextEdit}" selectedValue="{generalProps.emphasis == null ? 'mixed' : generalProps.emphasis.toString()}" change="emphasisChanged()"/>
- <mx:RadioButton label="true" groupName="emphasisRadioButtonGroup" id="emphasisTrueRadioButton" value="{true}"/>
- <mx:RadioButton label="false" groupName="emphasisRadioButtonGroup" id="emphasisFalseRadioButton" value="{false}"/>
- </mx:GridItem>
- <mx:GridItem height="100%">
- <mx:RadioButton label="mixed" groupName="emphasisRadioButtonGroup" enabled="false" id="emphasisMixedRadioButton"/>
- </mx:GridItem>
- </mx:GridRow>
- <mx:GridRow height="100%" id="confidentialGridRow" enabled="{generalProps != null && generalProps.confidentialEnabled}">
- <mx:GridItem width="100%" height="100%" verticalAlign="middle">
- <mx:Label width="100%" textAlign="right" text="Confidential"/>
- </mx:GridItem>
- <mx:GridItem width="100%" height="100%">
- <mx:RadioButtonGroup id="confidentialRadioButtonGroup" enabled="{allowTextEdit}" selectedValue="{generalProps.confidential == null ? 'mixed' : generalProps.confidential.toString()}" change="confidentialChanged()"/>
- <mx:RadioButton label="true" groupName="confidentialRadioButtonGroup" id="confidentialTrueRadioButton" value="{true}"/>
- <mx:RadioButton label="false" groupName="confidentialRadioButtonGroup" id="confidentialFalseRadioButton" value="{false}"/>
- </mx:GridItem>
- <mx:GridItem height="100%">
- <mx:RadioButton label="mixed" groupName="confidentialRadioButtonGroup" enabled="false" id="confidentialMixedRadioButton"/>
- </mx:GridItem>
- </mx:GridRow>
- </mx:Grid>
- </mx:HBox>
- </mx:VBox>