This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I am currently writing a visual editor for SVG images which are based on XML text. The editor makes it is possible to edit SVG either as xml text or as visual content. To achieve good performance and fast response the DocumentModel is used as internal model of XML file. Sometimes it is necessary to synchronize the model of text document with changes done in the visual content. The existing synchronization algorithm waits for 2secs after last change in the text before synchronization is started. This enforces either painful lags in in application responses or complicated workarounds. For this purpose it would be very nice to have possibility to force synchronization of model without waiting the 2secs interval. Also I need to have information if the model is synchronized with text or not, to decide whether the model update is needed. Thanks.
1) I have add three method to the DocumentModelListener: /** Called when the underlying javax.swing.Document has changed. */ public void sourceChanged(); /** Called when the DocumentModel update has started. */ public void updateStarted(); /** Called when the DocumentModel update has finished. */ public void updateFinished(); which are called by the DocumentModel when necessary. 2) I have added a non-blocking DocumentModel.forceUpdate() method which starts the model update immediately. The client is then supposed to listen on DocumentModelListener.updateFinished() to get know that the model is ready to be read. I am attaching the changes in a diff, please test it and let me know about potential bottlenecks before I take this change to the fast track review. Thanks.
Created attachment 44699 [details] The change diff
The presented solution is probably feasible for my needs, but unfortunately the introduction of new methods to the DocumentModelListener class is not backward compatible and thus breaks contract with other module(s). I have observed problem with XmlFoldManager but there are probably more classes implementing this listener out there. For this reason I could not finish the testing. Anyway I would propose some backward compatible variant of this change, possibly using new listener class containg those three methods. This class could either extend the DocumentListener or can be separate with its own add/remove/fire methods.
Yes,I realized the backw. comp. problem after I post the comment. I'll make it backw. comp. and attach new patch soon. I am sorry for that.
Done, plese use the attached diff and confirm if the changes fulflis your needs. Btw, I have changed the semantic of updateStarted() method and added one more method to the interface. Please read the javadoc.
Created attachment 44808 [details] New diff
I have tested the new variant and it works very well. Please commit it into the CVS trunk after it passes the fast track review (or whatever else the process requires). Thanks for help.
I would like to ask for fasttrack review namely Pavel and Samaresh whether they agree with the change.
I do agree with the change.
Y01 Write a test.
Y01 fixed - new diff attached.
Created attachment 45448 [details] New diff with the unit test
Y02 You should probably increment spec version of your module and annotate new methods and class with @since tag.
Y02 fixed. Changes commited to trunk. Checking in nbproject/project.properties; /cvs/xml/tageditorsupport/nbproject/project.properties,v <-- project.properties new revision: 1.14; previous revision: 1.13 done Checking in test/unit/src/org/netbeans/modules/editor/structure/api/DocumentModelTest.java; /cvs/xml/tageditorsupport/test/unit/src/org/netbeans/modules/editor/structure/api/DocumentModelTest.java,v <-- DocumentModelTest.java new revision: 1.5; previous revision: 1.4 done RCS file: /cvs/xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModelStateListener.java,v done Checking in src/org/netbeans/modules/editor/structure/api/DocumentModelStateListener.java; /cvs/xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModelStateListener.java,v <-- DocumentModelStateListener.java initial revision: 1.1 done Checking in src/org/netbeans/modules/editor/structure/api/DocumentModel.java; /cvs/xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModel.java,v <-- DocumentModel.java new revision: 1.41; previous revision: 1.40 done Checking in arch.xml; /cvs/xml/tageditorsupport/arch.xml,v <-- arch.xml new revision: 1.7; previous revision: 1.6 done
forgot to reassign
fixed