fix horrid merge bug (yay!). Implement suspend/resume events for redrawing, to speed...
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / SingleTagEditor.as
1 package net.systemeD.potlatch2.mapfeatures.editors {
2
3     import net.systemeD.halcyon.connection.*;
4     import net.systemeD.potlatch2.mapfeatures.*;
5     import mx.containers.VBox;
6     import flash.events.*;
7
8         public class SingleTagEditor extends VBox {
9
10       protected var _factory:SingleTagEditorFactory;
11       protected var _entity:Entity;
12       
13       [Bindable(event="factory_set")]
14       public function get fieldName():String {
15           return _factory == null ? "" : _factory.name;
16       }
17       
18       [Bindable(event="factory_set")]
19       public function get fieldDescription():String {
20           return _factory == null ? "" : _factory.description;
21       }
22       
23       [Bindable(event="tag_changed")]
24       public function get value():String {
25           return _entity == null ? "" : _entity.getTag(_factory.key);
26       }
27       
28       public function set value(val:String):void {
29           if ( _entity != null )
30               _entity.setTag(_factory.key, val);
31       }
32
33       public function set factory(factory:SingleTagEditorFactory):void {
34           _factory = factory;
35           dispatchEvent(new Event("factory_set"));
36       }
37       
38       public function set entity(entity:Entity):void {
39           _entity = entity;
40           entity.addEventListener(Connection.TAG_CHANGED, tagChanged, false, 0, true);
41           dispatchEvent(new Event("tag_changed"));
42       }
43       
44       private function tagChanged(event:TagEvent):void {
45           var tagVal:String = _entity.getTag(_factory.key);
46           dispatchEvent(new Event("tag_changed"));
47       }
48
49     }
50
51 }
52
53