Changeset 1473


Ignore:
Timestamp:
07/27/11 09:45:44 (13 years ago)
Author:
twagoo
Message:

GUI: implemented ComponentUsageService?, which calls the component/usage/ (see @1462-@1465) service to check whether the specified component is in use.
It is called when updating private components. Currently, the service response is not being processed so the event will always tell the component is in use.

Location:
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/Editor.mxml

    r1086 r1473  
    4343                        <mx:VBox styleName="borderStyles"
    4444                                         width="100%">
    45                                 <mx:Label text="Drag existing components onto edit canvas"/>
     45                                <mx:Label text="Drag TESTTEST existing components onto edit canvas"/>
    4646                                <browser:BrowserOverviewList id="componentsPaletteOverview"
    4747                                                                                         width="100%"
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorAS.as

    r1086 r1473  
    99import clarin.cmdi.componentregistry.services.ComponentInfoService;
    1010import clarin.cmdi.componentregistry.services.ComponentListService;
     11import clarin.cmdi.componentregistry.services.ComponentUsageCheckEvent;
     12import clarin.cmdi.componentregistry.services.ComponentUsageService;
    1113import clarin.cmdi.componentregistry.services.Config;
    1214import clarin.cmdi.componentregistry.services.ProfileInfoService;
     
    8890
    8991private function saveSpec(inUserSpace:Boolean, uploadAction:int):void {
    90 //      Alert.show(xmlEditor.cmdSpec.toXml());
     92        //      Alert.show(xmlEditor.cmdSpec.toXml());
    9193        if (xmlEditor.validate()) {
    9294                var item:ItemDescription = new ItemDescription();
     
    100102                        item.id = xmlEditor.cmdSpec.headerId;
    101103                }
    102                 uploadService.upload(uploadAction, item, xmlEditor.cmdSpec.toXml());
     104               
     105                // Private components that are in updated require usage check call. If in use, the user can choose whether or not to save the changes .
     106                if(inUserSpace && uploadAction == UploadService.UPDATE && !item.isProfile){
     107                        checkUsage(item);
     108                }else{
     109                        doUpload(uploadAction,item);
     110                }
    103111        } else {
    104112                errorMessageField.text = "Validation errors: red colored fields are invalid.";
    105113        }
     114}
     115
     116/**
     117 * Calls usage check for the specified component. If in use, asks user whether to proceed; if positive, initiates update.
     118 */
     119private function checkUsage(item:ItemDescription, uploadAction:int = UploadService.UPDATE):void{
     120        var componentUsageService:ComponentUsageService = new ComponentUsageService(item);
     121        componentUsageService.addEventListener(ComponentUsageCheckEvent.COMPONENT_IN_USE,
     122                function (event:ComponentUsageCheckEvent):void{
     123                        if(event.isComponentInUse){
     124                                Alert.show("Component is used by other components and/or profiles. Changes in this component will affect these. Do you want to proceed?","Component is used", Alert.YES|Alert.NO,null,
     125                                        function (eventObj:CloseEvent):void{
     126                                                if(eventObj.detail == Alert.YES){
     127                                                        doUpload(uploadAction, item);
     128                                                }
     129                                        });
     130                        } else {
     131                                doUpload(uploadAction,item);
     132                        }
     133                });
     134        componentUsageService.checkUsage();
     135}
     136
     137private function doUpload(uploadAction:int, item:ItemDescription):void{
     138        uploadService.upload(uploadAction, item, xmlEditor.cmdSpec.toXml());
    106139}
    107140
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/Config.as

    r1232 r1473  
    2828                private static const COMPONENT_LIST_URL:String = "/rest/registry/components";
    2929                private static const PROFILE_LIST_URL:String = "/rest/registry/profiles";
     30                private static const COMPONENT_USAGE_URL:String = "/rest/registry/components/usage/";
    3031                private static const UPLOAD_PROFILE_SERVICE_URL:String = "/rest/registry/profiles";
    3132                private static const UPLOAD_COMPONENT_SERVICE_URL:String = "/rest/registry/components";
     
    8788                public function get componentListUrl():String {
    8889                        return _serviceRootUrl + COMPONENT_LIST_URL;
     90                }
     91               
     92                public function get componentUsageUrl():String {
     93                        return _serviceRootUrl + COMPONENT_USAGE_URL;
    8994                }
    9095
Note: See TracChangeset for help on using the changeset viewer.