1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" |
---|
3 | xmlns:comp="clarin.cmdi.componentregistry.common.components.*" |
---|
4 | xmlns:common="clarin.cmdi.componentregistry.common.*" |
---|
5 | xmlns:browser="clarin.cmdi.componentregistry.browser.*"> |
---|
6 | |
---|
7 | <mx:Metadata> |
---|
8 | [Event(name="startItemLoaded",type="flash.events.Event")] |
---|
9 | </mx:Metadata> |
---|
10 | <mx:Array id="browserColumns"/> |
---|
11 | |
---|
12 | <mx:Script> |
---|
13 | import clarin.cmdi.componentregistry.services.CommentInfoService; |
---|
14 | import clarin.cmdi.componentregistry.services.CommentListService; |
---|
15 | import clarin.cmdi.componentregistry.services.Config; |
---|
16 | import clarin.cmdi.componentregistry.common.components.BrowseContextMenu; |
---|
17 | import clarin.cmdi.componentregistry.common.components.RegistryViewStack; |
---|
18 | import clarin.cmdi.componentregistry.services.DeleteService; |
---|
19 | import clarin.cmdi.componentregistry.services.BrowserService; |
---|
20 | |
---|
21 | [Bindable] |
---|
22 | private var commentsMenu:BrowseContextMenu; |
---|
23 | [Bindable] |
---|
24 | private var selectedCommentItem:CommentDescription; |
---|
25 | [Bindable] |
---|
26 | private var commentsSrv:CommentListService = CommentListService.getInstance(Config.instance.userSpace); |
---|
27 | [Bindable] |
---|
28 | private var commentSrv:CommentInfoService = new CommentInfoService(); |
---|
29 | |
---|
30 | public static const START_ITEM_LOADED:String = "startItemLoaded"; |
---|
31 | private var startupItemLoaded:Boolean = false; |
---|
32 | private var deleteSrv:DeleteService = DeleteService.instance; |
---|
33 | private var _itemToScrollToComment:CommentDescription; |
---|
34 | private var startupItemId:String = null; |
---|
35 | |
---|
36 | public function init():void { |
---|
37 | commentsMenu = new BrowseContextMenu(true); |
---|
38 | commentsMenu.viewStack = this.parent as RegistryViewStack; |
---|
39 | commentsMenu.deleteService = deleteSrv; |
---|
40 | deleteSrv.addEventListener(DeleteService.ITEM_DELETED, handleItemDeleted); |
---|
41 | } |
---|
42 | |
---|
43 | public function loadStartup():void { |
---|
44 | startupItemId = Config.instance.startupItem; |
---|
45 | if (startupItemId) { //only load this once on startup |
---|
46 | commentsSrv.addEventListener(BrowserService.ITEMS_LOADED, commentsLoaded); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | private function commentsLoaded(event:Event):void { |
---|
51 | var item:CommentDescription = CommentListService.findDescription(startupItemId); |
---|
52 | loadStartupComment(item); |
---|
53 | commentsSrv.removeEventListener(BrowserService.ITEMS_LOADED, commentsLoaded); |
---|
54 | } |
---|
55 | |
---|
56 | private function loadStartupComment(item:CommentDescription):void { |
---|
57 | if (item) { |
---|
58 | setSelectedCommentDescription(item); |
---|
59 | startupItemId = null; |
---|
60 | dispatchEvent(new Event(START_ITEM_LOADED)); |
---|
61 | } else if (startupItemLoaded) { |
---|
62 | dispatchEvent(new Event(START_ITEM_LOADED)); |
---|
63 | } |
---|
64 | startupItemLoaded = true; |
---|
65 | } |
---|
66 | |
---|
67 | public function setSelectedCommentDescription(desc:CommentDescription):void { |
---|
68 | tabnav.selectedIndex = 0; |
---|
69 | this.selectedCommentItem = desc; |
---|
70 | commentSrv.load(desc); |
---|
71 | } |
---|
72 | |
---|
73 | public function refresh():void { |
---|
74 | commentsSrv.load(); |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | private function handleItemDeleted(event:Event):void { |
---|
79 | refresh(); |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | </mx:Script> |
---|
84 | |
---|
85 | <mx:XML id="cmdComponent"/> |
---|
86 | <mx:XML id="cmdComment"/> |
---|
87 | <mx:XML id="nrOfComments"/> |
---|
88 | <common:ItemDescription id="itemDescription"/> |
---|
89 | <common:CommentDescription id="commentDescription"/> |
---|
90 | |
---|
91 | <mx:String id="headerLabel"/> |
---|
92 | |
---|
93 | <mx:HBox horizontalAlign="center" |
---|
94 | verticalAlign="middle" |
---|
95 | width="100%"> |
---|
96 | <mx:Label id="header" |
---|
97 | text="{headerLabel}" |
---|
98 | fontWeight="bold" |
---|
99 | fontSize="14"/> |
---|
100 | <mx:ToggleButtonBar id="toggleBar" |
---|
101 | dataProvider="{infoViewStack}"/> |
---|
102 | </mx:HBox> |
---|
103 | |
---|
104 | |
---|
105 | <mx:ViewStack id="infoViewStack" |
---|
106 | height="100%" |
---|
107 | width="100%" |
---|
108 | styleName="borderStyles"> |
---|
109 | |
---|
110 | <browser:xmlBrowsePanel id="viewPanel" |
---|
111 | label="view" |
---|
112 | cmdComponent="{cmdComponent}" |
---|
113 | itemDescription="{itemDescription}"/> |
---|
114 | <browser:xmlPanel id="xmlPanel" |
---|
115 | label="xml" |
---|
116 | cmdComponent="{cmdComponent}"/> |
---|
117 | |
---|
118 | <mx:VDividedBox label="Comments({nrOfComments})" |
---|
119 | width="100%"> |
---|
120 | <mx:TabNavigator id="tabnav" |
---|
121 | width="100%" |
---|
122 | height="100%" |
---|
123 | color="0x323232" |
---|
124 | y="59" |
---|
125 | borderStyle="outset"> |
---|
126 | <browser:xmlCommentPanel |
---|
127 | id="viewAllComments" width="399" height="109" |
---|
128 | browseMenu="{commentsMenu}" |
---|
129 | browserColumns="{browserColumns.getCommentColumns()}" |
---|
130 | browserDataProvider="{commentsSrv.itemDescriptions}" |
---|
131 | itemToScrollToComment="{selectedCommentItem}" |
---|
132 | cmdComment="{cmdComment}" |
---|
133 | commentDescription="{commentDescription}" |
---|
134 | /> |
---|
135 | <!-- id="viewComments" width="100%" --> |
---|
136 | </mx:TabNavigator> |
---|
137 | </mx:VDividedBox> |
---|
138 | |
---|
139 | </mx:ViewStack> |
---|
140 | |
---|
141 | </mx:VBox> |
---|