No Selection]]>
Nothing selected" :
"Not recognised
Try looking at the tags under the advanced properties";
popupChange.label = "unknown";
tw.setSelectedFeature(null);
}
private function checkAdvanced():void {
if ( selectedEntity != null )
setupAdvanced(selectedEntity);
}
private function setupAdvanced(entity:Entity):void {
var entityText:String = "xx";
if ( entity is Node ) entityText = "Node";
else if ( entity is Way ) entityText = "Way";
else if ( entity is Relation ) entityText = "Relation";
advancedID.htmlText = entityText+": "+entity.id+"";
if ( collection == null ) {
collection = new ArrayCollection();
//var sort:Sort = new Sort();
//sort.fields = [new SortField("key", true)];
//collection.sort = sort;
//collection.refresh();
advancedTagGrid.dataProvider = collection;
}
collection.removeAll();
var tags:Array = entity.getTagArray();
tags.sortOn("key");
for each(var tag:Tag in tags)
collection.addItem(tag);
}
private function tagChanged(event:TagEvent):void {
refreshFeatureIcon();
if ( collection != null ) {
// check to see if the key is already in our list
var exists:Boolean = false;
var tag:Tag = null;
var i:uint;
for ( i = 0; i < collection.length && !exists; i++ ) {
tag = Tag(collection.getItemAt(i));
exists = tag.key == event.key;
}
if ( !exists ) {
tag = new Tag(selectedEntity, event.key, event.newValue);
collection.addItem(tag);
collection.refresh();
} else {
if ( event.newValue == null ) {
collection.removeItemAt(i-1);
collection.refresh();
}
}
}
}
public function loadFeatures():void {
mapFeatures = MapFeatures.getInstance();
}
public function openDescription():void {
trace("open description here");
}
public function addNewTag():void {
var newKey:String = "(new tag)";
var newTag:Tag = new Tag(selectedEntity, newKey, "(new value)");
collection.addItem(newTag);
advancedTagGrid.editedItemPosition = {rowIndex: collection.getItemIndex(newTag), columnIndex: 0};
}
public function removeTag():void {
var k:String = advancedTagGrid.selectedItem.key;
selectedEntity.setTag(k, null);
}
public function initFeatureBox():void {
tw = new CategorySelector();
tw.addEventListener("selectedType", changeFeatureType);
popupChange.popUp = tw;
}
public function changeFeatureType(event:Event):void {
if ( selectedEntity == null )
return;
var newFeature:Feature = tw.selectedType;
// remove tags from the current feature
if ( feature != null ) {
for each( var oldtag:Object in feature.tags ) {
selectedEntity.setTag(oldtag["k"], null);
}
}
// set tags for new feature
if ( newFeature != null ) {
for each( var newtag:Object in newFeature.tags ) {
selectedEntity.setTag(newtag["k"], newtag["v"]);
}
}
popupChange.close();
}
]]>