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.

Bug 181073 - Allow listening on document property changes
Summary: Allow listening on document property changes
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: PC All
: P3 normal (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2010-02-23 03:19 UTC by Vitezslav Stejskal
Modified: 2010-03-09 06:53 UTC (History)
0 users

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
The API changes (9.34 KB, patch)
2010-02-23 03:25 UTC, Vitezslav Stejskal
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vitezslav Stejskal 2010-02-23 03:19:58 UTC
javax.swing.text.Document supports properties, but there is no way how to listen on changes in those properties.
Comment 1 Vitezslav Stejskal 2010-02-23 03:25:47 UTC
Created attachment 94414 [details]
The API changes

The API changes in editor.util and the implementation in editor.lib.
Comment 2 Vitezslav Stejskal 2010-02-23 03:26:39 UTC
Please review this simple API change. Thanks
Comment 3 Miloslav Metelka 2010-02-23 04:48:15 UTC
The patch is fine, thanks Vita!
Comment 4 Jaroslav Tulach 2010-02-23 07:52:59 UTC
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?
Comment 5 Vitezslav Stejskal 2010-02-23 08:14:26 UTC
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.
Comment 6 Jaroslav Tulach 2010-02-23 09:13:09 UTC
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.
Comment 7 Vitezslav Stejskal 2010-03-08 08:30:50 UTC
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.
Comment 8 Vitezslav Stejskal 2010-03-09 06:53:37 UTC
Thanks for the review. http://hg.netbeans.org/jet-main/rev/3ba8ceb7b6ee