Reputation: 553
What is the best way to refresh Custom editors content when a change has occurred in underlying Model ?
Upvotes: 4
Views: 1766
Reputation: 84028
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.
Upvotes: 2
Reputation: 1323303
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:
Upvotes: 0