-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix text monitor tests #8714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix text monitor tests #8714
Conversation
- use diamond notation <> to remove redundant type specification - do no cache listeners, because it makes the code heavier for a a very small gain in memory usage. - removed redundant "this" keywords
Your proposed changes add the mousewheel and key listeners to more than just the component that contains the zoomable text. I think that's not desired. Regarding the design choice of replacing the constructor Base argument by adding the listeners outside of the class:
This allows for the Base class to be passed, but the text monitors not to depend on it (but rather on a more simple interface), without requireing classes that use the text monitors to call additional methods. What are your thoughts on this @cmaglie? |
@cmaglie Regarding usage of
The only downside of adding I would like to hear your thoughts on this as well, since not using |
Hi @Pieter12345, sorry for the long delay
why not? in the end it's an AbstractTextMoniror! intuitively I expect this to work exactly this way (unless there is a more robust way to add a listener to all child components?)
IMHO the "mousewheel-zoom" behaviour should not be part of AbstractTextMonitor, to me seems that this is more like a "shortcut" (exactly as the "CTRL +" or "CTRL -") that is added from the caller side, exactly as we do with the other shortcuts.
For solving this particular issue (removing dep from Base) IMHO it's not worth it. It may be worth it if we could make it handle all the aspects of text zooming in particular also in the @Override
public void applyPreferences() {
// Apply font.
Font consoleFont = Theme.getFont("console.font");
Font editorFont = PreferencesData.getFont("editor.font");
textArea.setFont(Theme.scale(new Font(
consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize()))); but, again, it's worth it? in my opinion at this point in time probably not, if we see that this starts to get ubiquitous we may think a refactor like you suggested. |
/cc @Pieter12345 this is something along the line on what I though about here #8704 (comment)
I've also removed the caching of the listeners because I found that it makes the code a lot less readable for a very small gain in this case.
Also I removed the use of
this
, again, I found it very redundant but, @Pieter12345 I see that you use it often maybe you have some arguments in his favor?