0

I am developing an eclipse plugin containing a multi-page xml editor among other utilits. The number of pages and its content is dependent from the first page which is a text editor. For tabs update I've implemented updateTabs() method. I would like to call it when user does undo or redo operation to keep the GUI synced with the source. Is there a possibility to "listen" to this kind of operations? Which interface does my editor have to implement for this purpose?

greg-449
  • 109,219
  • 232
  • 102
  • 145
Danny Lo
  • 1,553
  • 4
  • 26
  • 48
  • Surely you want to call `updateTabs()` whenever the text editor's content changes? For example when the user types something, deletes, cuts, pastes, etc should the GUI not update then too? When they undo/redo an action, all that's doing is changing the text content too. So that is the event that you want to hook up to. – Jamie Cockburn Jul 03 '14 at 08:18
  • You can use an `IDocumentListener` on the `IDocument` you give to the text editor to listen to all changes made to the text. – greg-449 Jul 03 '14 at 10:12
  • I don't want to update tabs on every textual change. A user may add or remove single characters to the XML code and this will probably cause a lot of erroneous states of the document. These should not be parsed. For that purpose I added a toolbar button and a [hotkey](http://stackoverflow.com/questions/24655122/eclipse-plugin-developement-keyboard-binding-to-an-action-object) to allow user refresh the GUI if he want's to do it. Apart from that the GUI is being automatically refreshed on switching pages. – Danny Lo Jul 10 '14 at 14:32
  • However the issue is over. `org.eclipse.ui.editors.text.TextEditor` removed a dirty state if user undid all operations and the document went to the initial state. That behavior prevented the pages from being refreshed on switching. Using `org.eclipse.wst.sse.ui.StructuredTextEditor` instead resolved the problem as it doesn't remove the dirty state on undoing the changes. – Danny Lo Jul 10 '14 at 14:38

0 Answers0