public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// remove our listeners to the old state
if (oldInput != null) {
Document domDoc = (Document) oldInput;
ModelQuery mq = ModelQueryUtil.getModelQuery(domDoc);
if (mq != null) {
documentManager = mq.getCMDocumentManager();
if (documentManager != null) {
documentManager.removeListener(this);
}
}
}
if ((oldInput != null) && (oldInput instanceof IDOMNode)) {
IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IDOMNode) oldInput).getModel().getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
if (factory != null) {
factory.removeListener(viewer);
}
}
if (viewer instanceof StructuredViewer) {
fViewer = null;
}
else {
fViewer = (StructuredViewer) viewer;
}
if ((newInput != null) && (newInput instanceof IDOMNode)) {
IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IDOMNode) newInput).getModel().getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
if (factory != null) {
factory.addListener(viewer);
}
}
if (newInput != null) {
Document domDoc = (Document) newInput;
ModelQuery mq = ModelQueryUtil.getModelQuery(domDoc);
if (mq != null) {
documentManager = mq.getCMDocumentManager();
if (documentManager != null) {
documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
documentManager.addListener(this);
}
}