1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | |
---|
3 | <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" |
---|
4 | xmlns:comp="clarin.cmdi.componentregistry.common.components.*" |
---|
5 | xmlns:rictus="com.rictus.controls.*"> |
---|
6 | |
---|
7 | <mx:Metadata> |
---|
8 | [Event(name="browserItemSelected",type="clarin.cmdi.componentregistry.browser.BrowserSelectionEvent")] |
---|
9 | </mx:Metadata> |
---|
10 | |
---|
11 | |
---|
12 | <mx:ArrayCollection id="browserDataProvider" /> |
---|
13 | <mx:Array id="browserColumns"/> |
---|
14 | |
---|
15 | |
---|
16 | <mx:Script> |
---|
17 | <![CDATA[ |
---|
18 | import clarin.cmdi.componentregistry.common.components.BrowseContextMenu; |
---|
19 | import mx.collections.ArrayCollection; |
---|
20 | import mx.events.CollectionEvent; |
---|
21 | import clarin.cmdi.componentregistry.browser.BrowserSelectionEvent; |
---|
22 | import clarin.cmdi.componentregistry.common.ItemDescription; |
---|
23 | |
---|
24 | private var currentSelectedItem:ItemDescription; |
---|
25 | [Bindable] |
---|
26 | private var menu:BrowseContextMenu; |
---|
27 | |
---|
28 | private function dispatchBrowserSelectionEvent():void { |
---|
29 | if (this.dataGrid.selectedItem != null) { |
---|
30 | var item:ItemDescription = this.dataGrid.selectedItem as ItemDescription |
---|
31 | if (currentSelectedItem == null || currentSelectedItem.id != item.id) { //Only update when the item selected is different. |
---|
32 | currentSelectedItem = item; |
---|
33 | var event:BrowserSelectionEvent = new BrowserSelectionEvent(item); |
---|
34 | dispatchEvent(event); |
---|
35 | } |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | public function set browseMenu(browseMenu:BrowseContextMenu):void { |
---|
40 | this.menu = browseMenu; |
---|
41 | menu.dataGrid= dataGrid; |
---|
42 | } |
---|
43 | |
---|
44 | private function handleKeyUp(event:KeyboardEvent):void { |
---|
45 | if (event.keyCode == Keyboard.DELETE) { |
---|
46 | menu.deleteSelectedItems(); |
---|
47 | } |
---|
48 | } |
---|
49 | ]]> |
---|
50 | </mx:Script> |
---|
51 | |
---|
52 | <mx:HBox horizontalAlign="center" |
---|
53 | verticalAlign="middle" |
---|
54 | width="100%"> |
---|
55 | <rictus:SearchBox id="searchBox" label="filter..."/> |
---|
56 | <mx:Label text="Showing {browserDataProvider.length} of {dataGrid.unfilteredLength}"/> |
---|
57 | </mx:HBox> |
---|
58 | |
---|
59 | <comp:FilteringDataGrid id="dataGrid" |
---|
60 | x="0" |
---|
61 | y="112" |
---|
62 | width="100%" |
---|
63 | height="100%" |
---|
64 | click="dispatchBrowserSelectionEvent()" |
---|
65 | dataProvider="{browserDataProvider}" |
---|
66 | columns="{browserColumns}" |
---|
67 | contextMenu="{menu.cm}" |
---|
68 | allowMultipleSelection="true" |
---|
69 | searchInput="{searchBox}" |
---|
70 | keyUp="handleKeyUp(event)"> |
---|
71 | </comp:FilteringDataGrid> |
---|
72 | </mx:VBox> |
---|