Changeset 264
- Timestamp:
- 03/22/10 09:40:42 (14 years ago)
- 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 123 123 for each (var attribute:CMDAttribute in attributes) { 124 124 createAndAddFormChild("Name", attribute.name); 125 if ( attribute.type != null) {126 createAndAddFormChild("Type", attribute. type);125 if (!attribute.valueSchemeSimple) { 126 createAndAddFormChild("Type", attribute.valueSchemeSimple); 127 127 } else { 128 128 createAndAddValueScheme(null, attribute.valueSchemePattern, attribute.valueSchemeEnumeration); -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/AttributeListEdit.as
r238 r264 2 2 import clarin.cmdi.componentregistry.common.StyleConstants; 3 3 import clarin.cmdi.componentregistry.editor.model.CMDAttribute; 4 4 import clarin.cmdi.componentregistry.editor.model.ValueSchemeInterface; 5 5 6 import flash.events.Event; 6 7 import flash.events.MouseEvent; 7 8 8 9 import mx.binding.utils.BindingUtils; 9 10 import mx.collections.ArrayCollection; … … 53 54 } 54 55 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 { 56 60 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 } 57 70 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 = ""; 61 74 }, valueSchemeInput, "valueSchemePattern"); 62 75 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; 66 79 }, valueSchemeInput, "valueSchemeSimple"); 67 80 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 = ""; 71 84 }, 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 }81 85 return valueSchemeInput; 82 86 } -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/EditorManager.as
r238 r264 8 8 9 9 private static var _isocatSearchPopUp:IsocatSearchPopUp; 10 private static var _valueSchemePopUp:ValueSchemePopUp;11 10 12 11 public static function getIsocatSearchPopUp():IsocatSearchPopUp { … … 17 16 } 18 17 19 public static function getValueSchemePopUp():ValueSchemePopUp {20 if (!_valueSchemePopUp) {21 _valueSchemePopUp = new ValueSchemePopUp();22 }23 return _valueSchemePopUp;24 }25 26 18 } 27 19 } -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ElementEdit.as
r238 r264 7 7 import flash.events.MouseEvent; 8 8 9 import mx.binding.utils.BindingUtils;10 import mx.binding.utils.ChangeWatcher;11 import mx.collections.XMLListCollection;12 9 import mx.containers.Form; 13 10 import mx.containers.FormItem; … … 51 48 _element.cardinalityMax = val; 52 49 })); 53 createAndAddValueScheme();50 addChild(AttributeListEdit.createAndAddValueScheme(_element)); 54 51 handleCMDAttributeList(); 55 52 } … … 84 81 } 85 82 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 117 83 private function createHeading():FormItem { 118 84 var heading:FormItem = new FormItem(); -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ValueSchemeEnumerationGrid.mxml
r238 r264 14 14 15 15 [Bindable] 16 public var valueSchemeEnumeration:ArrayCollection = new ArrayCollection( [{item: ADD_ROW, conceptLink: "", appInfo: ""}]);16 public var valueSchemeEnumeration:ArrayCollection = new ArrayCollection(); 17 17 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 } 18 26 19 27 private function editEnd(e:DataGridEvent):void { -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ValueSchemeInput.as
r238 r264 37 37 protected override function createChildren():void { 38 38 super.createChildren(); 39 addChild(textField);40 39 addChild(valueSchemeButton); 41 40 } … … 53 52 if (getChildren().length > 1) { 54 53 removeChildAt(0); 55 addChildAt(textField, 0);56 54 } 55 addChildAt(textField, 0); 57 56 } 58 57 … … 69 68 if (getChildren().length > 1) { 70 69 removeChildAt(0); 71 addChildAt(textField, 0);72 70 } 71 addChildAt(textField, 0); 73 72 } 74 73 … … 85 84 if (getChildren().length > 1) { 86 85 removeChildAt(0); 87 addChildAt(enumeration, 0);88 86 } 87 addChildAt(enumeration, 0); 89 88 } 90 89 … … 99 98 100 99 private function handleButtonClick(event:MouseEvent):void { 101 var popup:ValueSchemePopUp = EditorManager.getValueSchemePopUp();100 var popup:ValueSchemePopUp = new ValueSchemePopUp(); 102 101 popup.valueSchemeInput = this; 103 102 PopUpManager.addPopUp(popup, this, false); -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/ValueSchemePopUp.mxml
r238 r264 19 19 public var valueSchemeInput:ValueSchemeInput; 20 20 21 21 //Taken from http://www.clarin.eu/cmd/general-component-schema.xsd (allowed_attributetypes_type) 22 22 [Bindable] 23 23 private var simpleValueSchemeDataProvider:ArrayCollection = new ArrayCollection([{label: "boolean", data: "boolean"}, … … 63 63 <mx:HBox width="100%"> 64 64 <mx:ComboBox id="simpleValueSchemeBox" 65 prompt="{valueSchemeInput.valueSchemeSimple}" 65 66 dataProvider="{simpleValueSchemeDataProvider}"> 66 67 </mx:ComboBox> … … 72 73 <mx:Label text="Or enter pattern:"/> 73 74 <mx:HBox width="100%"> 74 <mx:TextInput id="patternInput" >75 <!-- PD TODO how can I checkthis -->75 <mx:TextInput id="patternInput" text="{valueSchemeInput.valueSchemePattern}"> 76 <!-- PD TODO how can I validate this --> 76 77 </mx:TextInput> 77 78 <mx:Spacer width="100%"/> … … 83 84 <mx:Label text="Or create controlled vocabularies:"/> 84 85 <mx:HBox width="100%"> 85 <editor:ValueSchemeEnumerationGrid id="enumerationGrid" />86 <editor:ValueSchemeEnumerationGrid id="enumerationGrid" creationComplete="enumerationGrid.initEnumeration(valueSchemeInput.valueSchemeEnumeration)"/> 86 87 <mx:Button label="Use Controlled Vocabulary" 87 88 click="setControlledVocabulary()"/> -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDAttribute.as
r238 r264 4 4 import mx.collections.XMLListCollection; 5 5 6 public class CMDAttribute implements XmlAble {6 public class CMDAttribute implements XmlAble, ValueSchemeInterface { 7 7 //No Attributes 8 8 9 9 //Elements 10 10 public var name:String; 11 p ublicvar type:String;12 p ublic varvalueSchemePattern:String; //pattern13 p ublic varvalueSchemeEnumeration:XMLListCollection; // enumeration11 private var type:String; 12 private var _valueSchemePattern:String; //pattern 13 private var _valueSchemeEnumeration:XMLListCollection; // enumeration 14 14 15 15 public function CMDAttribute() { 16 16 } 17 17 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 18 42 public function toXml():XML { 19 43 var result:XML = <Attribute></Attribute>; 20 44 result.appendChild(<Name>{name}</Name>); 21 45 if (valueSchemePattern) { 22 46 result.appendChild(<ValueScheme><pattern>{valueSchemePattern}</pattern></ValueScheme>); 23 47 } else if (valueSchemeEnumeration) { 24 25 for each (var item:XML in valueSchemeEnumeration) {26 27 28 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>); 29 53 } else { 30 54 result.appendChild(<Type>{type}</Type>); -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDAttributeTest.as
r238 r264 19 19 var result:CMDAttribute = new CMDAttribute(); 20 20 result.name = "aap"; 21 result. type = "string";21 result.valueSchemeSimple = "string"; 22 22 var expected:XML = <Attribute> 23 23 <Name>aap</Name> -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponentElement.as
r238 r264 1 1 package clarin.cmdi.componentregistry.editor.model { 2 2 import clarin.cmdi.componentregistry.common.XmlAble; 3 3 4 4 import mx.collections.ArrayCollection; 5 5 import mx.collections.XMLListCollection; 6 6 7 public class CMDComponentElement implements XmlAble {7 public class CMDComponentElement implements XmlAble, ValueSchemeInterface { 8 8 9 9 //Attributes 10 10 public var name:String; 11 11 public var conceptLink:String; 12 p ublic varvalueSchemeSimple:String;12 private var _valueSchemeSimple:String; 13 13 public var cardinalityMin:String = "1"; 14 14 public var cardinalityMax:String = "1"; … … 17 17 //elements 18 18 public var attributeList:ArrayCollection = new ArrayCollection(); 19 p ublic varvalueSchemeEnumeration:XMLListCollection;20 p ublic varvalueSchemePattern:String;19 private var _valueSchemeEnumeration:XMLListCollection; 20 private var _valueSchemePattern:String; 21 21 22 22 public function CMDComponentElement() { 23 23 } 24 24 25 public function get valueSchemeSimple():String { 26 return this._valueSchemeSimple 27 } 25 28 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 } 26 48 27 49 public function toXml():XML { … … 49 71 if (valueSchemeEnumeration != null) { 50 72 var enumerationScheme:XML = <enumeration></enumeration>; 51 for each (var item:XML in valueSchemeEnumeration) {52 53 54 73 for each (var item:XML in valueSchemeEnumeration) { 74 enumerationScheme.appendChild(item); 75 } 76 result.appendChild(<ValueScheme>{enumerationScheme}</ValueScheme>); 55 77 } 56 78 return result; -
ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/editor/model/CMDComponentElementTest.as
r238 r264 22 22 var att:CMDAttribute = new CMDAttribute(); 23 23 att.name = "test"; 24 att. type = "string";24 att.valueSchemeSimple = "string"; 25 25 result.attributeList.addItem(att); 26 26 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 80 80 result.name = xml.Name; 81 81 if (xml.hasOwnProperty(ComponentMD.TYPE)) { 82 result. type = xml.Type;82 result.valueSchemeSimple = xml.Type; 83 83 } else { 84 84 if (xml.ValueScheme.hasOwnProperty(ComponentMD.PATTERN)) {
Note: See TracChangeset
for help on using the changeset viewer.