What is the best way to refresh Custom editors content when a change has occurred in underlying Model ?
If your question does concern EMF (the Eclipse Modeling Framework, which is all about "Model"), then this section from the eclipse help pages could be useful, especially when changes occurring in the underlying Model concern resources (like file).
That means using the EMF MT (EMF Model Transaction), which provides:
- the capability of managing access to an editing domain by multiple reading and writing threads.
- a facility to register and share an editing domain amongst different clients and listeners. Resource set listeners are defined in the transaction layer and are provided with notifications in batches.
As VonC says, not clear exactly what you mean by model. Here's a couple of options.
If you're talking about resource changes, there's an (old, but still useful) article on resource deltas on Eclipse corner that show you the basics.
If you mean changes to the workspace selection (e.g. selection of an item in the package explorer), then check out this article on the selection service.
From debugging the org.eclipse.ui.texteditor.AbstractTextEditor, the update is handled as follows:
protected void handleEditorInputChanged() {
...
final IDocumentProvider provider= getDocumentProvider();
...
if (provider instanceof IDocumentProviderExtension) {
IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
extension.synchronize(input);
Note there is a load of code around this to handle deactivation and reactivation of other event handlers while this is happening. If you are able to extend from the AbstractTextEditor, you might want to do so to avoid having to implement this yourself.