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.
javax.swing.text.Document supports properties, but there is no way how to listen on changes in those properties.
Created attachment 94414 [details] The API changes The API changes in editor.util and the implementation in editor.lib.
Please review this simple API change. Thanks
The patch is fine, thanks Vita!
Y01 There does not seem to be a way to find out whether if listener will ever get an event or is no-op operation. static boolean isPropertyChangeSupported(Document doc) might be a solution. Y02 Why org.openide.text.NbDocument is not more suitable place for this API? It contains a lot of similar utilitie methods. Y03 Static methods in NbDocument usually contain some fallback implementation. I guess there is no way to provide that generally in case of PCL, right?
Y01 Who and for what purpose would use this method? Y02 DocumentUtilities contain more these methods... Well, honestly, I don't have an answer for this. I have always considered openide.text an implementation module, which connects the editor infrastructure with the platform (TopComponents, DataObjects, etc) and not a primary place for developing editor APIs. Y02 No, I think there is not.
Re. Y01: I'd like to avoid code that works only with editor BaseDocument and silently disfunctions on other documents. The isPCL method would give each code a chance to verify whether or not it is going to work. There are of course other ways - throw UnsupportedException. That will guarantee the API user is quite visibly notified.
I'm sorry for the delay. I was distracted by other work. Re. Y01: This check is automatically done in DU.add{remove}DocumentListener() and so the callers don't have to do it explicitly. I don't see any other usecases and so for now I would prefer to go without DU.isPropertyChangeSupported(). After all, it can easily be added in the future.
Thanks for the review. http://hg.netbeans.org/jet-main/rev/3ba8ceb7b6ee