Changeset 1949


Ignore:
Timestamp:
05/21/12 15:39:51 (12 years ago)
Author:
twagoo
Message:

Fixed implementation of #202:

  • when new components/elements/attributes are added, they inherit changeTracking status of parent
  • CMDComponentElement also check attribute children for changes when doing hasChanged()
Location:
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDAttribute.as

    r1946 r1949  
    11package clarin.cmdi.componentregistry.editor.model {
     2        import clarin.cmdi.componentregistry.common.ChangeTrackingCMDElement;
    23        import clarin.cmdi.componentregistry.common.ComponentMD;
    34        import clarin.cmdi.componentregistry.common.XmlAble;
     
    78        import mx.collections.ArrayCollection;
    89
    9         public class CMDAttribute implements XmlAble, ValueSchemeInterface {
     10        public class CMDAttribute implements XmlAble, ValueSchemeInterface, ChangeTrackingCMDElement {
    1011                //No Attributes
    1112
     
    1819               
    1920                private var changed:Boolean = false;
    20                 public var changeTracking:Boolean = false;
     21                private var _changeTracking:Boolean = false;
    2122               
    2223                public function CMDAttribute() {
     
    2930                }
    3031               
     32                public function set changeTracking(value:Boolean):void{
     33                        _changeTracking = value;
     34                }
     35               
    3136                public function setChanged(value:Boolean):void {
    32                         if(changeTracking) {
     37                        if(_changeTracking) {
    3338                                this.changed = value;
    3439                        }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponent.as

    r1946 r1949  
    11package clarin.cmdi.componentregistry.editor.model {
     2        import clarin.cmdi.componentregistry.common.ChangeTrackingCMDElement;
    23        import clarin.cmdi.componentregistry.common.XmlAble;
    34       
     
    67        import mx.events.CollectionEventKind;
    78
    8         public class CMDComponent implements XmlAble, AttributeContainer {
     9        public class CMDComponent implements XmlAble, AttributeContainer, ChangeTrackingCMDElement {
    910
    1011                //Attributes
     
    3839                        if(event.kind == CollectionEventKind.ADD ||event.kind == CollectionEventKind.MOVE || event.kind == CollectionEventKind.REMOVE){
    3940                                setChanged(true);
     41                        }
     42                        if(event.kind == CollectionEventKind.ADD){
     43                                for each(var item:ChangeTrackingCMDElement in event.items){
     44                                        item.changeTracking = _changeTracking;
     45                                }
    4046                        }
    4147                }
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponentElement.as

    r1946 r1949  
    11package clarin.cmdi.componentregistry.editor.model {
     2        import clarin.cmdi.componentregistry.common.ChangeTrackingCMDElement;
    23        import clarin.cmdi.componentregistry.common.ComponentMD;
    34        import clarin.cmdi.componentregistry.common.XmlAble;
     
    67       
    78        import mx.collections.ArrayCollection;
    8 
     9        import mx.events.CollectionEvent;
     10        import mx.events.CollectionEventKind;
     11       
    912        [Bindable]
    10         public class CMDComponentElement implements XmlAble, ValueSchemeInterface, AttributeContainer {
    11 
     13        public class CMDComponentElement implements XmlAble, ValueSchemeInterface, AttributeContainer, ChangeTrackingCMDElement {
     14               
    1215                //Attributes
    1316                public var name:String;
     
    1922                public var cardinalityMin:String = "1";
    2023                public var cardinalityMax:String = "1";
    21 
     24               
    2225                //elements
    2326                public var attributeList:ArrayCollection = new ArrayCollection();
     
    2528                private var _valueSchemePattern:String;
    2629                private var changed:Boolean = false;
    27                 public var changeTracking:Boolean = false;
    28 
     30                private var _changeTracking:Boolean = false;
     31               
    2932                public function CMDComponentElement() {
     33                        attributeList.addEventListener(CollectionEvent.COLLECTION_CHANGE, collectionChangedHandler);
     34                }
     35               
     36                public function set changeTracking(value:Boolean):void{
     37                        _changeTracking = value;
     38                        for each (var attribute:CMDAttribute in attributeList){
     39                                attribute.changeTracking = value;
     40                        }
     41                }
     42               
     43                private function collectionChangedHandler(event:CollectionEvent):void {
     44                        if(event.kind == CollectionEventKind.ADD ||event.kind == CollectionEventKind.MOVE || event.kind == CollectionEventKind.REMOVE){
     45                                setChanged(true);
     46                        }
     47                        if(event.kind == CollectionEventKind.ADD){
     48                                for each(var item:ChangeTrackingCMDElement in event.items){
     49                                        item.changeTracking = _changeTracking;
     50                                }
     51                        }
    3052                }
    3153               
    3254                public function setChanged(value:Boolean):void {
    33                         if(changeTracking) {
     55                        if(_changeTracking) {
    3456                                this.changed = value;
    3557                        }
     
    3759               
    3860                public function get hasChanged():Boolean{
    39                         return changed;
     61                        if(changed){
     62                                return changed;
     63                        } else {
     64                                for each (var attribute:CMDAttribute in attributeList){
     65                                        if(attribute.hasChanged){
     66                                                return true;
     67                                        }
     68                                }
     69                        }
     70                        return false;
    4071                }
    41 
     72               
    4273                public static function createEmptyElement():CMDComponentElement {
    4374                        var result:CMDComponentElement = new CMDComponentElement();
     
    4576                        return result;
    4677                }
    47 
    48 
     78               
     79               
    4980                public function get valueSchemeSimple():String {
    5081                        return this._valueSchemeSimple
    5182                }
    52 
     83               
    5384                public function set valueSchemeSimple(valueSchemeSimple:String):void {
    5485                        this._valueSchemeSimple = valueSchemeSimple;
    5586                        setChanged(true);
    5687                }
    57 
     88               
    5889                public function get valueSchemeEnumeration():ArrayCollection {
    5990                        return this._valueSchemeEnumeration
    6091                }
    61 
     92               
    6293                public function set valueSchemeEnumeration(valueSchemeEnumeration:ArrayCollection):void {
    6394                        this._valueSchemeEnumeration = valueSchemeEnumeration;
    6495                        setChanged(true);
    6596                }
    66 
     97               
    6798                public function get valueSchemePattern():String {
    6899                        return this._valueSchemePattern;
    69100                }
    70 
     101               
    71102                public function set valueSchemePattern(valueSchemePattern:String):void {
    72103                        this._valueSchemePattern = valueSchemePattern;
    73104                        setChanged(true);
    74105                }
    75 
     106               
    76107                public function toXml():XML {
    77108                        var result:XML = <CMD_Element></CMD_Element>;
     
    111142                        return result;
    112143                }
    113 
     144               
    114145                public function getAttributeList():ArrayCollection {
    115146                        return attributeList;
    116147                }
    117 
     148               
    118149        }
    119150}
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDSpec.as

    r1946 r1949  
    11package clarin.cmdi.componentregistry.editor.model {
     2        import clarin.cmdi.componentregistry.common.ChangeTrackingCMDElement;
    23        import clarin.cmdi.componentregistry.common.XmlAble;
    34       
    45        import mx.collections.ArrayCollection;
    56        import mx.events.CollectionEvent;
     7        import mx.events.CollectionEventKind;
    68
    79        [Bindable]
    8         public class CMDSpec implements XmlAble {
     10        public class CMDSpec implements XmlAble, ChangeTrackingCMDElement {
    911                //Attribute
    1012                public var isProfile:Boolean;
     
    5557               
    5658                private function collectionChangedHandler(event:CollectionEvent):void {
    57                         setChanged(true);
     59                        if(event.kind == CollectionEventKind.ADD ||event.kind == CollectionEventKind.MOVE || event.kind == CollectionEventKind.REMOVE){
     60                                setChanged(true);
     61                        }
     62                        if(event.kind == CollectionEventKind.ADD){
     63                                for each(var item:ChangeTrackingCMDElement in event.items){
     64                                        item.changeTracking = _changeTracking;
     65                                }
     66                        }
    5867                }
    5968
Note: See TracChangeset for help on using the changeset viewer.