Changeset 242


Ignore:
Timestamp:
03/17/10 16:19:20 (14 years ago)
Author:
patdui
Message:
  • added editing of components.
  • fixed bug in sharing of contextmenus in browser.
Location:
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/TestRunner.mxml

    r224 r242  
    77        <mx:Script>
    88                <![CDATA[
     9                    import clarin.cmdi.componentregistry.editor.model.CMDSpecTest;
    910                        import clarin.cmdi.componentregistry.editor.model.CMDAttributeTest;
    1011                        import clarin.cmdi.componentregistry.editor.model.CMDComponentElementTest;
     
    2223                                var testSuite:TestSuite = new TestSuite();
    2324
     25                                testSuite.addTestSuite(CMDSpecTest);
    2426                                testSuite.addTestSuite(CMDComponentTest);
    2527                                testSuite.addTestSuite(CMDComponentElementTest);
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/Browse.mxml

    r206 r242  
    2424                        private var deleteSrv:DeleteService = new DeleteService();
    2525                        [Bindable]
    26                         private var browseMenu:BrowseContextMenu
     26                        private var profilesMenu:BrowseContextMenu
     27                        [Bindable]
     28                        private var componentsMenu:BrowseContextMenu
    2729
    2830                        public function init():void {
    29                             browseMenu = new BrowseContextMenu();
    30                                 browseMenu.viewStack = this.parent as RegistryViewStack;
    31                                 browseMenu.deleteService = deleteSrv;
     31                            profilesMenu = new BrowseContextMenu();
     32                                profilesMenu.viewStack = this.parent as RegistryViewStack;
     33                                profilesMenu.deleteService = deleteSrv;
     34                            componentsMenu = new BrowseContextMenu();
     35                                componentsMenu.viewStack = this.parent as RegistryViewStack;
     36                                componentsMenu.deleteService = deleteSrv;
    3237                                deleteSrv.addEventListener(DeleteService.ITEM_DELETED, handleItemDeleted);
    3338                        }
     
    5257                                        tabnav.selectedIndex = 1;
    5358                                }
     59//                              var indeprofilesOverview.browserDataProvider.getItemIndex(desc);
    5460                                //Need to select the correct item, can't get it to highlight at the mo
    5561                                //profilesOverview.dataGrid.selectedIndex=2;
     
    8995                                                                                         width="100%"
    9096                                                                                         height="70%"
    91                                                                                          browseMenu="{browseMenu}"/>
     97                                                                                         browseMenu="{profilesMenu}"/>
    9298                                <browser:ProfileInfoPage id="profileInfoPage"
    9399                                                                                 profile="{profileSrv.profile}"
     
    104110                                                                                         width="100%"
    105111                                                                                         height="50%"
    106                                                                                          browseMenu="{browseMenu}"/>
     112                                                                                         browseMenu="{componentsMenu}"/>
    107113                                <browser:ComponentInfoPage id="componentInfoPage"
    108114                                                                                   component="{componentSrv.component}"
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/XMLBrowser.as

    r238 r242  
    7272                        addFormHeading("Header");
    7373                        createAndAddFormChild("Name", spec.headerName);
     74                        createAndAddFormChild(DESCRIPTION, spec.headerDescription);
    7475                        createAndAddFormChild("Id", spec.headerId);
    75                         createAndAddFormChild(DESCRIPTION, spec.headerDescription);
    7676                }
    7777
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/CMDComponentXMLEditor.as

    r238 r242  
    55        import clarin.cmdi.componentregistry.editor.model.CMDComponent;
    66        import clarin.cmdi.componentregistry.editor.model.CMDSpec;
    7        
     7
    88        import flash.display.DisplayObject;
    99        import flash.events.Event;
    1010        import flash.utils.getTimer;
    11        
     11
     12        import mx.binding.utils.BindingUtils;
    1213        import mx.collections.ArrayCollection;
    1314        import mx.containers.Form;
     
    7172                                addComponent(emptyComp);
    7273                        }
    73 
    7474                }
    7575
    7676                public function set cmdSpec(cmdSpec:CMDSpec):void {
    7777                        _spec = cmdSpec;
    78                         createNewBrowser();
     78                        createNewEditor();
    7979                        dispatchEditorChangeEvent();
    8080                }
     
    8989                }
    9090
    91                 private function createNewBrowser():void {
     91                private function createNewEditor():void {
    9292                        var start:int = getTimer();
    9393                        removeAllChildren()
     
    9898
    9999                private function handleHeader(spec:CMDSpec):void {
     100                        addChild(new SelectTypeRadioButtons(spec));
     101                        addChild(createOptionalGroupNameInput(spec));
    100102                        addChild(createHeading());
    101103                        addChild(new FormItemInputLine("Name", spec.headerName, function(val:String):void {
    102104                                        spec.headerName = val;
    103105                                }));
    104                         var idInput:FormItemInputLine = new FormItemInputLine("Id", spec.headerId, function(val:String):void {
    105                                         spec.headerId = val;
    106                                 }, false);
    107                         idInput.toolTip="Id will be generated";
    108                         addChild(idInput);
    109106                        addChild(new FormItemInputText(XMLBrowser.DESCRIPTION, spec.headerDescription, function(val:String):void {
    110107                                        spec.headerDescription = val;
    111108                                }));
     109                        var idInput:FormItemInputLine = new FormItemInputLine("Id", spec.headerId, function(val:String):void {
     110                                        spec.headerId = val;
     111                                }, false);
     112                        idInput.toolTip = "Id will be generated";
     113                        addChild(idInput);
     114                }
     115
     116                private function createOptionalGroupNameInput(spec:CMDSpec):FormItem {
     117                        var result:FormItem = new FormItemInputLine("Group Name", spec.groupName, function(val:String):void {
     118                                        spec.groupName = val;
     119                                })
     120                        BindingUtils.bindSetter(function(val:Boolean):void {
     121                                        result.visible = !val;
     122                                }, spec, "isProfile");
     123                        return result;
    112124                }
    113125
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/Editor.mxml

    r238 r242  
    1616                <mx:HBox width="100%"
    1717                                 height="40">
    18                         <mx:Button id="createEmptyProfileBtn"
    19                                            label="createEmptyProfile"
    20                                            click="createEmptyProfile()"/>
     18                        <mx:Button id="clearBtn"
     19                                           label="clear"
     20                                           click="clearEditor()"/>
    2121                        <mx:Button id="saveBtn"
    2222                                           label="save"
    23                                            click="saveProfile()"/>
     23                                           click="saveSpec()"/>
    2424                </mx:HBox>
    2525                <mx:Text id="errorMessageField"
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorAS.as

    r224 r242  
    6060}
    6161
    62 public function createEmptyProfile():void {
     62public function clearEditor():void {
    6363        this.cmdSpec = new CMDSpec(true);
    6464}
     
    6666private var ref:FileReference = new FileReference();
    6767
    68 private function saveProfile():void {
    69         Alert.show(xmlEditor.cmdSpec.toXml());
     68private function saveSpec():void {
     69//      Alert.show(xmlEditor.cmdSpec.toXml());
    7070        var item:ItemDescription = new ItemDescription();
    7171        item.description = xmlEditor.cmdSpec.headerDescription;
    7272        item.name = xmlEditor.cmdSpec.headerName;
    7373        item.isProfile = xmlEditor.cmdSpec.isProfile;
     74        item.groupName = xmlEditor.cmdSpec.groupName;
    7475        uploadService.addEventListener(UploadCompleteEvent.UPLOAD_COMPLETE, handleSaveComplete);
    75         uploadService.submitProfile(item, xmlEditor.cmdSpec.toXml());
     76        if (item.isProfile) {
     77            uploadService.submitProfile(item, xmlEditor.cmdSpec.toXml());
     78        } else {
     79            uploadService.submitComponent(item, xmlEditor.cmdSpec.toXml());
     80        }
    7681}
    7782
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDSpec.as

    r206 r242  
    1414                public var headerDescription:String;
    1515                public var cmdComponents:ArrayCollection = new ArrayCollection();
     16               
     17                public var groupName:String; //Not in xml but stored in the description
    1618
    1719                public function CMDSpec(isProfile:Boolean) {
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/UploadService.as

    r238 r242  
    22        import clarin.cmdi.componentregistry.common.ItemDescription;
    33        import clarin.cmdi.componentregistry.importer.UploadCompleteEvent;
    4        
     4
    55        import com.adobe.net.URI;
    66        import com.hurlant.util.Base64;
    7        
     7
    88        import flash.events.DataEvent;
    99        import flash.events.ErrorEvent;
     
    1414        import flash.net.FileFilter;
    1515        import flash.net.FileReference;
    16         import flash.net.URLRequest;
    1716        import flash.net.URLVariables;
    18        
     17
    1918        import mx.controls.ProgressBar;
    20        
     19
    2120        import org.httpclient.HttpClient;
    2221        import org.httpclient.events.HttpDataEvent;
     
    3938                private var fileRef:FileReference;
    4039                private var httpClient:HttpClient;
    41                 private var request:URLRequest;
    4240                private var pb:ProgressBar;
    4341
     
    4644                }
    4745
    48                 private function createAndInitRequest(url:String):void {
    49                         request = new URLRequest(url);
     46                private function createAndInitRequest():void {
    5047                        httpClient = new HttpClient();
    5148                        httpClient.listener.onError = httpclientErrorHandler;
    52                         httpClient.listener.onData = httpclientDataHandler; 
     49                        httpClient.listener.onData = httpclientDataHandler;
    5350                        httpClient.listener.onComplete = httpclientCompleteHandler;
    5451                }
     
    6764                 */
    6865                public function submitProfile(description:ItemDescription, data:String = null):void {
    69                         createAndInitRequest(Config.instance.uploadProfileUrl);
    70                         var params:URLVariables = new URLVariables();
    71                         submit(description, params, data);
     66                        createAndInitRequest();
     67                        submit(description, data, new URI(Config.instance.uploadProfileUrl));
    7268                }
    7369
     
    7672                 */
    7773                public function submitComponent(description:ItemDescription, data:String = null):void {
    78                         createAndInitRequest(Config.instance.uploadComponentUrl);
    79                         var params:URLVariables = new URLVariables();
    80                         params.group = description.groupName;
    81                         submit(description, params, data);
     74                        createAndInitRequest();
     75                        submit(description, data, new URI(Config.instance.uploadComponentUrl));
    8276                }
    8377
     
    8680                }
    8781
    88                 private function submit(description:ItemDescription, params:URLVariables, data:String = null):void {
     82                private function submit(description:ItemDescription, data:String, uri:URI):void {
    8983                        message = "";
    9084                        try {
     
    9387                                        parts.push(new Part("description", description.description));
    9488                                        parts.push(new Part("name", description.name));
     89                                        parts.push(new Part("group", description.groupName));
    9590                                        parts.push(new Part("data", data, "application/octet-stream", [{name: "filename", value: description.name + ".xml"}]));
    9691
    9792                                        var multipart:Multipart = new Multipart(parts);
    98                                         var uri:URI = new URI(Config.instance.uploadProfileUrl);
    9993                                        startUploadHandler();
    10094                                        var post:Post = new Post();
     
    108102                                                //only load if not loaded before otherwise sent the already loaded file. You can only force a reload of the file by selecting it again (it is a flash thingy).
    109103                                                fileRef.addEventListener(Event.COMPLETE, function(event:Event):void {
    110                                                                 submit(description, params, new String(fileRef.data));
     104                                                                submit(description, new String(fileRef.data), uri);
    111105                                                        });
    112106                                                fileRef.load();
    113107                                        } else {
    114                                                 submit(description, params, new String(fileRef.data));
     108                                                submit(description, new String(fileRef.data), uri);
    115109                                        }
    116110                                }
     
    121115                }
    122116
    123 
    124117                public function selectXmlFile(event:Event):void {
    125118                        createAndInitFileReference();
     
    138131                                addToMessage("Server Failed to handle registration. Unexpected error, try again later. (httpstatus code was: " + event.response.code + ")\n");
    139132                        }
    140             httpClient.close();
     133                        httpClient.close();
    141134                }
    142135
Note: See TracChangeset for help on using the changeset viewer.