1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" |
---|
3 | xmlns:common="clarin.cmdi.componentregistry.common.*" |
---|
4 | xmlns:browser="clarin.cmdi.componentregistry.browser.*" |
---|
5 | |
---|
6 | xmlns:comp="clarin.cmdi.componentregistry.common.components.*" |
---|
7 | xmlns:rictus="com.rictus.controls.*" |
---|
8 | creationComplete="scrollToCommentSelected()"> |
---|
9 | <mx:Metadata> |
---|
10 | [Event(name="browserCommentSelected",type="clarin.cmdi.componentregistry.browser.BrowserSelectionEvent")] |
---|
11 | </mx:Metadata> |
---|
12 | |
---|
13 | <mx:Array id="browserColumns"/> |
---|
14 | |
---|
15 | <mx:Script> |
---|
16 | <![CDATA[ |
---|
17 | import clarin.cmdi.componentregistry.editor.model.CMDModelFactory; |
---|
18 | |
---|
19 | import clarin.cmdi.componentregistry.common.Credentials; |
---|
20 | import clarin.cmdi.componentregistry.common.Login; |
---|
21 | import mx.collections.ArrayList; |
---|
22 | import com.adobe.utils.ArrayUtil; |
---|
23 | import clarin.cmdi.componentregistry.common.StyleConstants; |
---|
24 | import clarin.cmdi.componentregistry.services.Config; |
---|
25 | import clarin.cmdi.componentregistry.common.components.BrowseContextMenu; |
---|
26 | import mx.collections.ArrayCollection; |
---|
27 | import mx.events.CollectionEvent; |
---|
28 | import clarin.cmdi.componentregistry.browser.BrowserSelectionEvent; |
---|
29 | import clarin.cmdi.componentregistry.common.CommentDescription; |
---|
30 | |
---|
31 | private var defaultColor:Object; |
---|
32 | private var currentSelectedComment:CommentDescription; |
---|
33 | [Bindable] |
---|
34 | private var menu:BrowseContextMenu; |
---|
35 | |
---|
36 | private var _itemToScrollToComment:CommentDescription; |
---|
37 | |
---|
38 | public function set browserDataProvider(dataProvider:ArrayCollection):void { |
---|
39 | if (dataProvider) { |
---|
40 | var data:ArrayCollection = new ArrayCollection(dataProvider.toArray().slice()); |
---|
41 | this.dataGrid.dataProvider = data |
---|
42 | dataGrid.doFiltering(); |
---|
43 | scrollToCommentSelected(); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | private function dispatchBrowserSelectionEvent():void { |
---|
49 | if (this.dataGrid.selectedItem != null) { |
---|
50 | var item:CommentDescription = dataGrid.selectedItem as CommentDescription |
---|
51 | if (currentSelectedComment == null || currentSelectedComment.id != item.id) { //Only update when the item selected is different. |
---|
52 | currentSelectedComment = item; |
---|
53 | /* var event:BrowserSelectionEvent = new BrowserSelectionEvent(item); |
---|
54 | dispatchEvent(event); */ |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | public function set itemToScrollToComment(itemToScrollTo:CommentDescription):void { |
---|
60 | _itemToScrollToComment = itemToScrollTo; |
---|
61 | scrollToCommentSelected(); |
---|
62 | } |
---|
63 | |
---|
64 | private function scrollToCommentSelected():void { |
---|
65 | if (_itemToScrollToComment && dataGrid.dataProvider) { |
---|
66 | for (var i:int; i < dataGrid.dataProvider.length; i++) { |
---|
67 | var item:CommentDescription = dataGrid.dataProvider.getItemAt(i) as CommentDescription; |
---|
68 | if (item.id == _itemToScrollToComment.id) { |
---|
69 | dataGrid.selectedItem = item; |
---|
70 | dispatchBrowserSelectionEvent(); |
---|
71 | dataGrid.setFocus(); |
---|
72 | dataGrid.scrollToIndex(i); |
---|
73 | break; |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | public function set browseMenu(browseMenu:BrowseContextMenu):void { |
---|
80 | this.menu = browseMenu; |
---|
81 | menu.dataGrid = dataGrid; |
---|
82 | } |
---|
83 | |
---|
84 | private function handleKeyUp(event:KeyboardEvent):void { |
---|
85 | if (event.keyCode == Keyboard.DELETE) { |
---|
86 | menu.deleteSelectedItems(); |
---|
87 | } |
---|
88 | } |
---|
89 | ]]> |
---|
90 | </mx:Script> |
---|
91 | |
---|
92 | <mx:HBox horizontalAlign="center" |
---|
93 | verticalAlign="middle" |
---|
94 | width="100%"> |
---|
95 | |
---|
96 | |
---|
97 | <rictus:SearchBox id="searchBox" |
---|
98 | label="filter..."/> |
---|
99 | <mx:Label text="Showing {dataGrid.dataProvider.length} of {dataGrid.unfilteredLength}"/> |
---|
100 | </mx:HBox> |
---|
101 | |
---|
102 | <comp:FilteringDataGrid id="dataGrid" |
---|
103 | x="0" |
---|
104 | y="112" |
---|
105 | width="100%" |
---|
106 | height="100%" |
---|
107 | click="dispatchBrowserSelectionEvent()" |
---|
108 | columns="{browserColumns}" |
---|
109 | contextMenu="{menu.cm}" |
---|
110 | allowMultipleSelection="true" |
---|
111 | searchInput="{searchBox}" |
---|
112 | keyUp="handleKeyUp(event)" |
---|
113 | useRollOver="false" |
---|
114 | showDataTips="true"> |
---|
115 | </comp:FilteringDataGrid> |
---|
116 | |
---|
117 | <mx:XML id="cmdComment"/> |
---|
118 | <common:CommentDescription id="commentDescription"/> |
---|
119 | <browser:CMDComponentXMLBrowser id="commentBrowse" |
---|
120 | cmdSpec = "{CMDModelFactory.createCommentModel(cmdComment, commentDescription)}" |
---|
121 | width="100%" |
---|
122 | height="100%"/> |
---|
123 | </mx:VBox> |
---|