-
Notifications
You must be signed in to change notification settings - Fork 917
Support to redefine icons for LSP client #3459
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
Support to redefine icons for LSP client #3459
Conversation
ea07e73 to
ae3bade
Compare
ae3bade to
cfddb16
Compare
eirikbakke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting out this digestible PR; looks good. I read over everything, though assuming that the LSP stuff was reviewed before by someone more familiar with that part of the codebase.
See in-code comments... main changes requested was fixing a double equals in a properties file and adding a comment to UIDefaultsIconMetadata to make it clear that it doesn't run during normal IDE execution.
...integration/src/org/netbeans/modules/nbcode/integration/resources/uimanager-icons.properties
Outdated
Show resolved
Hide resolved
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/explorer/TreeItem.java
Show resolved
Hide resolved
...integration/src/org/netbeans/modules/nbcode/integration/resources/uimanager-icons.properties
Show resolved
Hide resolved
...r/nbcode/integration/src/org/netbeans/modules/nbcode/integration/UIDefaultsIconMetadata.java
Outdated
Show resolved
Hide resolved
...r/nbcode/integration/src/org/netbeans/modules/nbcode/integration/UIDefaultsIconMetadata.java
Show resolved
Hide resolved
eirikbakke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
neilcsmith-net
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double check the static initialization logic in ImageUtilities. Then please squash and merge when ready. Will be branching for NB13 later today.
platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
Outdated
Show resolved
Hide resolved
a49f9be to
5791131
Compare
| if (EventQueue.isDispatchThread()) { | ||
| dummyIconComponent = new JLabel(); | ||
| dummyIconComponentLabel = new JLabel(); | ||
| dummyIconComponentButton = new JCheckBox(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're doing a JCheckBox here instead of a JButton, the variable should be called dummyIconComponentCheckBox.
But remind me why we are doing a JCheckBox? I know it extends JButton but unless you know of specific cases that need it, I'd prefer to just have a JButton. Otherwise the hacks start getting too specific, and we'll be afraid to change them in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During development of the UIDefaults replacing code, I used ImageUtilities on real icons served by UIManager (default LaF). Several of them had special implementations that downcast the Component to JCheckbox in their paint(). Having a JCheckbox satisfies more icons than just JButton (there are such icons as well) I tried to choose the class that covered most of the errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, as long as you saw actual cases, that's fine. What do you mean by "using ImageUtilities"; which method(s) specifically? And which LAF was this? (Which OS?) Why haven't these cases come up before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which method(s) specifically
ImageUtilities.icon2Image; that ultimately calls paintIcon() to get the icon rendered to a BufferedImage. OS Linux / KDE, JDK 8+11, default L&F.
Why haven't these cases come up before?
Nobody called icon2Image on those particular UIManager icons ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reasoning is captured fine in the comment above too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's fine with me. Just wondering if these were problems caused due to aggressive manual testing only, or whether they actually occur during real use.
| */ | ||
| public static URL findImageBaseURL(Image image) { | ||
| Object o = image.getProperty(PROPERTY_URL, null); | ||
| return o instanceof URL ? (URL)o : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after ")", if you're doing another round of changes...
neilcsmith-net
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's get it in before branching.
|
@sdedic actually, hold on! Travis CI VSCode test is broken. Lots of logged Coincidence that that's with JCheckbox, or because of previous fix? |
|
@neilcsmith-net ImageUtilities.image2Icon(ImageUtilities.loadImage(resImage)) is suspect in any case, since loadImage can return null and image2Icon does not accept null. |
|
@sdedic I need to proceed with branching. Once available, please rebase this on delivery. |
|
Got it, running tests. Will rebase. |
5791131 to
2fbce60
Compare
|
Seems that when the 1st call to ImageUtilities happened in the EDT (seemed not the case when running as a headless NBLS server or as an IDE, but did in the test), UIDefaultsIconMetadata attempted to call back to stil-not-initialized class |
|
Thanks! See, I knew that would cause a bug somewhere, or that fixing it would. 😆 Bit of a backlog in tests with all the branching and merging today. Please merge when it goes green. |
I reworked the stuff originally in #3414 to a state hopefully acceptable for NB13 before freeze/branching. Overview
Openide changes
PROPERTY_URLin API + implementation bugfixesLSP / VSCode changes
ImageUtilities.loadImages converted to icons for keys that are actually present. Replacement table is in a resource file. Stub image is replicated at build time, and mapped to images not mapped explicitly (just listed).