nb-codeoutline icon indicating copy to clipboard operation
nb-codeoutline copied to clipboard

Use NetBeans utilities for font color settings

Open Shredder121 opened this issue 8 years ago • 7 comments

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?

Shredder121 avatar Sep 03 '16 13:09 Shredder121

Or maybe from mimetype to FontColorSettings?

the 'Lookup.lookup()` call is the slowest in the few method calls.

Shredder121 avatar Sep 04 '16 12:09 Shredder121

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.

markiewb avatar Sep 04 '16 12:09 markiewb

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 avatar Sep 05 '16 08:09 Shredder121

@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]

markiewb avatar Sep 09 '16 09:09 markiewb

@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

markiewb avatar Oct 15 '16 09:10 markiewb

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?

Shredder121 avatar Oct 15 '16 09:10 Shredder121

Yes. Try that.

Some remarks:

  • Do not add too much listeners. One per mimetype would be enough.
  • Unregister the listeners properlz (WeakListeners?)

markiewb avatar Oct 15 '16 10:10 markiewb