Changeset 2558
- Timestamp:
- 02/08/13 15:20:26 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as
r1896 r2558 15 15 import mx.rpc.http.HTTPService; 16 16 import mx.utils.StringUtil; 17 17 18 18 [Event(name="itemDeleted", type="flash.events.Event")] 19 19 20 20 public class DeleteService extends EventDispatcher { 21 21 public static const ITEM_DELETED:String = "itemDeleted"; 22 22 private var service:HTTPService; 23 23 private static const DELETE_METHOD:Object = {"method": "delete"}; 24 24 25 25 private static var _instance:DeleteService = new DeleteService(); 26 26 27 27 public function DeleteService() { 28 28 if (_instance != null) { … … 34 34 service.method = HTTPRequestMessage.POST_METHOD; 35 35 } 36 36 37 37 public function deleteItem(item:ItemDescription):void { 38 38 CursorManager.setBusyCursor(); 39 var url:URI = new URI(item.dataUrl); 39 40 var deleteUrl:URI = new URI(item.dataUrl); 40 41 if (item.isInUserSpace) { 41 url.setQueryValue(Config.PARAM_USERSPACE, "true");42 deleteUrl.setQueryValue(Config.PARAM_USERSPACE, "true"); 42 43 } 43 sendDelete(url); 44 45 var usageService:ComponentUsageService = new ComponentUsageService(item, item.isInUserSpace); 46 usageService.addEventListener(ComponentUsageCheckEvent.COMPONENT_IN_USE, 47 function (event:ComponentUsageCheckEvent):void{ 48 if(event.isComponentInUse){ 49 onComponentInUse(event); 50 } else { 51 sendDelete(deleteUrl); 52 } 53 }); 54 usageService.checkUsage(); 55 } 56 57 public function onComponentInUse(event:ComponentUsageCheckEvent):void{ 58 var messageBody:String = "The component cannot be deleted because it is used by the following component(s) and/or profile(s):\n\n"; 59 for each(var name:String in event.itemUsingComponent){ 60 messageBody += " - " + name + "\n"; 61 } 62 CursorManager.removeBusyCursor(); 63 Alert.show(messageBody,"Component is used"); 44 64 } 45 65 … … 61 81 service.send(DELETE_METHOD); 62 82 } 63 83 64 84 private function handleResult(resultEvent:ResultEvent):void { 65 85 CursorManager.removeBusyCursor(); … … 70 90 } 71 91 } 72 92 73 93 public function handleError(faultEvent:FaultEvent):void { 74 94 CursorManager.removeBusyCursor(); … … 81 101 } 82 102 } 83 103 84 104 public static function get instance():DeleteService { 85 105 return _instance;
Note: See TracChangeset
for help on using the changeset viewer.