nb-codeoutline
nb-codeoutline copied to clipboard
Use NetBeans utilities for font color settings
Hey @markiewb,
Nice plugin, why haven't I seen this before?
:+1:
Do you think it would make sense to add caching from mimetype to AttributeSet
?
Or maybe from mimetype to FontColorSettings
?
the 'Lookup.lookup()` call is the slowest in the few method calls.
Currently I do not care about the performance. A better way than caching would be to add a listener to the settings. Like it is done in standard NB: When you change a color in the option, then it is reflected in the editor after saving the options.
A better way than caching would be to add a listener to the settings.
I agree. Do you know what component we have to listen to for that? EditorSettings seems to be the way to go, but its API is not stable.
Or do you know a better one?
@Shredder121: I do not know a better implementation. But I did not search for others.
I was pleased with the solution I implemented originally. It worked at least [grin]
@Shredder121: Perhaps this is the way? https://github.com/markiewb/nb-codeoutline/blob/0e5a868ec084a0ea426f0191de67f255ca33edeb/src/main/java/de/markiewb/netbeans/plugins/outline/NaviViewExt.java#L51
Yeah, and then register the listener for each MimeType it sees along the way. So if you never opened e.g. a JSON file, we don't need to lookup the color settings for that.
Shall I do that then?
Yes. Try that.
Some remarks:
- Do not add too much listeners. One per mimetype would be enough.
- Unregister the listeners properlz (WeakListeners?)