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 | private function openCCR():void { |
---|
58 | var urlRequest:URLRequest = new URLRequest("http://www.clarin.eu/ccr/"); |
---|
59 | navigateToURL(urlRequest, "_blank"); |
---|
60 | } |
---|
61 | ]]> |
---|
62 | </mx:Script> |
---|
63 | |
---|
64 | <mx:VBox> |
---|
65 | <mx:HBox> |
---|
66 | <rictus:SearchBox id="searchBox" |
---|
67 | label="type keyword and press 'enter' to search" |
---|
68 | keyDown="handleSearch(event);" |
---|
69 | minWidth="300"/> |
---|
70 | <mx:Button id="searchButton" |
---|
71 | label="Search" |
---|
72 | click="handleSearch(event);" /> |
---|
73 | <mx:Label text="{dataGrid.dataProvider.length} results"/> |
---|
74 | |
---|
75 | <mx:Spacer width="100%"/> |
---|
76 | |
---|
77 | <mx:Label textAlign="right" textDecoration="underline" click="openCCR()" > |
---|
78 | <mx:htmlText><![CDATA[Searching in the <a href="http://www.clarin.eu/ccr/">CLARIN Concept Registry</a>]]></mx:htmlText> |
---|
79 | </mx:Label> |
---|
80 | </mx:HBox> |
---|
81 | <mx:DataGrid id="dataGrid" |
---|
82 | dataProvider="{searchService.searchResults}" |
---|
83 | initialize="initializeDataGrid()" |
---|
84 | itemClick="setItem()" |
---|
85 | resizableColumns="true" |
---|
86 | itemRenderer="mx.controls.Label" |
---|
87 | showDataTips="true"> |
---|
88 | <mx:columns> |
---|
89 | <mx:DataGridColumn dataField="@name" |
---|
90 | dataTipField="@name" |
---|
91 | headerText="Name"/> |
---|
92 | <mx:DataGridColumn dataField="@definition" |
---|
93 | dataTipField="@definition" |
---|
94 | headerText="Definition"/> |
---|
95 | <mx:DataGridColumn dataField="@identifier" |
---|
96 | dataTipField="@identifier" |
---|
97 | headerText="Identifier"/> |
---|
98 | <mx:DataGridColumn dataField="@owner" |
---|
99 | dataTipField="@owner" |
---|
100 | headerText="Owner"/> |
---|
101 | <mx:DataGridColumn dataField="@pid" |
---|
102 | dataTipField="@pid" |
---|
103 | headerText="Persistent Identifier" |
---|
104 | width="130" |
---|
105 | itemRenderer="clarin.cmdi.componentregistry.common.components.LinkRenderer"/> |
---|
106 | <mx:DataGridColumn dataField="@type" |
---|
107 | dataTipField="@type" |
---|
108 | headerText="Type"/> |
---|
109 | <mx:DataGridColumn dataField="@version" |
---|
110 | dataTipField="@version" |
---|
111 | headerText="Version"/> |
---|
112 | </mx:columns> |
---|
113 | </mx:DataGrid> |
---|
114 | <mx:HBox width="100%"> |
---|
115 | <mx:Spacer width="100%"/> |
---|
116 | <mx:Button id="okBtn" |
---|
117 | label="OK" |
---|
118 | click="handleOkClick()" |
---|
119 | enabled="{dataGrid.selectedItem != null}" |
---|
120 | /> |
---|
121 | <mx:Button label="Cancel" |
---|
122 | click="cleanUp()"/> |
---|
123 | </mx:HBox> |
---|
124 | </mx:VBox> |
---|
125 | </mx:TitleWindow> |
---|