1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" |
---|
3 | xmlns:rictus="com.rictus.controls.*" |
---|
4 | showCloseButton="true" |
---|
5 | creationComplete="PopUpManager.centerPopUp(this)" |
---|
6 | close="cleanUp();" |
---|
7 | title="Search in CLARIN Concept Registry"> |
---|
8 | |
---|
9 | <mx:Metadata> |
---|
10 | [Event(name="OK", type="flash.events.Event")] |
---|
11 | </mx:Metadata> |
---|
12 | <mx:Script> |
---|
13 | <![CDATA[ |
---|
14 | import clarin.cmdi.componentregistry.services.IsocatService; |
---|
15 | |
---|
16 | import mx.controls.TextInput; |
---|
17 | import mx.managers.PopUpManager; |
---|
18 | |
---|
19 | public static const OK_EVENT:String = "OK"; |
---|
20 | |
---|
21 | [Bindable] |
---|
22 | public var searchService:IsocatService = null; |
---|
23 | |
---|
24 | public var isocatSearchType:String = null; |
---|
25 | |
---|
26 | //To store the result |
---|
27 | public var editField:TextInput; |
---|
28 | |
---|
29 | private function handleOkClick():void { |
---|
30 | dispatchEvent(new Event(OK_EVENT)); |
---|
31 | cleanUp(); |
---|
32 | } |
---|
33 | |
---|
34 | private function cleanUp():void { |
---|
35 | searchService.close(); |
---|
36 | PopUpManager.removePopUp(this); |
---|
37 | } |
---|
38 | |
---|
39 | private function initializeDataGrid():void { |
---|
40 | editField = new TextInput(); |
---|
41 | } |
---|
42 | |
---|
43 | private function setItem():void { |
---|
44 | var selectedItem:XML = dataGrid.selectedItem as XML; |
---|
45 | if (selectedItem) { |
---|
46 | editField.text = selectedItem.@pid; |
---|
47 | editField.toolTip = selectedItem.@name + ": " + selectedItem.@definition; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | private function handleSearch(event:Event):void { |
---|
52 | if(event is MouseEvent || (event is KeyboardEvent && KeyboardEvent(event).keyCode == Keyboard.ENTER)){ |
---|
53 | searchService.load(searchBox.text, isocatSearchType); |
---|
54 | } |
---|
55 | } |
---|
56 | ]]> |
---|
57 | </mx:Script> |
---|
58 | |
---|
59 | <mx:VBox> |
---|
60 | <mx:HBox> |
---|
61 | <rictus:SearchBox id="searchBox" |
---|
62 | label="type keyword and press 'enter' to search" |
---|
63 | keyDown="handleSearch(event);" |
---|
64 | minWidth="300"/> |
---|
65 | <mx:Button id="searchButton" |
---|
66 | label="Search" |
---|
67 | click="handleSearch(event);" /> |
---|
68 | <mx:Label text="{dataGrid.dataProvider.length} results"/> |
---|
69 | </mx:HBox> |
---|
70 | <mx:DataGrid id="dataGrid" |
---|
71 | dataProvider="{searchService.searchResults}" |
---|
72 | initialize="initializeDataGrid()" |
---|
73 | itemClick="setItem()" |
---|
74 | resizableColumns="true" |
---|
75 | itemRenderer="mx.controls.Label" |
---|
76 | showDataTips="true"> |
---|
77 | <mx:columns> |
---|
78 | <mx:DataGridColumn dataField="@name" |
---|
79 | dataTipField="@name" |
---|
80 | headerText="Name"/> |
---|
81 | <mx:DataGridColumn dataField="@definition" |
---|
82 | dataTipField="@definition" |
---|
83 | headerText="Definition"/> |
---|
84 | <mx:DataGridColumn dataField="@identifier" |
---|
85 | dataTipField="@identifier" |
---|
86 | headerText="Identifier"/> |
---|
87 | <mx:DataGridColumn dataField="@owner" |
---|
88 | dataTipField="@owner" |
---|
89 | headerText="Owner"/> |
---|
90 | <mx:DataGridColumn dataField="@pid" |
---|
91 | dataTipField="@pid" |
---|
92 | headerText="Persistent Identifier" |
---|
93 | width="130" |
---|
94 | itemRenderer="clarin.cmdi.componentregistry.common.components.LinkRenderer"/> |
---|
95 | <mx:DataGridColumn dataField="@type" |
---|
96 | dataTipField="@type" |
---|
97 | headerText="Type"/> |
---|
98 | <mx:DataGridColumn dataField="@version" |
---|
99 | dataTipField="@version" |
---|
100 | headerText="Version"/> |
---|
101 | </mx:columns> |
---|
102 | </mx:DataGrid> |
---|
103 | <mx:HBox width="100%"> |
---|
104 | <mx:Spacer width="100%"/> |
---|
105 | <mx:Button id="okBtn" |
---|
106 | label="OK" |
---|
107 | click="handleOkClick()" |
---|
108 | enabled="{dataGrid.selectedItem != null}" |
---|
109 | /> |
---|
110 | <mx:Button label="Cancel" |
---|
111 | click="cleanUp()"/> |
---|
112 | </mx:HBox> |
---|
113 | </mx:VBox> |
---|
114 | </mx:TitleWindow> |
---|