Created
August 8, 2010 18:43
-
-
Save suryagaddipati/514401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class XmlElementAttributeObservableValue extends AbstractObservableValue{ | |
| Element element; | |
| String propertyName; | |
| public XmlElementAttributeObservableValue( Element element, final String propertyName) { | |
| this.element = element; | |
| this.propertyName = propertyName; | |
| addListner(this.element, this.propertyName); | |
| } | |
| private void addListner(final Element element, final String propertyName) { | |
| ElementImpl elementImpl = (ElementImpl) element; | |
| elementImpl.addEventListener("DOMAttrModified", new EventListener(){ | |
| public void handleEvent(Event evt) { | |
| final MutationEvent mutEvent = (MutationEvent) evt; | |
| if( mutEvent.getAttrName().equals(propertyName)){ | |
| fireValueChange(new ValueDiff(){ | |
| @Override | |
| public Object getNewValue() { | |
| return mutEvent.getNewValue(); | |
| } | |
| @Override | |
| public Object getOldValue() { | |
| return mutEvent.getPrevValue(); | |
| } | |
| }); | |
| } | |
| } | |
| }, false); | |
| } | |
| public Object getValueType() { | |
| return String.class; | |
| } | |
| public boolean isStale() { | |
| return false; | |
| } | |
| @Override | |
| protected Object doGetValue() { | |
| return element.getAttribute(propertyName); | |
| } | |
| @Override | |
| protected void doSetValue(Object value) { | |
| element.setAttribute(propertyName, (String) value); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment