Eclipse: update editor

What is the best way to update the content of custom editors when changing in the base model?

+4
source share
2 answers

As VonC says, it's unclear what you mean by model. Here are a few options.

If you're talking about resource changes, there is a (old, but still useful) article on the deltas resource in the Eclipse corner that shows you the basics.

If you mean changes in the choice of the workspace (for example, the choice of an item in the package explorer), check out this article in the selection service .

Debugging org.eclipse.ui.texteditor.AbstractTextEditor, the update is processed as follows:

protected void handleEditorInputChanged() { ... final IDocumentProvider provider= getDocumentProvider(); ... if (provider instanceof IDocumentProviderExtension) { IDocumentProviderExtension extension= (IDocumentProviderExtension) provider; extension.synchronize(input); 

Note that in all of this there is code loading to handle the deactivation and reactivation of other event handlers during this process. If you can expand from AbstractTextEditor, you can do this to avoid having to implement it yourself.

+2
source

If your question is about EMF ( Eclipse Modeling Framework , as regards the "Model"), then this section of the eclipse man pages can be useful, especially when the changes that occur in the base model relate to resources (for example, a file).

This means using EMF MT ( EMF Model Transaction ), which provides:

  • the ability to control access to the editing domain with multiple read and write streams.
  • a means of registering and sharing an editing domain among different clients and listeners. Resource set listeners are defined at the transaction level and are provided with packet notifications.
0
source

All Articles