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

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

http://transcriptstudio4isha.googlecode.com/
Macromedia eXtensible Markup Language | 82 lines | 75 code | 7 blank | 0 comment | 0 complexity | d802a678d4db132d2c40e2887ce4ea7d MD5 | raw file
 1<?xml version="1.0" encoding="utf-8"?>
 2<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="{0.9 * parentDocument.width}" height="{0.9 * parentDocument.height}" title="Execute XQuery" horizontalAlign="center" creationComplete="init()">
 3	<mx:Script>
 4	<![CDATA[
 5		import mx.managers.PopUpManager;
 6		import mx.controls.TextInput;
 7		import mx.controls.Label;
 8		import mx.containers.GridItem;
 9		import mx.containers.GridRow;
10		import org.ishafoundation.archives.transcript.db.XQueryExecutor;
11		import mx.controls.Alert;
12		import org.ishafoundation.archives.transcript.db.XQueries;
13		
14		public var xQueryExecutor:XQueryExecutor;
15		
16		[Bindable]
17		private var args:Array = new Array(5);
18		
19		private function init():void {
20			//queryTextArea.text = XQueries.ALL_EVENT_IDS;
21			for (var i:int = 0; i < args.length; i++) {
22				var gr:GridRow = new GridRow();
23				gr.percentWidth = 100;
24				gr.percentHeight = 100;
25				var gi1:GridItem = new GridItem();
26				gi1.percentWidth = 100;
27				gi1.percentHeight = 100;
28				var label:Label = new Label();
29				label.text = "arg" + i;
30				gi1.addChild(label);
31				var gi2:GridItem = new GridItem();
32				gi2.percentWidth = 100;
33				gi2.percentHeight = 100;
34				var textInput:TextInput = createArgTextInput(i);
35				gi2.addChild(textInput);
36				gr.addChild(gi1);
37				gr.addChild(gi2);
38				argsGrid.addChild(gr);
39			}
40		}
41		
42		private function createArgTextInput(i:int):TextInput {
43			var textInput:TextInput = new TextInput();
44			textInput.width = 80;
45			textInput.addEventListener(Event.CHANGE, function(evt:Event):void {
46				args[i] = textInput.text;
47			});
48			return textInput
49		}
50		
51		private function labelFunc(queryStr:String):String {
52			var lines:Array = queryStr.split("\n");
53			return lines[0];
54		}
55		
56		private function executeClicked():void {
57			resultTextArea.text = "Executing...";
58			xQueryExecutor.query(queryTextArea.text, args, function(xml:XML):void {
59				resultTextArea.text = xml.toXMLString();
60			}, function(msg:String):void {
61				Alert.show(msg);
62			});
63		}
64
65		private function closeMe():void {
66        	PopUpManager.removePopUp(this);
67		}
68	]]>
69	</mx:Script>
70	<mx:ComboBox id="templateComboBox" width="100%" prompt="Select a template xquery..." labelFunction="labelFunc" dataProvider="{XQueries.ALL_XQUERIES}" change="{queryTextArea.text = templateComboBox.selectedItem as String}"/>
71	<mx:VDividedBox width="100%" height="100%">
72		<mx:VBox width="100%" height="100%" horizontalAlign="center" paddingBottom="5">
73			<mx:HBox width="100%" height="100%">
74				<mx:TextArea id="queryTextArea" height="100%" width="100%"/>
75				<mx:Grid id="argsGrid"/>
76			</mx:HBox>			
77			<mx:Button label="Execute" click="executeClicked()"/>
78		</mx:VBox>
79		<mx:TextArea id="resultTextArea" width="100%" height="100%" editable="false"/>
80	</mx:VDividedBox>
81	<mx:Button label="Done" click="closeMe()"/>
82</mx:TitleWindow>