Changeset 224


Ignore:
Timestamp:
03/09/10 17:37:10 (14 years ago)
Author:
patdui
Message:
  • reimplemented my drag and drop editor
  • created search functionality for isocat conceptLinks.
  • added some flexUnit tests and cleanup error handling
Location:
ComponentRegistry/trunk/ComponentBrowserGui
Files:
8 added
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/pom.xml

    r206 r224  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    3    
    4     <modelVersion>4.0.0</modelVersion>
     2<project xmlns="http://maven.apache.org/POM/4.0.0"
     3                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    55
    6     <groupId>clarin.cmdi</groupId>
    7     <artifactId>ComponentBrowserGui</artifactId>
    8     <version>1.1-SNAPSHOT</version>
    9     <packaging>swf</packaging>
    10     <name>ComponentBrowserGui</name>
     6        <modelVersion>4.0.0</modelVersion>
     7
     8        <groupId>clarin.cmdi</groupId>
     9        <artifactId>ComponentBrowserGui</artifactId>
     10        <version>1.1-SNAPSHOT</version>
     11        <packaging>swf</packaging>
     12        <name>ComponentBrowserGui</name>
    1113        <properties>
    12           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    13           <targetPlayer>10.0.0</targetPlayer>
     14                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    1415        </properties>
    1516
    1617        <dependencies>
    17     <dependency>
    18       <groupId>com.adobe.flex.framework</groupId>
    19       <artifactId>flex-framework</artifactId>
    20       <version>3.5.0.12683</version>
    21       <type>pom</type>
    22           <exclusions>
    23                 <exclusion>
    24                   <groupId>com.adobe.flex.framework</groupId>
    25                   <artifactId>playerglobal</artifactId>
    26                 </exclusion>
    27           </exclusions>     
    28     </dependency>       
    29     <dependency>
    30       <groupId>com.adobe.flex.framework</groupId>
    31       <artifactId>playerglobal</artifactId>
    32       <version>3.5.0.12683</version>
    33       <classifier>10</classifier>
    34       <type>swc</type>
    35     </dependency>       
    36     <dependency>
    37       <groupId>org.httpclient</groupId>
    38       <artifactId>as3httpclientlib</artifactId>
    39       <version>1.0.6</version>
    40       <type>swc</type>
    41     </dependency>     
    42     <dependency>
    43       <groupId>com.adobe</groupId>
    44       <artifactId>as3corelib</artifactId>
    45       <version>0.92.1</version>
    46       <type>swc</type>
    47     </dependency>   
    48     <dependency>
    49       <groupId>com.hurlant</groupId>
    50       <artifactId>as3crypto</artifactId>
    51       <version>1.3</version>
    52       <type>swc</type>
    53     </dependency>   
     18                <dependency>
     19                        <groupId>com.adobe.flex.framework</groupId>
     20                        <artifactId>flex-framework</artifactId>
     21                        <version>3.5.0.12683</version>
     22                        <type>pom</type>
     23                        <exclusions>
     24                                <exclusion>
     25                                        <groupId>com.adobe.flex.framework</groupId>
     26                                        <artifactId>playerglobal</artifactId>
     27                                </exclusion>
     28                        </exclusions>
     29                </dependency>
     30                <dependency>
     31                        <groupId>com.adobe.flex.framework</groupId>
     32                        <artifactId>playerglobal</artifactId>
     33                        <version>3.5.0.12683</version>
     34                        <classifier>10</classifier>
     35                        <type>swc</type>
     36                </dependency>
     37                <dependency>
     38                        <groupId>org.httpclient</groupId>
     39                        <artifactId>as3httpclientlib</artifactId>
     40                        <version>1.0.6</version>
     41                        <type>swc</type>
     42                </dependency>
     43                <dependency>
     44                        <groupId>com.adobe</groupId>
     45                        <artifactId>as3corelib</artifactId>
     46                        <version>0.92.1</version>
     47                        <type>swc</type>
     48                </dependency>
     49                <dependency>
     50                        <groupId>com.hurlant</groupId>
     51                        <artifactId>as3crypto</artifactId>
     52                        <version>1.3</version>
     53                        <type>swc</type>
     54                </dependency>
     55                <dependency>
     56                        <groupId>com.adobe.flexunit</groupId>
     57                        <artifactId>flexunit</artifactId>
     58                        <version>0.90</version>
     59                        <type>swc</type>
     60                        <scope>test</scope>
     61                </dependency>
    5462        </dependencies>
    5563
    56     <build>
    57         <sourceDirectory>src/main/flex</sourceDirectory>
    58         <plugins>
    59                   <plugin>
    60                         <groupId>org.sonatype.flexmojos</groupId>
    61                         <artifactId>flexmojos-maven-plugin</artifactId>
    62                         <version>3.5.0</version>
    63                         <extensions>true</extensions>
    64                         <configuration>
    65                           <debug>true</debug>
    66                         </configuration>
    67                 <dependencies>
    68                   <dependency>
    69                 <groupId>com.adobe.flex</groupId>
    70                     <artifactId>compiler</artifactId>
    71                 <version>3.5.0.12683</version>
    72                     <type>pom</type>
    73               </dependency>
    74                 </dependencies>
    75                   </plugin>
    76         </plugins>
    77     </build>
     64        <build>
     65                <sourceDirectory>src/main/flex</sourceDirectory>
     66                <plugins>
     67                        <plugin>
     68                                <groupId>org.sonatype.flexmojos</groupId>
     69                                <artifactId>flexmojos-maven-plugin</artifactId>
     70                                <version>3.5.0</version>
     71                                <extensions>true</extensions>
     72                                <configuration>
     73                                        <debug>true</debug>
     74                                        <generateHtmlWrapper>true</generateHtmlWrapper>
     75                                        <targetPlayer>10.0.0</targetPlayer>
     76                                </configuration>
     77                                <dependencies>
     78                                        <dependency>
     79                                                <groupId>com.adobe.flex</groupId>
     80                                                <artifactId>compiler</artifactId>
     81                                                <version>3.5.0.12683</version>
     82                                                <type>pom</type>
     83                                        </dependency>
     84                                </dependencies>
     85                        </plugin>
     86                </plugins>
     87        </build>
    7888
    7989
    80     <repositories>
    81             <repository>
    82               <id>forge</id>
    83               <url>http://repository.sonatype.org/content/groups/flexgroup</url>
    84               <snapshots> <enabled>true</enabled> </snapshots>
    85               <releases> <enabled>true</enabled> </releases>
    86             </repository>   
    87     </repositories>
    88        
    89     <pluginRepositories>
    90             <pluginRepository>
    91               <id>forge</id>
    92               <url>http://repository.sonatype.org/content/groups/flexgroup</url>
    93               <snapshots> <enabled>true</enabled> </snapshots>
    94               <releases> <enabled>true</enabled> </releases>
    95             </pluginRepository>       
    96     </pluginRepositories>
     90        <repositories>
     91                <repository>
     92                        <id>forge</id>
     93                        <url>http://repository.sonatype.org/content/groups/flexgroup</url>
     94                        <snapshots>
     95                                <enabled>true</enabled>
     96                        </snapshots>
     97                        <releases>
     98                                <enabled>true</enabled>
     99                        </releases>
     100                </repository>
     101        </repositories>
     102
     103        <pluginRepositories>
     104                <pluginRepository>
     105                        <id>forge</id>
     106                        <url>http://repository.sonatype.org/content/groups/flexgroup</url>
     107                        <snapshots>
     108                                <enabled>true</enabled>
     109                        </snapshots>
     110                        <releases>
     111                                <enabled>true</enabled>
     112                        </releases>
     113                </pluginRepository>
     114        </pluginRepositories>
    97115
    98116
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/CMDComponentXMLEditor.as

    r209 r224  
    11package clarin.cmdi.componentregistry.common.components {
    2         import clarin.cmdi.componentregistry.editor.CMDSpecRenderer;
    32        import clarin.cmdi.componentregistry.common.ItemDescription;
    43        import clarin.cmdi.componentregistry.common.StyleConstants;
     4        import clarin.cmdi.componentregistry.editor.CMDSpecRenderer;
    55        import clarin.cmdi.componentregistry.editor.ComponentEdit;
    66        import clarin.cmdi.componentregistry.editor.FormItemInputLine;
     
    1111        import flash.display.DisplayObject;
    1212        import flash.events.Event;
    13         import flash.events.MouseEvent;
    1413        import flash.utils.getTimer;
    1514       
     
    1716        import mx.containers.Form;
    1817        import mx.containers.FormItem;
    19         import mx.controls.Button;
    2018        import mx.core.Container;
    2119        import mx.core.UIComponent;
     
    2523        import mx.managers.IFocusManagerComponent;
    2624
    27     [Event(name="editorChange", type="flash.events.Event")]
     25        [Event(name="editorChange", type="flash.events.Event")]
    2826        public class CMDComponentXMLEditor extends Form implements IFocusManagerComponent, CMDSpecRenderer {
    2927
    30         public static const EDITOR_CHANGE_EVENT:String = "editorChange";
     28                public static const DRAG_NEW_COMPONENT:String = "newComponent";
     29                public static const DRAG_NEW_ELEMENT:String = "newElement";
     30                public static const DRAG_NEW_ATTRIBUTE:String = "newAttribute";
     31
     32                public static const EDITOR_CHANGE_EVENT:String = "editorChange";
    3133                private var _spec:CMDSpec;
    3234
     
    5153                        if (event.dragSource.hasFormat("items")) {
    5254                                DragManager.showFeedback(DragManager.COPY);
     55                        } else if (event.dragSource.hasFormat(DRAG_NEW_COMPONENT)) {
     56                                DragManager.showFeedback(DragManager.COPY);
     57                        } else {
     58                                DragManager.showFeedback(DragManager.NONE);
    5359                        }
    5460                }
    5561
    5662                private function dragDropHandler(event:DragEvent):void {
    57                         var items:Array = event.dragSource.dataForFormat("items") as Array;
    58                         for each (var item:ItemDescription in items) {
    59                                 var comp:CMDComponent = new CMDComponent();
    60                                 comp.componentId = item.id;
    61                                 _spec.cmdComponents.addItem(comp);
    62                                 addComponent(comp);
     63                        if (event.dragSource.hasFormat("items")) {
     64                                var items:Array = event.dragSource.dataForFormat("items") as Array;
     65                                for each (var item:ItemDescription in items) {
     66                                        var comp:CMDComponent = new CMDComponent();
     67                                        comp.componentId = item.id;
     68                                        _spec.cmdComponents.addItem(comp);
     69                                        addComponent(comp);
     70                                }
     71                        } else if (event.dragSource.hasFormat(DRAG_NEW_COMPONENT)) {
     72                                var emptyComp:CMDComponent = event.dragSource.dataForFormat(DRAG_NEW_COMPONENT) as CMDComponent;
     73                                _spec.cmdComponents.addItem(emptyComp);
     74                                addComponent(emptyComp);
    6375                        }
     76
    6477                }
    6578
     
    6982                        dispatchEditorChangeEvent();
    7083                }
    71                
    72                 private function dispatchEditorChangeEvent(event:Event=null):void {
    73                     dispatchEvent(new Event(EDITOR_CHANGE_EVENT));
     84
     85                private function dispatchEditorChangeEvent(event:Event = null):void {
     86                        dispatchEvent(new Event(EDITOR_CHANGE_EVENT));
    7487                }
    7588
     
    8497                        handleHeader(_spec);
    8598                        handleComponents(_spec.cmdComponents);
    86                         trace("Created browser2 view in " + (getTimer() - start) + " ms.");
     99                        trace("Created editor view in " + (getTimer() - start) + " ms.");
    87100                }
    88101
     
    111124                                addComponent(component);
    112125                        }
    113                         var btn:Button = new Button();
    114                         btn.label = "add Component";
    115                         btn.addEventListener(MouseEvent.CLICK, handleAddComponentClick);
    116                         btn.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {drawFocus(true);});
    117                         btn.addEventListener(MouseEvent.MOUSE_OUT, function(event:MouseEvent):void {drawFocus(false);});
    118                         addChild(btn);
    119126                }
    120                
    121                 private function handleAddComponentClick(event:MouseEvent):void {
    122                         var comp:CMDComponent = new CMDComponent();
    123                         _spec.cmdComponents.addItem(comp);
    124                         var index:int = getChildIndex(event.currentTarget as DisplayObject);
    125                         addComponent(comp, index);
    126                 }
    127                
    128127
    129                
    130                 public function addComponent(component:CMDComponent, index:int=-1):void {
     128                public function addComponent(component:CMDComponent, index:int = -1):void {
    131129                        var comp:Container = new ComponentEdit(component, this);
    132130                        comp.addEventListener(ComponentEdit.REMOVE_COMPONENT_EVENT, removeComponent);
    133131                        if (index == -1) {
    134                             addChild(comp);
     132                                addChild(comp);
    135133                        } else {
    136                             addChildAt(comp, index);
     134                                addChildAt(comp, index);
    137135                        }
    138136                }
    139137
    140         private function removeComponent(event:Event):void {
    141             var comp:CMDComponent = ComponentEdit(event.currentTarget).component;
    142             _spec.removeComponent(comp);
    143             removeChild(event.currentTarget as DisplayObject);
    144         }
    145        
     138                private function removeComponent(event:Event):void {
     139                        var comp:CMDComponent = ComponentEdit(event.currentTarget).component;
     140                        _spec.removeComponent(comp);
     141                        removeChild(event.currentTarget as DisplayObject);
     142                }
     143
    146144        }
    147145
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/XMLBrowser.as

    r206 r224  
    113113                                        createAndAddFormChild("Cardinality", element.cardinalityMin + " - " + element.cardinalityMax);
    114114                                handleCMDAttributeList(element.attributeList);
    115                                 createAndAddValueScheme(element.valueSchemeSimple, element.valueSchemeComplex);
     115                                createAndAddValueScheme(element.valueSchemeSimple, element.valueSchemePattern, element.valueSchemeEnumeration);
    116116                                indent = false;
    117117                        }
     
    126126                                                createAndAddFormChild("Type", attribute.type);
    127127                                        } else {
    128                                                 createAndAddValueScheme(attribute.valueSchemeSimple, attribute.valueSchemeComplex);
     128                                                createAndAddValueScheme(null, attribute.valueSchemePattern, attribute.valueSchemeEnumeration);
    129129                                        }
    130130                                }
     
    132132                }
    133133
    134                 protected function createAndAddValueScheme(value:String = null, valueList:XMLListCollection = null):void {
     134                protected function createAndAddValueScheme(value:String = null, valuePattern:String = null, valueList:XMLListCollection = null):void {
    135135                        var formItem:FormItem;
    136                         if (valueList == null) {
     136                        if (value  != null && value != "") {
    137137                                formItem = createFormItem("ValueScheme", value);
     138                        } else if (valuePattern  != null && valuePattern != "") {
     139                            formItem = createFormItem("ValueScheme", valuePattern);
    138140                        } else {
    139141                                formItem = createFormItem("ValueScheme", null);
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/AttributeListEdit.as

    r206 r224  
    11package clarin.cmdi.componentregistry.editor {
    22        import clarin.cmdi.componentregistry.common.StyleConstants;
     3        import clarin.cmdi.componentregistry.common.components.CMDComponentXMLEditor;
    34        import clarin.cmdi.componentregistry.editor.model.CMDAttribute;
    45
    56        import flash.display.DisplayObject;
    67        import flash.events.Event;
    7         import flash.events.IEventDispatcher;
    88        import flash.events.MouseEvent;
    99
     
    1414        import mx.controls.Button;
    1515        import mx.core.UIComponent;
     16        import mx.events.DragEvent;
     17        import mx.managers.DragManager;
    1618
    1719        [Event(name="removeAttribute", type="flash.events.Event")]
     
    2729                        _parent = parent;
    2830                        styleName = StyleConstants.XMLBROWSER;
     31                        addEventListener(DragEvent.DRAG_ENTER, dragEnterHandler);
     32                        addEventListener(DragEvent.DRAG_OVER, dragOverHandler);
     33                        addEventListener(DragEvent.DRAG_DROP, dragDropHandler);
     34
    2935                }
    3036
     
    3642                                        addChild(createAttributeBox(attribute));
    3743                                }
    38                         }
    39                         var btn:Button = new Button();
    40                         btn.label = "add Attribute";
    41                         btn.addEventListener(MouseEvent.CLICK, handleAddAttributeClick);
    42                         btn.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
    43                                         drawFocus(true);
    44                                 });
    45                         btn.addEventListener(MouseEvent.MOUSE_OUT, function(event:MouseEvent):void {
    46                                         drawFocus(false);
    47                                 });
    48                         addChild(btn);
    49                 }
    50 
    51                 private function handleAddAttributeClick(event:MouseEvent):void {
    52                         var attr:CMDAttribute = new CMDAttribute();
    53                         _attributes.addItem(attr);
    54                         var index:int = getChildIndex(event.currentTarget as DisplayObject);
    55                         if (index == -1) {
    56                                 addChild(createAttributeBox(attr));
    57                         } else {
    58                                 addChildAt(createAttributeBox(attr), index);
    5944                        }
    6045                }
     
    7560
    7661                private function createAndAddValueScheme(attribute:CMDAttribute):UIComponent {
    77                         if (attribute.valueSchemeComplex == null) {
    78                                 return new FormItemInputLine("ValueScheme", attribute.valueSchemeSimple, function(val:String):void {
    79                                                 attribute.valueSchemeSimple = val;
     62                        if (attribute.valueSchemeEnumeration == null) {
     63                                return new FormItemInputLine("ValueScheme", attribute.valueSchemePattern, function(val:String):void {
     64                                                attribute.valueSchemePattern = val;
    8065                                        });
    8166                        } else {
    82                                 return new EnumerationEdit(attribute.valueSchemeComplex, this);
     67                                return new EnumerationEdit(attribute.valueSchemeEnumeration, this);
    8368                        }
    8469                }
     
    121106                }
    122107
     108                private function dragEnterHandler(event:DragEvent):void {
     109                        DragManager.acceptDragDrop(event.currentTarget as UIComponent);
     110                        UIComponent(event.currentTarget).drawFocus(true);
     111                }
     112
     113                private function dragOverHandler(event:DragEvent):void {
     114                        if (event.dragSource.hasFormat(CMDComponentXMLEditor.DRAG_NEW_ATTRIBUTE)) {
     115                                DragManager.showFeedback(DragManager.COPY);
     116                        } else {
     117                                DragManager.showFeedback(DragManager.NONE);
     118                        }
     119                }
     120
     121                private function dragDropHandler(event:DragEvent):void {
     122                        if (event.dragSource.hasFormat(CMDComponentXMLEditor.DRAG_NEW_ATTRIBUTE)) {
     123                                var attr:CMDAttribute = event.dragSource.dataForFormat(CMDComponentXMLEditor.DRAG_NEW_ATTRIBUTE) as CMDAttribute;
     124                                _attributes.addItem(attr);
     125                                addChild(createAttributeBox(attr));
     126                        }
     127                }
     128
    123129        }
    124130}
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ComponentEdit.as

    r206 r224  
    22        import clarin.cmdi.componentregistry.common.ItemDescription;
    33        import clarin.cmdi.componentregistry.common.StyleConstants;
     4        import clarin.cmdi.componentregistry.common.components.CMDComponentXMLEditor;
    45        import clarin.cmdi.componentregistry.common.components.ExpandingComponentLabel;
    56        import clarin.cmdi.componentregistry.common.components.XMLBrowser;
    67        import clarin.cmdi.componentregistry.editor.model.CMDComponent;
    78        import clarin.cmdi.componentregistry.editor.model.CMDComponentElement;
    8 
     9       
    910        import flash.display.DisplayObject;
    1011        import flash.events.Event;
    1112        import flash.events.MouseEvent;
    12 
     13       
    1314        import mx.collections.ArrayCollection;
    1415        import mx.containers.Form;
     
    1718        import mx.controls.Button;
    1819        import mx.controls.HRule;
    19         import mx.controls.Spacer;
    2020        import mx.core.Container;
    2121        import mx.core.UIComponent;
     
    2929                private var _parent:UIComponent;
    3030                private var _component:CMDComponent;
     31                private var currentElementIndex:int = -1;
    3132
    3233                public function ComponentEdit(component:CMDComponent, parent:UIComponent) {
     
    3536                        _parent = parent;
    3637                        styleName = StyleConstants.XMLBROWSER;
    37                         addEventListener(DragEvent.DRAG_ENTER, dragEnterHandler);
    38                         addEventListener(DragEvent.DRAG_OVER, dragOverHandler);
    39                         addEventListener(DragEvent.DRAG_DROP, dragDropHandler);
     38                        if (component.componentId == null) { // new empty component, otherwise it would be an already existed component which cannot be edited.
     39                                addEventListener(DragEvent.DRAG_ENTER, dragEnterHandler);
     40                                addEventListener(DragEvent.DRAG_OVER, dragOverHandler);
     41                                addEventListener(DragEvent.DRAG_DROP, dragDropHandler);
     42                        }
    4043                }
    4144
     
    5356                        if (event.dragSource.hasFormat("items")) {
    5457                                DragManager.showFeedback(DragManager.COPY);
     58                        } else if (event.dragSource.hasFormat(CMDComponentXMLEditor.DRAG_NEW_COMPONENT)) {
     59                                DragManager.showFeedback(DragManager.COPY);
     60                        } else if (event.dragSource.hasFormat(CMDComponentXMLEditor.DRAG_NEW_ELEMENT)) {
     61                                DragManager.showFeedback(DragManager.COPY);
     62                        } else {
     63                                DragManager.showFeedback(DragManager.NONE);
    5564                        }
    5665                }
    5766
    5867                private function dragDropHandler(event:DragEvent):void {
    59                         var items:Array = event.dragSource.dataForFormat("items") as Array;
    60                         for each (var item:ItemDescription in items) {
    61                                 var comp:CMDComponent = new CMDComponent();
    62                                 comp.componentId = item.id;
    63                                 _component.cmdComponents.addItem(comp);
    64                                 addComponent(comp);
     68                        if (event.dragSource.hasFormat("items")) {
     69                                var items:Array = event.dragSource.dataForFormat("items") as Array;
     70                                for each (var item:ItemDescription in items) {
     71                                        var comp:CMDComponent = new CMDComponent();
     72                                        comp.componentId = item.id;
     73                                        _component.cmdComponents.addItem(comp);
     74                                        addComponent(comp);
     75                                }
     76                        } else if (event.dragSource.hasFormat(CMDComponentXMLEditor.DRAG_NEW_COMPONENT)) {
     77                                var emptyComp:CMDComponent = event.dragSource.dataForFormat(CMDComponentXMLEditor.DRAG_NEW_COMPONENT) as CMDComponent;
     78                                _component.cmdComponents.addItem(emptyComp);
     79                                addComponent(emptyComp);
     80                        } else if (event.dragSource.hasFormat(CMDComponentXMLEditor.DRAG_NEW_ELEMENT)) {
     81                                var element:CMDComponentElement = event.dragSource.dataForFormat(CMDComponentXMLEditor.DRAG_NEW_ELEMENT) as CMDComponentElement;
     82                                _component.cmdElements.addItem(element);
     83                                addElement(element, currentElementIndex);
    6584                        }
    6685                }
     
    86105                                                _component.name = val;
    87106                                        }));
    88                                 addChild(new FormItemInputLine(XMLBrowser.CONCEPTLINK, _component.conceptLink, function(val:String):void {
     107                                addChild(new ConceptLinkInput(XMLBrowser.CONCEPTLINK, _component.conceptLink, function(val:String):void {
    89108                                                _component.conceptLink = val;
    90109                                        }));
     
    131150
    132151                private function handleCMDAttributeList():void {
    133                     if (_component.attributeList.length > 0)
    134                             addChild(new AttributeListEdit(_component.attributeList, this));
     152                        if (_component.attributeList.length > 0)
     153                                addChild(new AttributeListEdit(_component.attributeList, this));
    135154                }
    136155
     
    139158                                addComponent(component);
    140159                        }
    141                         var btn:Button = new Button();
    142                         btn.label = "add Component";
    143                         btn.addEventListener(MouseEvent.CLICK, handleAddComponentClick);
    144                         btn.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
    145                                         drawFocus(true);
    146                                 });
    147                         btn.addEventListener(MouseEvent.MOUSE_OUT, function(event:MouseEvent):void {
    148                                         drawFocus(false);
    149                                 });
    150                         addChild(btn);
    151                 }
    152 
    153                 private function handleAddComponentClick(event:MouseEvent):void {
    154                         var comp:CMDComponent = new CMDComponent();
    155                         _component.cmdComponents.addItem(comp);
    156                         var index:int = getChildIndex(event.currentTarget as DisplayObject);
    157                         addComponent(comp, index);
    158160                }
    159161
     
    179181                                addElement(element);
    180182                        }
    181                         var btn:Button = new Button();
    182                         btn.label = "add Element";
    183                         btn.addEventListener(MouseEvent.CLICK, handleAddElementClick);
    184                         btn.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
    185                                         drawFocus(true);
    186                                 });
    187                         btn.addEventListener(MouseEvent.MOUSE_OUT, function(event:MouseEvent):void {
    188                                         drawFocus(false);
    189                                 });
    190                         addChild(btn);
    191                 }
    192 
    193                 private function handleAddElementClick(event:MouseEvent):void {
    194                         var element:CMDComponentElement = new CMDComponentElement();
    195                         _component.cmdElements.addItem(element);
    196                         var index:int = getChildIndex(event.currentTarget as DisplayObject);
    197                         addElement(element, index);
    198183                }
    199184
     
    207192                                addChildAt(elem, index);
    208193                        }
     194                        currentElementIndex = getChildIndex(elem) + 1;
    209195                }
    210196
     
    213199                        _component.removeElement(elem);
    214200                        removeChild(event.currentTarget as DisplayObject);
     201                        currentElementIndex--;
    215202                }
    216203
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/Editor.mxml

    r206 r224  
    2323                                           click="saveProfile()"/>
    2424                </mx:HBox>
    25         <mx:Text id="errorMessageField"
    26                                          text="{uploadService.message}" visible='{uploadService.message != ""}' includeInLayout='{uploadService.message != ""}' />
     25                <mx:Text id="errorMessageField"
     26                                 text="{uploadService.message}"
     27                                 visible='{uploadService.message != ""}'
     28                                 includeInLayout='{uploadService.message != ""}'/>
    2729                <mx:ProgressBar id="uploadProgress"
    28                                                         label=""
    29                                                         mode="manual"
    30                                                         visible="false"
    31                                                         includeInLayout="false"/>
     30                                                label=""
     31                                                mode="manual"
     32                                                visible="false"
     33                                                includeInLayout="false"/>
    3234
    3335                <mx:VBox width="100%"
     
    3537                        <comp:CMDComponentXMLEditor id="xmlEditor"
    3638                                                                                cmdSpec="{cmdSpec}"
    37                                                                                 width="50%"
    38                                                                                 toolTip="drag components from list to add..." editorChange="handleEditorChange(event)" />
    39                         <mx:DataGrid id="dataGrid"
    40                                                  width="50%"
    41                                                  dragEnabled="true"
    42                                                  dataProvider="{componentsSrv.itemDescriptions}"
    43                                                  columns="{browserColumns.getComponentColumns()}"
    44                                                  allowMultipleSelection="true"/>
    45 
     39                                                                                editorChange="handleEditorChange(event)"/>
     40                        <mx:VBox styleName="borderStyles">
     41                <mx:Label text="Drag items onto edit canvas"/>
     42                                <mx:HBox id="palette">
     43                                        <mx:Canvas width="60"
     44                                                           height="60"
     45                                                           backgroundColor="blue"
     46                                                           borderStyle="solid"
     47                                                           id="ComponentDrag"
     48                                                           mouseMove="enableComponentDrag(event);"
     49                                                           >
     50                                        </mx:Canvas>
     51                                        <mx:Canvas width="45"
     52                                                           height="45"
     53                                                           backgroundColor="green"
     54                                                           borderStyle="solid"
     55                                                           id="ElementDrag"
     56                                                           mouseMove="enableElementDrag(event);">
     57                                        </mx:Canvas>
     58                                        <mx:Canvas width="30"
     59                                                           height="30"
     60                                                           backgroundColor="red"
     61                                                           borderStyle="solid"
     62                                                           id="AttributeDrag"
     63                                                           mouseMove="enableAttributeDrag(event);">
     64                                        </mx:Canvas>
     65                                </mx:HBox>
     66                                <browser:BrowserOverviewList id="componentsPaletteOverview"
     67                                                                                         browserDataProvider="{componentsSrv.itemDescriptions}"
     68                                                                                         browserColumns="{browserColumns.getComponentColumns()}"
     69                                                                                         creationComplete="initPaletteOverview();"/>
     70                        </mx:VBox>
    4671                </mx:VBox>
    47                 <mx:HBox width="100%"
    48                                  height="300">
    49                         <comp:ScrollableTextArea id="infoTextArea"
    50                                                                          styleName="xmlTextArea"
    51                                                                          editable="false"
    52                                                                          text="{cmdSpec.toXml()}"
    53                                                                          width="50%"
    54                                                                          height="300"/>
    55                 </mx:HBox>
    5672        </mx:VBox>
    5773
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorAS.as

    r206 r224  
    22import clarin.cmdi.componentregistry.browser.BrowserColumns;
    33import clarin.cmdi.componentregistry.common.ItemDescription;
     4import clarin.cmdi.componentregistry.editor.model.CMDAttribute;
     5import clarin.cmdi.componentregistry.editor.model.CMDComponent;
     6import clarin.cmdi.componentregistry.editor.model.CMDComponentElement;
    47import clarin.cmdi.componentregistry.editor.model.CMDModelFactory;
    58import clarin.cmdi.componentregistry.editor.model.CMDSpec;
     
    1316import flash.net.FileReference;
    1417
     18import mx.controls.Alert;
     19import mx.core.DragSource;
     20import mx.core.UIComponent;
     21import mx.managers.DragManager;
     22
    1523
    1624private var currentDescription:ItemDescription;
     
    1927
    2028[Bindable]
    21 private var componentsSrv:ComponentListService = ComponentListService.instance;
     29private var componentsSrv:ComponentListService = new ComponentListService(); //Don't create an instance we need a new one
    2230
    2331[Bindable]
     
    5967
    6068private function saveProfile():void {
    61         //Alert.show(xmlEditor.cmdSpec.toXml());
     69        Alert.show(xmlEditor.cmdSpec.toXml());
    6270        var item:ItemDescription = new ItemDescription();
    6371        item.description = xmlEditor.cmdSpec.headerDescription;
     
    7987
    8088
     89private function enableComponentDrag(event:MouseEvent):void {
     90        var ds:DragSource = new DragSource();
     91        ds.addHandler(function():CMDComponent {
     92                        return new CMDComponent();
     93                }, CMDComponentXMLEditor.DRAG_NEW_COMPONENT);
     94        DragManager.doDrag(UIComponent(event.currentTarget), ds, event);
     95}
    8196
     97private function enableElementDrag(event:MouseEvent):void {
     98        var ds:DragSource = new DragSource();
     99        ds.addHandler(function():CMDComponentElement {
     100                        return new CMDComponentElement();
     101                }, CMDComponentXMLEditor.DRAG_NEW_ELEMENT);
     102        DragManager.doDrag(UIComponent(event.currentTarget), ds, event);
     103}
     104
     105private function enableAttributeDrag(event:MouseEvent):void {
     106        var ds:DragSource = new DragSource();
     107        ds.addHandler(function():CMDAttribute {
     108                        return new CMDAttribute();
     109                }, CMDComponentXMLEditor.DRAG_NEW_ATTRIBUTE);
     110        DragManager.doDrag(UIComponent(event.currentTarget), ds, event);
     111}
     112
     113private function initPaletteOverview():void {
     114        componentsPaletteOverview.dataGrid.dragEnabled = true;
     115        componentsPaletteOverview.dataGrid.allowMultipleSelection = true;
     116        componentsPaletteOverview.dataGrid.horizontalScrollPolicy = "auto";
     117        componentsPaletteOverview.dataGrid.resizableColumns = true;
     118}
     119
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ElementEdit.as

    r206 r224  
    33        import clarin.cmdi.componentregistry.common.components.XMLBrowser;
    44        import clarin.cmdi.componentregistry.editor.model.CMDComponentElement;
    5        
     5
    66        import flash.events.Event;
    77        import flash.events.MouseEvent;
    8        
     8
    99        import mx.containers.Form;
    1010        import mx.containers.FormItem;
     
    2727                }
    2828
    29         public function get element():CMDComponentElement {
    30             return _element;
    31         }
     29                public function get element():CMDComponentElement {
     30                        return _element;
     31                }
    3232
    3333                protected override function createChildren():void {
    3434                        super.createChildren();
    35                        
     35
    3636                        addChild(createEditBar());
    3737                        addChild(new FormItemInputLine("Name", _element.name, function(val:String):void {
    3838                                        _element.name = val;
    3939                                }));
    40                         addChild(new FormItemInputLine(XMLBrowser.CONCEPTLINK, _element.conceptLink, function(val:String):void {
     40                        addChild(new ConceptLinkInput(XMLBrowser.CONCEPTLINK, _element.conceptLink, function(val:String):void {
    4141                                        _element.conceptLink = val;
    4242                                }));
     43
    4344                        addChild(new FormItemInputLine("CardinalityMin", _element.cardinalityMin, function(val:String):void {
    4445                                        _element.cardinalityMin = val;
     
    5253
    5354                private function createEditBar():HBox {
    54                     var editBar:HBox = new HBox();
     55                        var editBar:HBox = new HBox();
    5556                        editBar.addChild(createHeading());
    5657                        var removeButton:Button = new Button();
     
    5859                        removeButton.label = "X";
    5960                        removeButton.addEventListener(MouseEvent.CLICK, fireRemoveComponent);
    60                         removeButton.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {drawFocus(true);});
    61                         removeButton.addEventListener(MouseEvent.MOUSE_OUT, function(event:MouseEvent):void {drawFocus(false);});
     61                        removeButton.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
     62                                        drawFocus(true);
     63                                });
     64                        removeButton.addEventListener(MouseEvent.MOUSE_OUT, function(event:MouseEvent):void {
     65                                        drawFocus(false);
     66                                });
    6267
    6368                        editBar.addChild(removeButton);
     
    7782
    7883                private function createAndAddValueScheme():void {
    79                         if (_element.valueSchemeComplex == null) {
    80                                 addChild(new FormItemInputLine("ValueScheme", _element.valueSchemeSimple, function(val:String):void {
    81                                                 _element.valueSchemeSimple = val;
    82                                         }));
     84                        if (_element.valueSchemeEnumeration == null) {
     85                                if (_element.valueSchemePattern != null) {
     86                                        addChild(new FormItemInputLine("ValueScheme", _element.valueSchemePattern, function(val:String):void {
     87                                                        _element.valueSchemeSimple = val;
     88                                                }));
     89                                } else {
     90                                        addChild(new FormItemInputLine("ValueScheme", _element.valueSchemeSimple, function(val:String):void {
     91                                                        _element.valueSchemeSimple = val;
     92                                                }));
     93                                }
    8394                        } else {
    84                                 addChild(new EnumerationEdit(_element.valueSchemeComplex, this));
     95                                addChild(new EnumerationEdit(_element.valueSchemeEnumeration, this));
    8596                        }
    8697                }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/FormItemInputLine.as

    r206 r224  
    1414                        styleName = StyleConstants.XMLBROWSER_FIELD;
    1515                        editField.styleName = StyleConstants.XMLEDITOR_EDIT_FIELD;
    16                         editField.width = 400;
     16                        editField.width = 300;
    1717                        editField.text = value;
    1818                        BindingUtils.bindSetter(bindingFunction, editField, "text");
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/FormItemInputText.as

    r206 r224  
    1515                        styleName = StyleConstants.XMLBROWSER_FIELD;
    1616                        editArea.styleName = StyleConstants.XMLEDITOR_EDIT_FIELD;
    17                         editArea.width = 400;
     17                        editArea.width = 300;
    1818                        editArea.text = value;
    1919                        BindingUtils.bindSetter(bindingFunction, editArea, "text");
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDAttribute.as

    r206 r224  
    11package clarin.cmdi.componentregistry.editor.model {
    22        import clarin.cmdi.componentregistry.common.XmlAble;
    3        
     3
    44        import mx.collections.XMLListCollection;
    55
    66        public class CMDAttribute implements XmlAble {
    7             //No Attributes
    8            
    9             //Elements
    10             public var name:String;
    11             public var type:String;
    12             public var valueSchemeSimple:String;
    13         public var valueSchemeComplex:XMLListCollection;
    14            
    15            
     7                //No Attributes
     8
     9                //Elements
     10                public var name:String;
     11                public var type:String;
     12                public var valueSchemePattern:String; //pattern
     13                public var valueSchemeEnumeration:XMLListCollection; // enumeration
     14
     15                //TODO Patrick see element?? check usage in xmlBrowser
     16
     17
    1618                public function CMDAttribute() {
    1719                }
    1820
    1921                public function toXml():XML {
    20                         return <Attribute></Attribute>; //TODO PD implement
     22                        var result:XML = <Attribute></Attribute>;
     23                        result.appendChild(<Name>{name}</Name>);
     24                        if (valueSchemePattern) {
     25                                result.appendChild(<pattern>{valueSchemePattern}</pattern>);
     26                        } else if (valueSchemeEnumeration) {
     27                                result.appendChild(<enumeration>{valueSchemeEnumeration}</enumeration>);
     28                        } else {
     29                                result.appendChild(<Type>{type}</Type>);
     30                        }
     31
     32                        return result
    2133                }
    2234        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponent.as

    r206 r224  
    4040                public function toXml():XML {
    4141                        var result:XML = <CMD_Component></CMD_Component>;
    42                         if (isNotEmpty(name))
     42                        if (name)
    4343                                result.@name = name;
    44                         if (isNotEmpty(componentId))
     44                        if (componentId)
    4545                                result.@ComponentId = componentId;
    46                         if (isNotEmpty(conceptLink))
     46                        if (conceptLink)
    4747                                result.@ConceptLink = conceptLink;
    48                         if (isNotEmpty(filename))
     48                        if (filename)
    4949                                result.@filename = filename;
    50                         if (isNotEmpty(cardinalityMin))
     50                        if (cardinalityMin)
    5151                                result.@CardinalityMin = cardinalityMin;
    52                         if (isNotEmpty(cardinalityMax))
     52                        if (cardinalityMax)
    5353                                result.@CardinalityMax = cardinalityMax;
    5454                        if (attributeList.length > 0) {
     
    6868                }
    6969
    70                 private function isNotEmpty(value:String):Boolean {
    71                         return value != null && value != "";
    72                 }
    73 
    7470        }
    7571}
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponentElement.as

    r206 r224  
    1717                //elements
    1818                public var attributeList:ArrayCollection = new ArrayCollection();
    19                 public var valueSchemeComplex:XMLListCollection;
     19                public var valueSchemeEnumeration:XMLListCollection;
     20                public var valueSchemePattern:String;
    2021
    2122                public function CMDComponentElement() {
     
    2526
    2627                public function toXml():XML {
    27                         return <CMD_Element></CMD_Element>;//TODO PD implement
     28                        var result:XML = <CMD_Element></CMD_Element>; //TODO PD implement
     29                        if (name)
     30                                result.@name = name;
     31                        if (conceptLink)
     32                                result.@ConceptLink = conceptLink;
     33                        if (valueSchemeSimple)
     34                                result.@ValueScheme = valueSchemeSimple;
     35                        if (cardinalityMin)
     36                                result.@CardinalityMin = cardinalityMin;
     37                        if (cardinalityMax)
     38                                result.@CardinalityMax = cardinalityMax;
     39                        if (attributeList.length > 0) {
     40                                var attributeListTag:XML = <AttributeList></AttributeList>;
     41                                for each (var attribute:CMDAttribute in attributeList) {
     42                                        attributeListTag.appendChild(attribute.toXml());
     43                                }
     44                                result.appendChild(attributeListTag);
     45                        }
     46                        if (valueSchemePattern) {
     47                                result.appendChild(<ValueScheme><pattern></pattern>{valueSchemePattern}</ValueScheme>)
     48                        }
     49                        if (valueSchemeEnumeration != null) {
     50                                var enumerationScheme:XML = <ValueScheme><enumeration></enumeration></ValueScheme>;
     51                                enumerationScheme.appendChild(valueSchemeEnumeration);
     52                                result.appendChild(enumerationScheme);
     53                        }
     54                        return result;
    2855                }
     56
    2957
    3058        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDModelFactory.as

    r206 r224  
    5454                        if (xml.hasOwnProperty(ComponentMD.VALUE_SCHEME)) {
    5555                                if (xml.ValueScheme.hasOwnProperty(ComponentMD.PATTERN)) {
    56                                         result.valueSchemeSimple = xml.ValueScheme.pattern;
     56                                        result.valueSchemePattern = xml.ValueScheme.pattern;
    5757                                } else if (xml.ValueScheme.hasOwnProperty(ComponentMD.ENUMERATION)) {
    58                                         result.valueSchemeComplex = new XMLListCollection(xml.ValueScheme.enumeration.*);
     58                                        result.valueSchemeEnumeration = new XMLListCollection(xml.ValueScheme.enumeration.*);
    5959                                }
    6060                        }
     
    8181                        } else {
    8282                                if (xml.ValueScheme.hasOwnProperty(ComponentMD.PATTERN)) {
    83                                         result.valueSchemeSimple = xml.ValueScheme.pattern;
     83                                        result.valueSchemePattern = xml.ValueScheme.pattern;
    8484                                } else if (xml.ValueScheme.hasOwnProperty(ComponentMD.ENUMERATION)) {
    85                                         result.valueSchemeComplex = new XMLListCollection(xml.ValueScheme.enumeration.*);
     85                                        result.valueSchemeEnumeration = new XMLListCollection(xml.ValueScheme.enumeration.*);
    8686                                }
    8787                        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/BrowserService.as

    r161 r224  
    33       
    44        import mx.collections.ArrayCollection;
     5        import mx.controls.Alert;
    56        import mx.messaging.messages.HTTPRequestMessage;
    67        import mx.rpc.AsyncToken;
     
    910        import mx.rpc.events.ResultEvent;
    1011        import mx.rpc.http.HTTPService;
    11         import mx.utils.ObjectUtil;
    1212        import mx.utils.StringUtil;
    1313
     
    4747                public function fault(faultEvent:FaultEvent):void {
    4848                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1} - {2}", this, faultEvent.fault.faultString, faultEvent.fault.faultDetail);
    49                         throw new Error(errorMessage);
     49                        Alert.show(errorMessage);
    5050                }
    5151
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ComponentInfoService.as

    r134 r224  
    55        import clarin.cmdi.componentregistry.common.ItemDescription;
    66       
     7        import mx.controls.Alert;
    78        import mx.messaging.messages.HTTPRequestMessage;
    89        import mx.rpc.AsyncToken;
     
    1314        import mx.utils.StringUtil;
    1415
    15 [Event(name="ComponentLoaded", type="flash.events.Event")]
     16        [Event(name="ComponentLoaded", type="flash.events.Event")]
    1617        public class ComponentInfoService {
    17             public static const COMPONENT_LOADED:String = "ComponentLoaded";
     18                public static const COMPONENT_LOADED:String = "ComponentLoaded";
    1819
    1920                private var service:HTTPService;
     
    4849                public function fault(faultEvent:FaultEvent):void {
    4950                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1} - {2}", this, faultEvent.fault.faultString, faultEvent.fault.faultDetail);
    50                         throw new Error(errorMessage);
     51                        Alert.show(errorMessage);
    5152                }
    5253        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ComponentListService.as

    r161 r224  
    1212                public function ComponentListService() {
    1313                        super(Config.instance.componentListUrl);
    14                         if (_instance != null) {
    15                                 throw new Error("Service can only be accessed through ComponentListService.instance");
    16                         }
    1714                }
    1815
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/Config.as

    r92 r224  
    1212                private static var _instance:Config = new Config();
    1313
    14                 private var _serviceRootUrl:String = "http://localhost:8080/ComponentRegistry"; 
     14                private var _serviceRootUrl:String = "http://localhost:8080/ComponentRegistry";
    1515                //Default _serviceRootUrl value can be useful for testing. Set the proper value in your (index.)html that embeds the flash object.
    16                 //Like this: "FlashVars", "serviceRootUrl=http://localhost:8080/ComponentRegistry"
     16                //Like this: "FlashVars", "serviceRootUrl=http://localhost:8080/ComponentRegistry"
     17
     18                private var _isocatSearchUrl:String = "http://www.isocat.org/rest/user/guest/search";
     19                //Default _isocatSearchUrl value can be useful for testing. Set the proper value in your (index.)html that embeds the flash object.
     20                //Like this: "FlashVars", "isocatSearchUrl=http://www.isocat.org/rest/user/guest/search"
    1721
    1822
     
    2428                        if (serviceRootUrl != null) {
    2529                                _serviceRootUrl = serviceRootUrl;
     30                        }
     31                        var isocatSearchUrl:String = Application.application.parameters.isocatSearchUrl;
     32                        if (isocatSearchUrl != null) {
     33                                _isocatSearchUrl = isocatSearchUrl;
    2634                        }
    2735                }
     
    5159                }
    5260
     61                public function get isocatSearchUrl():String {
     62                        return _isocatSearchUrl;
     63                }
     64
    5365                public static function get instance():Config {
    5466                        return _instance;
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/DeleteService.as

    r206 r224  
    11package clarin.cmdi.componentregistry.services {
    22        import clarin.cmdi.componentregistry.common.ItemDescription;
    3 
     3       
    44        import com.adobe.net.URI;
    55        import com.hurlant.util.Base64;
    6 
     6       
     7        import flash.events.ErrorEvent;
    78        import flash.events.Event;
    89        import flash.events.EventDispatcher;
    9 
     10       
    1011        import mx.controls.Alert;
     12        import mx.managers.CursorManager;
    1113        import mx.utils.StringUtil;
    12 
     14       
    1315        import org.httpclient.HttpClient;
    14         import org.httpclient.events.HttpErrorEvent;
    1516        import org.httpclient.events.HttpResponseEvent;
    16         import org.httpclient.events.HttpStatusEvent;
    1717        import org.httpclient.http.Delete;
    1818
     
    2727                        service.listener.onComplete = handleResult;
    2828                        service.listener.onError = handleError;
    29                         service.listener.onStatus = handleStatus;
    3029                }
    3130
     
    3534
    3635                public function deleteItem(item:ItemDescription):void {
     36                        CursorManager.setBusyCursor();
    3737                        var uri:URI = new URI(item.dataUrl);
    3838                        var httpDelete:Delete = new Delete();
     
    4242
    4343                private function handleResult(resultEvent:HttpResponseEvent):void {
    44                         if (resultEvent.response.code == "200") {
     44                        CursorManager.removeBusyCursor();
     45                        if (resultEvent.response.isSuccess) {
    4546                                dispatchEvent(new Event(ITEM_DELETED));
     47                        } else if (resultEvent.response.isClientError) {
     48                                Alert.show("Unauthorized to delete item, you are not the creator.");
     49                        } else if (resultEvent.response.isServerError) {
     50                                Alert.show("Unexpected error, server returned status: " + resultEvent.response.code);
    4651                        }
    4752                }
    4853
    49                 public function handleError(faultEvent:HttpErrorEvent):void {
     54                public function handleError(faultEvent:ErrorEvent):void {
     55                        CursorManager.removeBusyCursor();
    5056                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1}", this, faultEvent.text);
    51                         throw new Error(errorMessage);
     57                    Alert.show(errorMessage);
    5258                }
    5359
    54                 private function handleStatus(event:HttpStatusEvent):void {
    55                         if (event.code != "200") {
    56                                 if (event.code == "401") {
    57                                         Alert.show("Unauthorized to delete item, you are not the creator.");
    58                                 }
    59                                 trace("(httpstatus code was: " + event.code + ")");
    60                         }
    61                 }
    6260        }
    6361}
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/ProfileInfoService.as

    r206 r224  
    88       
    99        import mx.collections.ArrayCollection;
     10        import mx.controls.Alert;
    1011        import mx.messaging.messages.HTTPRequestMessage;
    1112        import mx.rpc.AsyncToken;
     
    5960                public function fault(faultEvent:FaultEvent):void {
    6061                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1} - {2}", this, faultEvent.fault.faultString, faultEvent.fault.faultDetail);
    61                         throw new Error(errorMessage);
     62                    Alert.show(errorMessage);
    6263                }
    6364        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/UploadService.as

    r206 r224  
    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;
     9        import flash.events.ErrorEvent;
    910        import flash.events.Event;
    10         import flash.events.HTTPStatusEvent;
    1111        import flash.events.IOErrorEvent;
    1212        import flash.events.ProgressEvent;
     
    1616        import flash.net.URLRequest;
    1717        import flash.net.URLVariables;
    18 
     18       
    1919        import mx.controls.ProgressBar;
    20 
     20       
    2121        import org.httpclient.HttpClient;
    2222        import org.httpclient.events.HttpDataEvent;
    23         import org.httpclient.events.HttpErrorEvent;
    24         import org.httpclient.events.HttpStatusEvent;
     23        import org.httpclient.events.HttpResponseEvent;
    2524        import org.httpclient.http.Post;
    2625        import org.httpclient.http.multipart.Multipart;
     
    5150                        httpClient = new HttpClient();
    5251                        httpClient.listener.onError = httpclientErrorHandler;
    53                         httpClient.listener.onData = httpclientDataHandler;
    54                         httpClient.listener.onStatus = httpclientStatusHandler;
     52                        httpClient.listener.onData = httpclientDataHandler; 
     53                        httpClient.listener.onComplete = httpclientCompleteHandler;
    5554                }
    5655
     
    136135                }
    137136
    138                 private function httpclientStatusHandler(event:HttpStatusEvent):void {
    139                         if (event.code != "200") {
    140                                 addToMessage("Server Failed to handle registration. Unexpected error, try again later. (httpstatus code was: " + event.code + ")\n");
     137                private function httpclientCompleteHandler(event:HttpResponseEvent):void {
     138                        if (!event.response.isSuccess) {
     139                                addToMessage("Server Failed to handle registration. Unexpected error, try again later. (httpstatus code was: " + event.response.code + ")\n");
    141140                        }
    142141                }
     
    148147                }
    149148
    150                 private function httpclientErrorHandler(event:HttpErrorEvent):void {
     149                private function httpclientErrorHandler(event:ErrorEvent):void {
    151150                        addToMessage("Server Failed to handle registration. Unexpected error, try again later. (error: " + event.text + ")\n");
    152151                }
Note: See TracChangeset for help on using the changeset viewer.