final ODOMChangeListener hierarchyChangeListener =
new ODOMChangeListener() {
public void changed(ODOMObservable node,
ODOMChangeEvent event) {
if (event.getSource() instanceof Element) {
ODOMElement source = (ODOMElement) event.getSource();
if (source != getElement()) {
processEvent(node, event);
}
}
}
};
final ODOMChangeListener attributeChangeListener =
new ODOMChangeListener() {
public void changed(ODOMObservable node,
ODOMChangeEvent event) {
if (event.getSource() instanceof Attribute) {
processEvent(node, event);
}
}
};
formatComposite.getElement().addChangeListener(hierarchyChangeListener,
ChangeQualifier.HIERARCHY);
formatComposite.getElement().addChangeListener(attributeChangeListener,
ChangeQualifier.ATTRIBUTE_VALUE);
formatComposite.getElement().addChangeListener(attributeChangeListener,
ChangeQualifier.HIERARCHY);
// Add a dispose listener to the FormatComposite so that this
// FormatCompositeModifier will stop trying to modify the
// FormatComposite subsequent to its departure.
formatComposite.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
ODOMElement element = formatComposite.getElement();
element.removeChangeListener(hierarchyChangeListener,
ChangeQualifier.HIERARCHY);
element.removeChangeListener(attributeChangeListener,
ChangeQualifier.ATTRIBUTE_VALUE);
element.removeChangeListener(attributeChangeListener,
ChangeQualifier.HIERARCHY);
}
});
}