Changeset 3918
- Timestamp:
- 10/31/13 09:46:34 (11 years ago)
- Location:
- ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/BrowserOverviewList.mxml
r3907 r3918 16 16 <mx:Script> 17 17 <![CDATA[ 18 import clarin.cmdi.componentregistry.common.Group; 18 19 import clarin.cmdi.componentregistry.common.ItemDescription; 19 20 import clarin.cmdi.componentregistry.common.components.BrowseContextMenu; … … 21 22 import clarin.cmdi.componentregistry.common.components.RssDescriptionsContextMenu; 22 23 import clarin.cmdi.componentregistry.services.Config; 23 import clarin.cmdi.componentregistry.common.StyleConstants; 24 25 import flash.events.ContextMenuEvent; 26 import flash.ui.ContextMenu; 27 import flash.ui.ContextMenuItem; 24 import clarin.cmdi.componentregistry.services.ListUserGroupsMembershipService; 25 26 import mx.collections.ArrayCollection; 28 27 import mx.controls.Alert; 29 30 import mx.collections.ArrayCollection; 31 import mx.controls.Text; 32 import mx.core.UIComponent; 28 import mx.events.CloseEvent; 29 import mx.rpc.events.ResultEvent; 33 30 34 31 private var defaultColor:Object; … … 50 47 [Bindable] 51 48 public var spaceSwitchEnabled:Boolean = false; 49 50 [Bindable] 51 private var groups:ArrayCollection = new ArrayCollection(); 52 53 private static var currentSelectedGroup:String=""; 54 private var previousSelectedIndex:int=0; 52 55 53 56 public function set browserDataProvider(dataProvider:ArrayCollection):void { … … 76 79 private function init():void{ 77 80 Config.instance.addEventListener(Config.USER_SPACE_TOGGLE_EVENT, onSpaceChanged); 81 82 groups.addItem("Move to group..."); 83 Config.instance.getListUserGroupsMembershipService().addEventListener(ListUserGroupsMembershipService.GROUPS_LOADED, onGroupsLoaded); 84 Config.instance.addEventListener(Config.USER_SPACE_TOGGLE_EVENT, updateGroupVisibility); 85 Config.instance.getListUserGroupsMembershipService().loadGroupsForUser(); 86 addEventListener(GroupSelectionEvent.GROUP_SELECTED, onGroupSelected); 87 78 88 scrollToSelected(); 79 89 } … … 82 92 createNewButton.visible = (!Config.instance.selectedGroup); 83 93 createNewButton.includeInLayout = (!Config.instance.selectedGroup); 94 importButton.visible = (!Config.instance.selectedGroup); 95 importButton.includeInLayout = (!Config.instance.selectedGroup); 84 96 } 85 97 … … 132 144 } 133 145 146 147 148 private function onGroupSelected(event:GroupSelectionEvent):void { 149 //Some handler already moved the group for us 150 if (event.groupWasMoved) 151 return; 152 if (!event.getGroupId()){ 153 // we don't want items to be moved from groups into void, thus object this selection event 154 event.stopPropagation(); 155 event.stopImmediatePropagation(); 156 event.preventDefault(); 157 } else{ 158 var groupId:String = event.getGroupId(); 159 var itemId:String = currentSelectedItem.id; 160 Alert.show("Items, once moved to a group, can not be moved back to your workspace. Do you want to move this item?", "Title", mx.controls.Alert.YES | mx.controls.Alert.NO, this, function (nestedCloseEvent:CloseEvent):void { 161 if (nestedCloseEvent.detail == Alert.YES) { 162 Config.instance.getListGroupsOfItemService().transferOwnership(itemId, groupId, itemTransferToGroupComplete); 163 } 164 }); 165 } 166 event.groupWasMoved = true; 167 } 168 169 private function onMoveToGroupButtonClicked(event:Event):void { 170 currentSelectedGroup=groupBox.selectedItem.groupId; 171 var groupEvent:GroupSelectionEvent = new GroupSelectionEvent(groupBox.selectedItem.groupId, groupBox.selectedItem.label); 172 dispatchEvent(groupEvent); 173 // did someone object this selection? 174 if (groupEvent.isDefaultPrevented()){ 175 //e.preventDefault, stopPropagation and stopImmediatePropagation don't undo the selection so we have to do it manually here 176 groupBox.selectedIndex = previousSelectedIndex; 177 } else{ 178 previousSelectedIndex = groupBox.selectedIndex; 179 } 180 } 181 182 public function onGroupsLoaded(event:Event):void{ 183 groups.removeAll(); 184 groups.addItem({label:"Move to group...", space:null, groupId:null}); 185 186 for each (var group:Group in Config.instance.getListUserGroupsMembershipService().groups) { 187 groups.addItem({label:group.name, space:Config.SPACE_USER, groupId:group.id}); 188 } 189 updateGroupVisibility(event); 190 } 191 192 193 private function updateGroupVisibility(event:Event):void{ 194 var showGroups:Boolean = Config.instance.getListUserGroupsMembershipService().groups.length>0 && Config.instance.space != Config.SPACE_PUBLIC; 195 groupPanel.visible = showGroups; 196 groupBox.selectedIndex = 0; 197 } 198 199 protected function itemTransferToGroupComplete(resultEvent:ResultEvent):void { 200 RegistryViewStack.showView(Config.VIEW_BROWSE, currentSelectedItem); 201 } 134 202 ]]> 135 203 </mx:Script> … … 169 237 enabled="{Config.instance.space != Config.SPACE_USER && dataGrid.selectedItem != null}" 170 238 click="editItem()" /> 171 <mx:Button label="Import" 239 <mx:Button id="importButton" 240 label="Import" 172 241 toolTip="Import an item from a local file" 173 242 click="importItem()" /> 243 244 <mx:HBox id="groupPanel" 245 visible="true" 246 enabled="{Config.instance.space == Config.SPACE_USER && dataGrid.selectedItem != null}" 247 > 248 <mx:ComboBox id="groupBox" 249 dataProvider="{groups}" 250 /> 251 <mx:Button id="moveToGroupBtn" 252 label="Move to group" 253 click="onMoveToGroupButtonClicked(event)"/> 254 </mx:HBox> 174 255 175 256 </mx:HBox> -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/infoPage.mxml
r3907 r3918 4 4 xmlns:common="clarin.cmdi.componentregistry.common.*" 5 5 xmlns:browser="clarin.cmdi.componentregistry.browser.*" 6 creationComplete="init()"7 6 > 8 7 9 8 <mx:Metadata> 10 9 [Event(name="groupSelected", type="clarin.cmdi.componentregistry.browser.GroupSelectionEvent")] … … 24 23 dataProvider="{infoViewStack}"/> 25 24 26 <mx:HBox id="groupPanel" visible="true">27 <mx:ComboBox id="groupBox"28 dataProvider="{groups}"29 />30 <mx:Button id="moveToGroupBtn"31 label="Move to group"32 click="onMoveToGroupButtonClicked(event)"/>33 </mx:HBox>34 25 </mx:HBox> 35 26 … … 60 51 <mx:Script> 61 52 <![CDATA[ 62 import clarin.cmdi.componentregistry.common.Group;63 53 import clarin.cmdi.componentregistry.common.ItemDescription; 64 import clarin.cmdi.componentregistry.common.components.RegistryViewStack;65 import clarin.cmdi.componentregistry.services.CommentListService;66 54 import clarin.cmdi.componentregistry.services.Config; 67 import clarin.cmdi.componentregistry.services.ListUserGroupsMembershipService;68 55 69 import mx.collections.ArrayCollection;70 import mx.controls.Alert;71 import mx.events.CloseEvent;72 import mx.events.FlexEvent;73 56 import mx.events.IndexChangedEvent; 74 import mx.messaging.SubscriptionInfo; 75 import mx.rpc.events.ResultEvent; 76 77 private static var currentSelectedGroup:String=""; 78 private var previousSelectedIndex:int=0; 57 79 58 80 59 [Bindable] 81 60 private var _itemDescription:ItemDescription; 82 [Bindable]83 private var groups:ArrayCollection = new ArrayCollection();84 85 public function init():void{86 groups.addItem("Move to group...");87 Config.instance.getListUserGroupsMembershipService().addEventListener(ListUserGroupsMembershipService.GROUPS_LOADED, onGroupsLoaded);88 Config.instance.addEventListener(Config.USER_SPACE_TOGGLE_EVENT, updateGroupVisibility);89 Config.instance.getListUserGroupsMembershipService().loadGroupsForUser();90 addEventListener(GroupSelectionEvent.GROUP_SELECTED, onGroupSelected);91 }92 93 private function onGroupSelected(event:GroupSelectionEvent):void {94 //Some handler already moved the group for us95 if (event.groupWasMoved)96 return;97 if (!event.getGroupId()){98 // we don't want items to be moved from groups into void, thus object this selection event99 event.stopPropagation();100 event.stopImmediatePropagation();101 event.preventDefault();102 } else{103 var groupId:String = event.getGroupId();104 var itemId:String = _itemDescription.id;105 Alert.show("Items, once moved to a group, can not be moved back to your workspace. Do you want to move this item?", "Title", mx.controls.Alert.YES | mx.controls.Alert.NO, this, function (nestedCloseEvent:CloseEvent):void {106 if (nestedCloseEvent.detail == Alert.YES) {107 Config.instance.getListGroupsOfItemService().transferOwnership(itemId, groupId, itemTransferToGroupComplete);108 }109 });110 }111 event.groupWasMoved = true;112 }113 114 private function onMoveToGroupButtonClicked(event:Event):void {115 currentSelectedGroup=groupBox.selectedItem.groupId;116 var groupEvent:GroupSelectionEvent = new GroupSelectionEvent(groupBox.selectedItem.groupId, groupBox.selectedItem.label);117 dispatchEvent(groupEvent);118 // did someone object this selection?119 if (groupEvent.isDefaultPrevented()){120 //e.preventDefault, stopPropagation and stopImmediatePropagation don't undo the selection so we have to do it manually here121 groupBox.selectedIndex = previousSelectedIndex;122 } else{123 previousSelectedIndex = groupBox.selectedIndex;124 }125 }126 127 128 129 public function onGroupsLoaded(event:Event):void{130 groups.removeAll();131 groups.addItem({label:"Move to group...", space:null, groupId:null});132 133 for each (var group:Group in Config.instance.getListUserGroupsMembershipService().groups) {134 groups.addItem({label:group.name, space:Config.SPACE_USER, groupId:group.id});135 }136 updateGroupVisibility(event);137 }138 139 140 private function updateGroupVisibility(event:Event):void{141 var showGroups:Boolean = Config.instance.getListUserGroupsMembershipService().groups.length>0 && Config.instance.space != Config.SPACE_PUBLIC;142 groupPanel.visible = showGroups;143 groupBox.selectedIndex = 0;144 }145 61 146 62 … … 178 94 } 179 95 180 protected function itemTransferToGroupComplete(resultEvent:ResultEvent):void {181 RegistryViewStack.showView(Config.VIEW_BROWSE, _itemDescription);182 }183 184 96 ]]> 185 97 </mx:Script>
Note: See TracChangeset
for help on using the changeset viewer.