/src/org/ishafoundation/archives/transcript/components/studio/MainPanel.mxml

http://transcriptstudio4isha.googlecode.com/ · Macromedia eXtensible Markup Language · 637 lines · 592 code · 45 blank · 0 comment · 0 complexity · b697faa74052a155cbd595e77409da78 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:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:studioNS="org.ishafoundation.archives.transcript.components.studio.*" width="100%" height="100%" verticalGap="0" keyDown="keyDownHandler(event)">
  16. <mx:Script>
  17. <![CDATA[
  18. import mx.events.FlexEvent;
  19. import org.ishafoundation.archives.transcript.model.Transcript;
  20. import org.ishafoundation.archives.transcript.model.TranscriptTextSelection;
  21. import com.ericfeminella.collections.HashMap;
  22. import com.ericfeminella.collections.IMap;
  23. import mx.events.PropertyChangeEvent;
  24. import org.ishafoundation.archives.transcript.components.studio.importer.TranscriptsToImportSelectorDialog;
  25. import org.ishafoundation.archives.transcript.components.studio.importer.ImportDialog;
  26. import mx.utils.StringUtil;
  27. import mx.managers.CursorManager;
  28. import org.ishafoundation.archives.transcript.components.studio.session.SessionSelectorDialog;
  29. import org.ishafoundation.archives.transcript.components.studio.OpenDialog;
  30. import org.ishafoundation.archives.transcript.components.studio.OpenByIdDialog;
  31. import org.ishafoundation.archives.transcript.util.ApplicationUtils;
  32. import org.ishafoundation.archives.transcript.db.DatabaseConstants;
  33. import org.ishafoundation.archives.transcript.importer.MSWordImporter;
  34. import name.carter.mark.flex.util.XMLUtils;
  35. import name.carter.mark.flex.util.Utils;
  36. import name.carter.mark.flex.util.icon.IconUtils;
  37. import org.ishafoundation.archives.transcript.components.generic.UnhandledChangesPopUpManager;
  38. import org.ishafoundation.archives.transcript.db.DatabaseManagerUtils;
  39. import mx.controls.Alert;
  40. import org.ishafoundation.archives.transcript.components.generic.AboutBox;
  41. import org.ishafoundation.archives.transcript.components.studio.session.SessionMetadataEditorDialog;
  42. import org.ishafoundation.archives.transcript.model.SessionMetadata;
  43. import org.ishafoundation.archives.transcript.model.SessionManager;
  44. import org.ishafoundation.archives.transcript.model.ReferenceManager;
  45. import mx.managers.PopUpManager;
  46. import name.carter.mark.flex.project.mdoc.*;
  47. import org.ishafoundation.archives.transcript.components.studio.media.MediaPlayerDialog;
  48. import org.ishafoundation.archives.transcript.components.studio.event.EventMetadataEditorDialog;
  49. import org.ishafoundation.archives.transcript.model.EventMetadata;
  50. import org.ishafoundation.archives.transcript.components.generic.DebugPopUp;
  51. import org.ishafoundation.archives.transcript.components.studio.concept.ConceptManagerDialog;
  52. import org.ishafoundation.archives.transcript.components.studio.category.CategoryManagerDialog;
  53. import org.ishafoundation.archives.transcript.model.Session;
  54. import mx.events.MenuEvent;
  55. import mx.events.CloseEvent;
  56. import org.ishafoundation.archives.transcript.db.DatabaseManager;
  57. [Bindable]
  58. public var databaseMgr:DatabaseManager;
  59. [Bindable]
  60. private var referenceMgr:ReferenceManager;
  61. [Bindable]
  62. private var sessionMgr:SessionManager;
  63. [Bindable]
  64. private var session:Session;
  65. private static const DEFAULT_TITLE:String = ApplicationUtils.getApplicationName();
  66. [Bindable]
  67. public var title:String = DEFAULT_TITLE;
  68. [Bindable]
  69. public var status:String;
  70. public function init(username:String, databaseMgr:DatabaseManager):void {
  71. IconUtils.overrideIcon(Utils.DEFAULT_ICON_PATH, Utils.DEFAULT_ICON_CLASS);
  72. this.databaseMgr = databaseMgr;
  73. this.referenceMgr = new ReferenceManager(databaseMgr);
  74. this.sessionMgr = new SessionManager(username, referenceMgr, databaseMgr);
  75. this.referenceMgr.loadReferences(referenceXMLRetrieveSuccess, referenceXMLRetrieveFailure);
  76. }
  77. private static const KEYBOARD_SHORTCUT_MODIFIER:String = "ctrlKey";
  78. /** key is charCode, value is actionName */
  79. private static const KEYBOARD_SHORTCUT_MAP:IMap = createKeyboardShortcutMap();
  80. private static function createKeyboardShortcutMap():IMap {
  81. var result:IMap = new HashMap();
  82. result.put("m", "markupText")
  83. return result;
  84. }
  85. protected override function keyDownHandler(evt:KeyboardEvent):void {
  86. if (evt[KEYBOARD_SHORTCUT_MODIFIER]) {
  87. var keyStr:String = String.fromCharCode(evt.charCode);
  88. var actionName:String = KEYBOARD_SHORTCUT_MAP.getValue(keyStr);
  89. if (actionName != null) {
  90. var menuItemElement:XML = menuData..*.(hasOwnProperty("@id") && @id == actionName)[0]
  91. if (menuItemElement.@enabled == "true") {
  92. trace("Keyboard shortcut: " + KEYBOARD_SHORTCUT_MODIFIER + "-" + keyStr);
  93. onMenuClick(menuItemElement);
  94. evt.preventDefault();
  95. return;
  96. }
  97. }
  98. }
  99. super.keyDownHandler(evt);
  100. }
  101. private function referenceXMLRetrieveSuccess():void {
  102. this.status = "References loaded";
  103. }
  104. private static function referenceXMLRetrieveFailure(msg:String):void {
  105. throw new Error(msg);
  106. }
  107. public function openClicked():void {
  108. showUnsavedChangesPopupIfNecessary(showOpenDialog);
  109. }
  110. public function openByIdClicked():void {
  111. showUnsavedChangesPopupIfNecessary(showOpenByIdDialog);
  112. }
  113. private function managerClicked(openManagerFunc:Function):void {
  114. if (this.session != null && this.session.unsavedChanges) {
  115. // confirm this operation with the user
  116. Alert.show("Save session?", "Unsaved changes...", Alert.YES | Alert.NO | Alert.CANCEL, null, function(evt:CloseEvent):void {
  117. if (evt.detail == Alert.YES) {
  118. storeSession(openManagerFunc);
  119. }
  120. else if (evt.detail == Alert.NO) {
  121. // dont save (but dont have to really lose the changes just yet
  122. openManagerFunc();
  123. }
  124. });
  125. }
  126. else {
  127. openManagerFunc();
  128. }
  129. }
  130. private function openCategoryManager():void {
  131. var thisRef:DisplayObject = this;
  132. reloadReferencesBeforeContinuing(function():void {
  133. var categoryManagerDialog:CategoryManagerDialog = new CategoryManagerDialog();
  134. categoryManagerDialog.referenceMgr = referenceMgr;
  135. PopUpManager.addPopUp(categoryManagerDialog, thisRef, true);
  136. categoryManagerDialog.doneButton.addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void {
  137. // finished with the dialog box so reload transcript (because changes may have been made during the dialog
  138. reloadSession();
  139. });
  140. var selectedMarkupProps:MSuperNodeProperties = transcriptPane.markupsPane.selectedMarkupProps;
  141. if (selectedMarkupProps != null) {
  142. categoryManagerDialog.categorySearchPane.initialCategoryId = selectedMarkupProps.markupCategoryId;
  143. }
  144. });
  145. }
  146. private function openConceptManager():void {
  147. var thisRef:DisplayObject = this;
  148. reloadReferencesBeforeContinuing(function():void {
  149. var conceptManagerDialog:ConceptManagerDialog = ConceptManagerDialog.createInstance(referenceMgr);
  150. PopUpManager.addPopUp(conceptManagerDialog, thisRef, true);
  151. conceptManagerDialog.okButton.addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void {
  152. // finished with the dialog box so reload transcript (because changes may have been made during the dialog
  153. reloadSession();
  154. });
  155. });
  156. }
  157. private function queryClicked():void {
  158. var queryExecutorDialog:XQueryExecutorDialog = new XQueryExecutorDialog();
  159. queryExecutorDialog.xQueryExecutor = databaseMgr;
  160. PopUpManager.addPopUp(queryExecutorDialog, this, true);
  161. }
  162. private function showUnsavedChangesPopupIfNecessary(successFunction:Function):void {
  163. UnhandledChangesPopUpManager.displayIfNecessaryUsingAsyncFunc(this.session != null && this.session.unsavedChanges, storeSession, storeSessionFailure, successFunction);
  164. }
  165. private function showOpenDialog():void {
  166. var popup:OpenDialog = OpenDialog.display(this, databaseMgr, referenceMgr);
  167. popup.addEventListener(OpenDialog.OPEN_SESSION_REQUEST, function(evt:Event):void {
  168. var sessionId:String = popup.selectedSessionId;
  169. CursorManager.setBusyCursor();
  170. // first update the reference file - continue even if it fails
  171. reloadReferencesBeforeContinuing(function():void {
  172. sessionMgr.retrieveSession(sessionId, popup.eventSelectorPane.selectedEventMetadata, openSessionSuccess, openSessionFailure);
  173. });
  174. });
  175. }
  176. private function showOpenByIdDialog():void {
  177. var popup:OpenByIdDialog = new OpenByIdDialog();
  178. PopUpManager.addPopUp(popup, this, true);
  179. popup.okButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
  180. trace("Retrieving event/session using id: " + popup.enteredId);
  181. // id is of the form: <event/session id>[#<markup/paragraph id>] (i.e. the last part is optional)
  182. // examples: 20090329-n1-1-1800, 20090329-n1-1-1800#p12
  183. var hashIndex:int = popup.enteredId.indexOf('#');
  184. var docId:String = hashIndex < 0 ? popup.enteredId : popup.enteredId.substring(0, hashIndex);
  185. var nodeId:String = hashIndex < 0 ? null : popup.enteredId.substring(hashIndex + 1);
  186. reloadReferencesBeforeContinuing(function():void {
  187. databaseMgr.retrieveXML(function(docXML:XML):void {
  188. if (docXML == null) {
  189. Alert.show("No document exists with id: " + docId);
  190. }
  191. else if (docXML.localName() == "event") {
  192. var eventMetadata:EventMetadata = EventMetadata.createInstance(docXML);
  193. SessionSelectorDialog.displayIfNecessary(eventMetadata, popup, databaseMgr, function(sessionMetadata:SessionMetadata):void {
  194. sessionMgr.retrieveSession(sessionMetadata.sessionId, eventMetadata, openSessionSuccess, openSessionFailure);
  195. popup.closeMe();
  196. });
  197. }
  198. else if (docXML.localName() == "session") {
  199. // first we need to get the event props
  200. var sessionMetadata:SessionMetadata = SessionMetadata.createInstanceFromSessionXML(docXML);
  201. trace("Opening session based on session XML already in memory");
  202. DatabaseManagerUtils.retrieveEventXML(sessionMetadata.eventId, databaseMgr, function(eventXML:XML):void {
  203. var eventMetadata:EventMetadata = EventMetadata.createInstance(eventXML);
  204. var session:Session = new Session(docXML, eventMetadata, referenceMgr);
  205. openSessionSuccess(session);
  206. popup.closeMe();
  207. // the nodeId might refer to a markup or something
  208. if (nodeId != null && nodeId.length > 0) {
  209. callLater(function():void {
  210. var node:MNode = session.transcript.mdoc.resolveId(nodeId);
  211. if (node == null) {
  212. Alert.show("Could not find document internal id: " + nodeId);
  213. return;
  214. }
  215. if (node is MSuperNode) {
  216. transcriptPane.markupsPane.selectedMarkup = node as MSuperNode;
  217. transcriptPane.textPane.selectMarkup(node as MSuperNode);
  218. }
  219. else {
  220. var newSelection:TranscriptTextSelection = new TranscriptTextSelection(node);
  221. transcriptPane.textPane.select(newSelection);
  222. }
  223. });
  224. }
  225. }, function(msg:String):void {
  226. Alert.show(msg, "Could not open session");
  227. });
  228. }
  229. else {
  230. Alert.show("Unknown xml doc type: " + docXML.localName());
  231. }
  232. }, function(msg:String):void {
  233. Alert.show(msg, "Could not retrieve document using id: " + docId);
  234. }, null, docId, "/db/ts4isha/data");
  235. });
  236. });
  237. }
  238. private function reloadReferencesBeforeContinuing(nextFunc:Function):void {
  239. this.referenceMgr.loadReferences(nextFunc, function(msg:String):void {
  240. Alert.show("Could not reload reference file: " + msg);
  241. });
  242. }
  243. private function openSessionSuccess(session:Session):void {
  244. this.session = session;
  245. this.transcriptPane.transcript = session.transcript;
  246. this.status = "Successfully loaded transcript";
  247. updateTitle();
  248. CursorManager.removeBusyCursor();
  249. }
  250. private function openSessionFailure(msg:String):void {
  251. try {
  252. if (msg.indexOf("document not found") >= 0) {
  253. // exist message includes this phrase
  254. Alert.show("Transcript not found", "Error loading transcript");
  255. }
  256. else {
  257. var index:int = msg.indexOf("PermissionDeniedException:");
  258. if (index >= 0) {
  259. Alert.show(msg.substr(index + 26), "Error loading transcript");
  260. }
  261. else {
  262. throw new Error(msg);
  263. }
  264. }
  265. }
  266. finally {
  267. CursorManager.removeBusyCursor();
  268. }
  269. }
  270. private function storeSession(successFunc:Function = null, failureFunc:Function = null):void {
  271. this.sessionMgr.updateSessionInDatabase(session, function():void {
  272. storeSessionSuccess();
  273. if (successFunc != null) {
  274. successFunc();
  275. }
  276. }, function(msg:String):void {
  277. storeSessionFailure(msg);
  278. if (failureFunc != null) {
  279. failureFunc(msg);
  280. }
  281. });
  282. }
  283. private function storeSessionSuccess():void
  284. {
  285. this.status = "Successfully saved transcript";
  286. this.session.saveChangesHandler();
  287. var selectedMarkup:MSuperNode = this.transcriptPane.markupsPane.selectedMarkup;
  288. // this is primarily to refresh the "committedMarkup" in the propertiesPane
  289. if (selectedMarkup != null) {
  290. this.transcriptPane.markupsPane.selectedMarkup = null;
  291. this.transcriptPane.markupsPane.selectedMarkup = selectedMarkup;
  292. }
  293. Alert.show("Successfully saved transcript changes");
  294. }
  295. private function storeSessionFailure(msg:String):void
  296. {
  297. var index:int = msg.indexOf("PermissionDeniedException:");
  298. if (index >= 0) {
  299. Alert.show(msg.substr(index + 26), "Error saving transcript");
  300. }
  301. else if (StringUtil.trim(msg).length == 0) {
  302. // nothing in the message
  303. databaseMgr.testConnection(function():void {
  304. Alert.show("Unknown reason", "Error saving transcript");
  305. }, function(msg2:String):void {
  306. Alert.show("Could not connect to database", "Error saving transcript");
  307. });
  308. }
  309. else {
  310. Alert.show(msg, "Error saving transcript");
  311. }
  312. }
  313. private function reloadClicked():void {
  314. if (session.unsavedChanges) {
  315. // confirm this operation with the user
  316. Alert.show("Are you sure?", "Discarding changes...", Alert.OK | Alert.CANCEL, null, function(evt:CloseEvent):void {
  317. if (evt.detail==Alert.OK) {
  318. reloadSession();
  319. }
  320. });
  321. }
  322. else {
  323. reloadSession();
  324. }
  325. }
  326. private function reloadSession():void {
  327. if (session == null) {
  328. return;
  329. }
  330. var reloadSessionFunction:Function = function():void {
  331. sessionMgr.retrieveSession(session.id, session.eventMetadata, openSessionSuccess, openSessionFailure);
  332. }
  333. // first update the reference file - continue even if it fails
  334. referenceMgr.loadReferences(reloadSessionFunction, function(msg:String):void {
  335. trace("Couldnt retrieve reference.xml (continuing anyway): " + msg);
  336. reloadSessionFunction();
  337. });
  338. }
  339. private function editEventMetadata():void {
  340. var thisPanel:MainPanel = this;
  341. DatabaseManagerUtils.retrieveEventXML(session.eventMetadata.id, databaseMgr, function(eventXML:XML):void {
  342. session.eventMetadata = EventMetadata.createInstance(eventXML);
  343. var popup:EventMetadataEditorDialog = EventMetadataEditorDialog.display(thisPanel, databaseMgr, referenceMgr, session.eventMetadata);
  344. popup.addEventListener(EventMetadataEditorDialog.EVENT_EDITED, function(event:Event):void {
  345. status = "Successfully edited event";
  346. Alert.show("Successfully edited event");
  347. updateTitle();
  348. });
  349. }, function(msg:String):void {;
  350. Alert.show(msg, "Could not retrieve event XML");
  351. });
  352. }
  353. private function editSessionMetadata():void {
  354. var sessionXMLCopy:XML = session.sessionXML.copy();
  355. var sessionMetadataCopy:SessionMetadata = SessionMetadata.createInstanceFromSessionXML(sessionXMLCopy);
  356. var popup:SessionMetadataEditorDialog = SessionMetadataEditorDialog.display(this, databaseMgr, referenceMgr, sessionMetadataCopy);
  357. popup.addEventListener(FlexEvent.CREATION_COMPLETE, function(evt:FlexEvent):void {
  358. popup.sessionMetadataPane.selectableStartAtRange = session.eventMetadata.dateRange;
  359. });
  360. popup.addEventListener(SessionMetadataEditorDialog.SESSION_PROPS_EDITED, function():void {
  361. // copy the session props over the existing ones
  362. // first delete the old ones
  363. session.metadata.metadataElement = sessionMetadataCopy.metadataElement;
  364. session.unsavedChanges = true;
  365. Alert.show("Session properties edited but not yet saved");
  366. updateTitle();
  367. });
  368. }
  369. private function eventSessionBuilderClicked():void {
  370. if (session != null && session.unsavedChanges) {
  371. // confirm this operation with the user
  372. Alert.show("Are you sure?", "Discarding changes...", Alert.OK | Alert.CANCEL, null, function(evt:CloseEvent):void {
  373. if (evt.detail==Alert.OK) {
  374. importTranscript();
  375. }
  376. });
  377. }
  378. else {
  379. importTranscript();
  380. }
  381. }
  382. private function importTranscript():void {
  383. // always bring up the full import dialog if there is no session loaded or the session already has a transcript
  384. if (session == null || session.transcript != null) {
  385. importTranscriptComplex();
  386. }
  387. else {
  388. var popup:Alert = Alert.show("Import into current session?", null, Alert.YES + Alert.NO + Alert.CANCEL, this, function(evt:CloseEvent):void {
  389. if (evt.detail == Alert.YES) {
  390. importTranscriptSimple();
  391. }
  392. else if (evt.detail == Alert.NO) {
  393. importTranscriptComplex();
  394. }
  395. else {
  396. // do nothing
  397. }
  398. });
  399. }
  400. }
  401. private function importTranscriptComplex():void {
  402. var popup:ImportDialog = ImportDialog.display(this, databaseMgr, referenceMgr);
  403. popup.addEventListener(ImportDialog.IMPORT_CLICKED, function(event:Event):void {
  404. var newSession:Session = sessionMgr.openSessionForEvent(popup.sessionXML, popup.eventMetadata);
  405. openSessionSuccess(newSession);
  406. storeSession();
  407. });
  408. }
  409. /** imports the selected transcript files into the current session */
  410. private function importTranscriptSimple():void {
  411. if (session == null) {
  412. throw new Error("Cannot do a simple import when no session is open");
  413. }
  414. var popup:TranscriptsToImportSelectorDialog = TranscriptsToImportSelectorDialog.display(this, databaseMgr, referenceMgr);
  415. popup.addEventListener(TranscriptsToImportSelectorDialog.FILES_IMPORTED, function(evt:Event):void {
  416. var importedSessionXML:XML = MSWordImporter.createSessionElement(popup.selectedAudioTranscripts);
  417. var importedDeviceElements:XMLList = importedSessionXML..device;
  418. var importedTranscriptElement:XML = importedSessionXML.transcript[0];
  419. session.appendTranscript(importedTranscriptElement, importedDeviceElements);
  420. storeSession();
  421. session.unsavedChanges = true;
  422. openSessionSuccess(session);
  423. });
  424. }
  425. private function showAboutBox():void {
  426. var popup:AboutBox = PopUpManager.createPopUp(this, AboutBox, true) as AboutBox;
  427. popup.user = databaseMgr.user;
  428. }
  429. private function updateTitle():void {
  430. var title:String = "";
  431. if (session == null) {
  432. title += "No session open";
  433. }
  434. else {
  435. if (session.eventMetadata != null) {
  436. title += session.eventMetadata.generateFullName(referenceMgr) + "; ";
  437. }
  438. title += session.metadata.getFullName(session.eventMetadata) + " ";
  439. if (session.transcript == null) {
  440. title += "- NO TRANSCRIPT";
  441. }
  442. }
  443. transcriptPane.label = title;
  444. }
  445. private function onMenuClick(menuItemElement:XML):void {
  446. var actionName:String = menuItemElement.@id;
  447. if ( actionName == "open" ) {
  448. openClicked();
  449. }
  450. else if ( actionName == "openById" ) {
  451. openByIdClicked();
  452. }
  453. else if ( actionName == "store" ) {
  454. storeSession();
  455. }
  456. else if ( actionName == "reloadTranscript" ) {
  457. reloadClicked();
  458. }
  459. else if ( actionName == "eventMetadata" ) {
  460. editEventMetadata();
  461. }
  462. else if ( actionName == "sessionMetadata" ) {
  463. editSessionMetadata();
  464. }
  465. else if ( actionName == "markupText" ) {
  466. this.transcriptPane.markupText();
  467. }
  468. else if ( actionName == "removeMarkup" ) {
  469. this.transcriptPane.removeMarkup();
  470. }
  471. else if ( actionName == "mergeSegmentRange" ) {
  472. this.transcriptPane.mergeSegmentRange();
  473. }
  474. else if ( actionName == "deleteText" ) {
  475. this.transcriptPane.deleteText();
  476. }
  477. else if ( actionName == "nudgeUp" ) {
  478. this.transcriptPane.nudgeUp();
  479. }
  480. else if ( actionName == "nudgeDown" ) {
  481. this.transcriptPane.nudgeDown();
  482. }
  483. else if ( actionName == "showMediaPlayer" ) {
  484. var mediaPlayerDialog:MediaPlayerDialog = MediaPlayerDialog.display(this);
  485. mediaPlayerDialog.mediaMetadataElement = session.sessionXML.mediaMetadata[0];
  486. }
  487. else if ( actionName == "showMarkupPropertiesPane" ) {
  488. var showMarkupProps:Boolean = menuItemElement.@toggled.toString() == "true";
  489. this.transcriptPane.markupsPane.setNodePropertiesPaneVisibility(showMarkupProps);
  490. }
  491. else if ( actionName == "showTextPropertiesPane" ) {
  492. var showTextProps:Boolean = menuItemElement.@toggled.toString() == "true";
  493. this.transcriptPane.textPane.setPropertiesPaneVisibility(showTextProps);
  494. }
  495. else if ( actionName == "eventSessionBuilder" ) {
  496. eventSessionBuilderClicked();
  497. }
  498. else if ( actionName == "categoryManager" ) {
  499. managerClicked(openCategoryManager);
  500. }
  501. else if ( actionName == "conceptManager" ) {
  502. managerClicked(openConceptManager);
  503. }
  504. else if ( actionName == "query" ) {
  505. queryClicked();
  506. }
  507. else if ( actionName == "showHTMLSearchInterface" ) {
  508. navigateToURL(new URLRequest(DatabaseConstants.EXIST_URL + "/rest/db/ts4isha/xquery/main.xql"), "_blank");
  509. }
  510. else if ( actionName.indexOf("debug") == 0) {
  511. var popup:DebugPopUp = new DebugPopUp();
  512. PopUpManager.addPopUp(popup, this, true);
  513. if ( actionName == "debugSession") {
  514. popup.textArea.text = this.session.sessionXML.toXMLString();
  515. }
  516. else if ( actionName == "debugReference") {
  517. popup.textArea.text = referenceMgr.referenceXML.toXMLString();
  518. }
  519. else if ( actionName == "debugTranscriptHTML") {
  520. popup.textArea.text = transcriptPane.textPane.transcriptTextArea.wrappedTextArea.htmlText;
  521. }
  522. }
  523. else if ( actionName == "highlightHTMLElements") {
  524. transcriptPane.textPane.transcriptTextArea.highlightHTMLElements();
  525. }
  526. else if ( actionName == "about") {
  527. showAboutBox();
  528. }
  529. }
  530. ]]>
  531. </mx:Script>
  532. <mx:MenuBar id="myMenuBar" width="100%" labelField="@label" itemClick="onMenuClick(event.item as XML)">
  533. <mx:XMLList id="menuData">
  534. <menuitem label="File" enabled="{referenceMgr != null}">
  535. <menuitem id="open" label="Open..."/>
  536. <menuitem id="openById" label="Open by ID..."/>
  537. <!-- the enabled attribute value is a workaround because the following do not work:
  538. {session != null &amp;&amp; session.unsavedChanges}
  539. {session != null}
  540. {session != null ? true : false}
  541. {true &amp;&amp; session != null}
  542. {this &amp;&amp; session != null}
  543. -->
  544. <menuitem id="store" label="Save" enabled="true"/>
  545. <menuitem id="reloadTranscript" label="Reload from database" enabled="{myMenuBar != null &amp;&amp; session != null}"/>
  546. <menuitem type="separator"/>
  547. <menuitem id="eventMetadata" label="Event properties..." enabled="{myMenuBar != null &amp;&amp; session != null}"/>
  548. <menuitem id="sessionMetadata" label="Session properties..." enabled="{myMenuBar != null &amp;&amp; session != null}"/>
  549. <!--menuitem id="mediaProps" label="Media properties..." enabled="{myMenuBar != null &amp;&amp; session != null}"/-->
  550. </menuitem>
  551. <menuitem label="Selection" enabled="{transcriptPane.textPane.ttSelection != null}">
  552. <menuitem id="markupText" label="Markup text" enabled="{databaseMgr.user.isMarkupUser() &amp;&amp; transcriptPane.textPane.ttSelection.allowMarkup()}"/>
  553. <menuitem id="removeMarkup" label="Remove markup" enabled="{databaseMgr.user.isMarkupUser() &amp;&amp; transcriptPane.textPane.ttSelection.allowRemoveMarkup()}"/>
  554. <menuitem type="separator"/>
  555. <menuitem id="mergeSegmentRange" label="Merge paragraphs" enabled="{databaseMgr.user.isTextUser() &amp;&amp; transcriptPane.textPane.ttSelection.allowMerge()}"/>
  556. <menuitem id="deleteText" label="Delete text" enabled="{databaseMgr.user.isTextUser() &amp;&amp; transcriptPane.textPane.ttSelection.allowDeleteText()}"/>
  557. <menuitem type="separator"/>
  558. <menuitem id="nudgeUp" label="Nudge up" enabled="{databaseMgr.user.isMarkupUser() &amp;&amp; transcriptPane.textPane.ttSelection.allowNudgeUp()}"/>
  559. <menuitem id="nudgeDown" label="Nudge down" enabled="{databaseMgr.user.isMarkupUser() &amp;&amp; transcriptPane.textPane.ttSelection.allowNudgeDown()}"/>
  560. </menuitem>
  561. <menuitem label="Window" enabled="{myMenuBar != null &amp;&amp; session != null}">
  562. <menuitem id="showMediaPlayer" label="Media player"/>
  563. <menuitem type="separator"/>
  564. <menuitem id="showMarkupPropertiesPane" label="Markup properties" type="check" toggled="true"/>
  565. <menuitem id="showTextPropertiesPane" label="Text properties" type="check" toggled="false"/>
  566. </menuitem>
  567. <menuitem label="Admin" enabled="{databaseMgr != null &amp;&amp; databaseMgr.user.isDbaUser()}">
  568. <menuitem id="eventSessionBuilder" label="Event/Session Builder..."/>
  569. <menuitem type="separator"/>
  570. <menuitem id="categoryManager" label="Categories..."/>
  571. <menuitem id="conceptManager" label="Concepts..."/>
  572. <menuitem type="separator"/>
  573. <menuitem id="query" label="Execute XQuery..."/>
  574. </menuitem>
  575. <menuitem label="Tools">
  576. <menuitem id="showHTMLSearchInterface" label="HTML Search Interface"/>
  577. </menuitem>
  578. <menuitem label="Help">
  579. <menuitem label="Debug">
  580. <menuitem id="debugSession" label="Session XML"/>
  581. <menuitem id="debugReference" label="Reference XML"/>
  582. <menuitem id="debugTranscriptHTML" label="Transcript HTML"/>
  583. <!--menuitem id="highlightHTMLElements" label="Highlight HTML Elements"/-->
  584. </menuitem>
  585. <menuitem id="about" label="About {ApplicationUtils.getApplicationName()}"/>
  586. </menuitem>
  587. </mx:XMLList>
  588. </mx:MenuBar>
  589. <mx:TabNavigator borderStyle="none" tabWidth="{transcriptPane.width}" horizontalAlign="center" width="100%" height="100%" paddingTop="0" visible="{this.session != null}">
  590. <studioNS:TranscriptPane id="transcriptPane" width="100%" height="100%" backgroundColor="0x869CA7" referenceMgr="{this.referenceMgr}" visible="{this.session != null}" enabled="{this.transcriptPane.transcript != null}" user="{databaseMgr.user}"/>
  591. </mx:TabNavigator>
  592. </mx:VBox>