Krokodylowy
Krokodylowy

Reputation: 620

Updating model behind the editor when file has been refreshed

I am writing multi-tab editor for Eclipse. This plug-in has several tabs and the last one is the text source - something similar to the plugin.xml editor in PDE.

There is some model behind it which is used to show some information in tabs which are base on the data in the text source. User may edit source and when he/she switches to another tab the model is updated. That works fine.

The problem is when someone edits source file in an external editor. Then refresh project and the model should be also refreshed. But how can I achieve this?

I tried to use addResourceChangeListener, it notifies my with pre-refresh events, but it doesn't contain information if my file is going to be updated (e.g. only project resource if someone tried to refresh the whole project).

Other idea I had was to add document listener when a pre-refresh event comes and to remove it in the post-change handler. However here the problem is that if file hasn't changed and hasn't been updated no post-change event is sent, so I stay with unnecessary document listener which will be informed about all edits done by user in the last (source) tab.

I will appreciate any help.

Upvotes: 0

Views: 291

Answers (1)

nitind
nitind

Reputation: 20003

A Refresh, when it finds changed files, will report them as having been changed. You probably mean to listen to the POST_CHANGE notification as shown at http://www.eclipse.org/articles/Article-Resource-deltas/resource-deltas.html .

Upvotes: 1

Related Questions