Changeset 264


Ignore:
Timestamp:
03/22/10 09:40:42 (14 years ago)
Author:
patdui
Message:
Location:
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/browser/XMLBrowser.as

    r242 r264  
    123123                                for each (var attribute:CMDAttribute in attributes) {
    124124                                        createAndAddFormChild("Name", attribute.name);
    125                                         if (attribute.type != null) {
    126                                                 createAndAddFormChild("Type", attribute.type);
     125                                        if (!attribute.valueSchemeSimple) {
     126                                                createAndAddFormChild("Type", attribute.valueSchemeSimple);
    127127                                        } else {
    128128                                                createAndAddValueScheme(null, attribute.valueSchemePattern, attribute.valueSchemeEnumeration);
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/AttributeListEdit.as

    r238 r264  
    22        import clarin.cmdi.componentregistry.common.StyleConstants;
    33        import clarin.cmdi.componentregistry.editor.model.CMDAttribute;
    4 
     4        import clarin.cmdi.componentregistry.editor.model.ValueSchemeInterface;
     5       
    56        import flash.events.Event;
    67        import flash.events.MouseEvent;
    7 
     8       
    89        import mx.binding.utils.BindingUtils;
    910        import mx.collections.ArrayCollection;
     
    5354                }
    5455
    55                 private function createAndAddValueScheme(attribute:CMDAttribute):UIComponent {
     56        /**
     57        * Public utility method to create ValueScheme Component. By lack of better placed put in this class
     58        **/
     59                public static function createAndAddValueScheme(valueScheme:ValueSchemeInterface):UIComponent {
    5660                        var valueSchemeInput:ValueSchemeInput = new ValueSchemeInput("Type");
     61                        if (valueScheme.valueSchemeEnumeration == null) {
     62                                if (valueScheme.valueSchemePattern) {
     63                                        valueSchemeInput.valueSchemePattern = valueScheme.valueSchemePattern;
     64                                } else {
     65                                        valueSchemeInput.valueSchemeSimple = valueScheme.valueSchemeSimple;
     66                                }
     67                        } else {
     68                                valueSchemeInput.valueSchemeEnumeration = valueScheme.valueSchemeEnumeration;
     69                        }
    5770                        BindingUtils.bindSetter(function(val:String):void {
    58                                         attribute.valueSchemePattern = val;
    59                                         attribute.valueSchemeEnumeration = null;
    60                                         attribute.type = "";
     71                                        valueScheme.valueSchemePattern = val;
     72                                        valueScheme.valueSchemeEnumeration = null;
     73                                        valueScheme.valueSchemeSimple = "";
    6174                                }, valueSchemeInput, "valueSchemePattern");
    6275                        BindingUtils.bindSetter(function(val:String):void {
    63                                         attribute.type = val;
    64                                         attribute.valueSchemePattern ="";
    65                                         attribute.valueSchemeEnumeration = null;
     76                                        valueScheme.valueSchemeSimple = val;
     77                                        valueScheme.valueSchemePattern ="";
     78                                        valueScheme.valueSchemeEnumeration = null;
    6679                                }, valueSchemeInput, "valueSchemeSimple");
    6780                        BindingUtils.bindSetter(function(val:XMLListCollection):void {
    68                                         attribute.valueSchemeEnumeration = val;
    69                                         attribute.type = "";
    70                                         attribute.valueSchemePattern = "";
     81                                        valueScheme.valueSchemeEnumeration = val;
     82                                        valueScheme.valueSchemeSimple = "";
     83                                        valueScheme.valueSchemePattern = "";
    7184                                }, valueSchemeInput, "valueSchemeEnumeration");
    72                         if (attribute.valueSchemeEnumeration == null) {
    73                                 if (attribute.valueSchemePattern != null) {
    74                                         valueSchemeInput.valueSchemePattern = attribute.valueSchemePattern;
    75                                 } else {
    76                                         valueSchemeInput.valueSchemeSimple = attribute.type;
    77                                 }
    78                         } else {
    79                                 valueSchemeInput.valueSchemeEnumeration = attribute.valueSchemeEnumeration;
    80                         }
    8185                        return valueSchemeInput;
    8286                }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorManager.as

    r238 r264  
    88
    99                private static var _isocatSearchPopUp:IsocatSearchPopUp;
    10                 private static var _valueSchemePopUp:ValueSchemePopUp;
    1110
    1211                public static function getIsocatSearchPopUp():IsocatSearchPopUp {
     
    1716                }
    1817
    19                 public static function getValueSchemePopUp():ValueSchemePopUp {
    20                         if (!_valueSchemePopUp) {
    21                                 _valueSchemePopUp = new ValueSchemePopUp();
    22                         }
    23                         return _valueSchemePopUp;
    24                 }
    25 
    2618        }
    2719}
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ElementEdit.as

    r238 r264  
    77        import flash.events.MouseEvent;
    88
    9         import mx.binding.utils.BindingUtils;
    10         import mx.binding.utils.ChangeWatcher;
    11         import mx.collections.XMLListCollection;
    129        import mx.containers.Form;
    1310        import mx.containers.FormItem;
     
    5148                                        _element.cardinalityMax = val;
    5249                                }));
    53                         createAndAddValueScheme();
     50                        addChild(AttributeListEdit.createAndAddValueScheme(_element));
    5451                        handleCMDAttributeList();
    5552                }
     
    8481                }
    8582
    86                 private function createAndAddValueScheme():void {
    87                         var valueSchemeInput:ValueSchemeInput = new ValueSchemeInput("Type");
    88                         BindingUtils.bindSetter(function(val:String):void {
    89                                         _element.valueSchemePattern = val;
    90                                         _element.valueSchemeSimple = "";
    91                                         _element.valueSchemeEnumeration = null;
    92                                 }, valueSchemeInput, "valueSchemePattern");
    93                         BindingUtils.bindSetter(function(val:String):void {
    94                                         _element.valueSchemeSimple = val;
    95                                         _element.valueSchemeEnumeration = null;
    96                                         _element.valueSchemePattern = "";
    97                                 }, valueSchemeInput, "valueSchemeSimple");
    98                         BindingUtils.bindSetter(function(val:XMLListCollection):void {
    99                                         _element.valueSchemeEnumeration = val;
    100                                         _element.valueSchemeSimple = "";
    101                                         _element.valueSchemePattern = "";
    102                                 }, valueSchemeInput, "valueSchemeEnumeration");
    103 
    104                         if (_element.valueSchemeEnumeration == null) {
    105                                 if (_element.valueSchemePattern != null) {
    106                                         valueSchemeInput.valueSchemePattern = _element.valueSchemePattern;
    107                                 } else {
    108                                         valueSchemeInput.valueSchemeSimple = _element.valueSchemeSimple;
    109                                 }
    110                         } else {
    111                                 valueSchemeInput.valueSchemeEnumeration = _element.valueSchemeEnumeration;
    112 
    113                         }
    114                         addChild(valueSchemeInput);
    115                 }
    116 
    11783                private function createHeading():FormItem {
    11884                        var heading:FormItem = new FormItem();
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ValueSchemeEnumerationGrid.mxml

    r238 r264  
    1414
    1515                        [Bindable]
    16                         public var valueSchemeEnumeration:ArrayCollection = new ArrayCollection([{item: ADD_ROW, conceptLink: "", appInfo: ""}]);
     16                        public var valueSchemeEnumeration:ArrayCollection = new ArrayCollection();
    1717
     18                        public function initEnumeration(valueSchemeData:XMLListCollection):void {
     19                                if (valueSchemeData) {
     20                                        for each (var item:XML in valueSchemeData) {
     21                                                valueSchemeEnumeration.addItem({item: item.text(), conceptLink: item.@ConceptLink, appInfo: item.@AppInfo});
     22                                        }
     23                                }
     24                                valueSchemeEnumeration.addItem({item: ADD_ROW, conceptLink: "", appInfo: ""});
     25                        }
    1826
    1927                        private function editEnd(e:DataGridEvent):void {
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ValueSchemeInput.as

    r238 r264  
    3737                protected override function createChildren():void {
    3838                        super.createChildren();
    39                         addChild(textField);
    4039                        addChild(valueSchemeButton);
    4140                }
     
    5352                        if (getChildren().length > 1) {
    5453                                removeChildAt(0);
    55                                 addChildAt(textField, 0);
    5654                        }
     55                        addChildAt(textField, 0);
    5756                }
    5857
     
    6968                        if (getChildren().length > 1) {
    7069                                removeChildAt(0);
    71                                 addChildAt(textField, 0);
    7270                        }
     71                        addChildAt(textField, 0);
    7372                }
    7473
     
    8584                        if (getChildren().length > 1) {
    8685                                removeChildAt(0);
    87                                 addChildAt(enumeration, 0);
    8886                        }
     87                        addChildAt(enumeration, 0);
    8988                }
    9089
     
    9998
    10099                private function handleButtonClick(event:MouseEvent):void {
    101                         var popup:ValueSchemePopUp = EditorManager.getValueSchemePopUp();
     100                        var popup:ValueSchemePopUp = new ValueSchemePopUp();
    102101                        popup.valueSchemeInput = this;
    103102                        PopUpManager.addPopUp(popup, this, false);
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ValueSchemePopUp.mxml

    r238 r264  
    1919                        public var valueSchemeInput:ValueSchemeInput;
    2020
    21             //Taken from http://www.clarin.eu/cmd/general-component-schema.xsd (allowed_attributetypes_type)
     21                        //Taken from http://www.clarin.eu/cmd/general-component-schema.xsd (allowed_attributetypes_type)
    2222                        [Bindable]
    2323                        private var simpleValueSchemeDataProvider:ArrayCollection = new ArrayCollection([{label: "boolean", data: "boolean"},
     
    6363        <mx:HBox width="100%">
    6464                <mx:ComboBox id="simpleValueSchemeBox"
     65                                         prompt="{valueSchemeInput.valueSchemeSimple}"
    6566                                         dataProvider="{simpleValueSchemeDataProvider}">
    6667                </mx:ComboBox>
     
    7273        <mx:Label text="Or enter pattern:"/>
    7374        <mx:HBox width="100%">
    74                 <mx:TextInput id="patternInput">
    75                         <!-- PD TODO how can I check this -->
     75                <mx:TextInput id="patternInput" text="{valueSchemeInput.valueSchemePattern}">
     76                        <!-- PD TODO how can I validate this -->
    7677                </mx:TextInput>
    7778                <mx:Spacer width="100%"/>
     
    8384        <mx:Label text="Or create controlled vocabularies:"/>
    8485        <mx:HBox width="100%">
    85                 <editor:ValueSchemeEnumerationGrid id="enumerationGrid"/>
     86                <editor:ValueSchemeEnumerationGrid id="enumerationGrid" creationComplete="enumerationGrid.initEnumeration(valueSchemeInput.valueSchemeEnumeration)"/>
    8687                <mx:Button label="Use Controlled Vocabulary"
    8788                                   click="setControlledVocabulary()"/>
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDAttribute.as

    r238 r264  
    44        import mx.collections.XMLListCollection;
    55
    6         public class CMDAttribute implements XmlAble {
     6        public class CMDAttribute implements XmlAble, ValueSchemeInterface {
    77                //No Attributes
    88
    99                //Elements
    1010                public var name:String;
    11                 public var type:String;
    12                 public var valueSchemePattern:String; //pattern
    13                 public var valueSchemeEnumeration:XMLListCollection; // enumeration
     11                private var type:String;
     12                private var _valueSchemePattern:String; //pattern
     13                private var _valueSchemeEnumeration:XMLListCollection; // enumeration
    1414
    1515                public function CMDAttribute() {
    1616                }
    1717
     18                public function get valueSchemeSimple():String {
     19                        return this.type
     20                }
     21
     22                public function set valueSchemeSimple(valueSchemeSimple:String):void {
     23                        this.type = valueSchemeSimple;
     24                }
     25
     26                public function get valueSchemeEnumeration():XMLListCollection {
     27                        return this._valueSchemeEnumeration
     28                }
     29
     30                public function set valueSchemeEnumeration(valueSchemeEnumeration:XMLListCollection):void {
     31                        this._valueSchemeEnumeration = valueSchemeEnumeration;
     32                }
     33
     34                public function get valueSchemePattern():String {
     35                        return this._valueSchemePattern;
     36                }
     37
     38                public function set valueSchemePattern(valueSchemePattern:String):void {
     39                        this._valueSchemePattern = valueSchemePattern;
     40                }
     41
    1842                public function toXml():XML {
    19                         var result:XML = <Attribute></Attribute>;
     43                        var result:XML = <Attribute></Attribute>;
    2044                        result.appendChild(<Name>{name}</Name>);
    2145                        if (valueSchemePattern) {
    2246                                result.appendChild(<ValueScheme><pattern>{valueSchemePattern}</pattern></ValueScheme>);
    2347                        } else if (valueSchemeEnumeration) {
    24                                 var enumerationScheme:XML = <enumeration></enumeration>;
    25                                 for each(var item:XML in valueSchemeEnumeration) {
    26                                     enumerationScheme.appendChild(item);
    27                         }
    28                         result.appendChild(<ValueScheme>{enumerationScheme}</ValueScheme>);
     48                                var enumerationScheme:XML = <enumeration></enumeration>;
     49                                for each (var item:XML in valueSchemeEnumeration) {
     50                                        enumerationScheme.appendChild(item);
     51                                }
     52                                result.appendChild(<ValueScheme>{enumerationScheme}</ValueScheme>);
    2953                        } else {
    3054                                result.appendChild(<Type>{type}</Type>);
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDAttributeTest.as

    r238 r264  
    1919                        var result:CMDAttribute = new CMDAttribute();
    2020                        result.name = "aap";
    21                         result.type = "string";
     21                        result.valueSchemeSimple = "string";
    2222                        var expected:XML = <Attribute>
    2323                                        <Name>aap</Name>
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponentElement.as

    r238 r264  
    11package clarin.cmdi.componentregistry.editor.model {
    22        import clarin.cmdi.componentregistry.common.XmlAble;
    3        
     3
    44        import mx.collections.ArrayCollection;
    55        import mx.collections.XMLListCollection;
    66
    7         public class CMDComponentElement implements XmlAble {
     7        public class CMDComponentElement implements XmlAble, ValueSchemeInterface {
    88
    99                //Attributes
    1010                public var name:String;
    1111                public var conceptLink:String;
    12                 public var valueSchemeSimple:String;
     12                private var _valueSchemeSimple:String;
    1313                public var cardinalityMin:String = "1";
    1414                public var cardinalityMax:String = "1";
     
    1717                //elements
    1818                public var attributeList:ArrayCollection = new ArrayCollection();
    19                 public var valueSchemeEnumeration:XMLListCollection;
    20                 public var valueSchemePattern:String;
     19                private var _valueSchemeEnumeration:XMLListCollection;
     20                private var _valueSchemePattern:String;
    2121
    2222                public function CMDComponentElement() {
    2323                }
    2424
     25                public function get valueSchemeSimple():String {
     26                        return this._valueSchemeSimple
     27                }
    2528
     29                public function set valueSchemeSimple(valueSchemeSimple:String):void {
     30                        this._valueSchemeSimple = valueSchemeSimple;
     31                }
     32
     33                public function get valueSchemeEnumeration():XMLListCollection {
     34                        return this._valueSchemeEnumeration
     35                }
     36
     37                public function set valueSchemeEnumeration(valueSchemeEnumeration:XMLListCollection):void {
     38                        this._valueSchemeEnumeration = valueSchemeEnumeration;
     39                }
     40
     41                public function get valueSchemePattern():String {
     42                        return this._valueSchemePattern;
     43                }
     44
     45                public function set valueSchemePattern(valueSchemePattern:String):void {
     46                        this._valueSchemePattern = valueSchemePattern;
     47                }
    2648
    2749                public function toXml():XML {
     
    4971                        if (valueSchemeEnumeration != null) {
    5072                                var enumerationScheme:XML = <enumeration></enumeration>;
    51                                 for each(var item:XML in valueSchemeEnumeration) {
    52                                     enumerationScheme.appendChild(item);
    53                         }
    54                         result.appendChild(<ValueScheme>{enumerationScheme}</ValueScheme>);
     73                                for each (var item:XML in valueSchemeEnumeration) {
     74                                        enumerationScheme.appendChild(item);
     75                                }
     76                                result.appendChild(<ValueScheme>{enumerationScheme}</ValueScheme>);
    5577                        }
    5678                        return result;
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponentElementTest.as

    r238 r264  
    2222                        var att:CMDAttribute = new CMDAttribute();
    2323                        att.name = "test";
    24                         att.type = "string";
     24                        att.valueSchemeSimple = "string";
    2525                        result.attributeList.addItem(att);
    2626                        var expected:XML = <CMD_Element name="aap" ValueScheme="string" CardinalityMin="1" CardinalityMax="1">
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDModelFactory.as

    r249 r264  
    8080                        result.name = xml.Name;
    8181                        if (xml.hasOwnProperty(ComponentMD.TYPE)) {
    82                                 result.type = xml.Type;
     82                                result.valueSchemeSimple = xml.Type;
    8383                        } else {
    8484                                if (xml.ValueScheme.hasOwnProperty(ComponentMD.PATTERN)) {
Note: See TracChangeset for help on using the changeset viewer.