Skip to content
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

8271315: Redo: Nimbus JTree renderer properties persist across L&F changes #5178

Closed
wants to merge 5 commits into from

Conversation

@prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Aug 19, 2021

This is another attempt of fixing JDK-8249674 which created a regression JDK-8266510 for which it was backed out.
This fix reinstates the UIResource properties for "Tree.leafIcon", "Tree.closedIcon", "Tree.openIcon", "Tree.selectionForeground",
"Tree.textForeground", "Tree.selectionBackground", "Tree.textBackground", "Tree.selectionBorderColor" for NimbusLookAndFeel.

The regression which was "when a JTree node is selected, the text should be painted using the selected text color (white), matching the color of the expansion control. Instead, it is painted using the standard color (black)" is also fixed by this fix, although I could not find any mention of this behaviour in the spec that selected text color should match the expanded icon color
but it's a long standing behaviour, so catered to it.
It was happening because SynthLabelUI#paint when it tries to paint textForeground for cell label, it calls

g.setColor(context.getStyle().getColor(context,
                    ColorType.TEXT_FOREGROUND));

which then calls SynthStyle#getColor where even though cell renderer correctly gets the foreground color, it gets overridden by getColorForState() because the color is a UIResource and there's no corresponding color defined for that state for Tree.CellRenderer so it uses default "black" color for "text" as defined in skin.laf

else if (type == ColorType.TEXT_FOREGROUND) {
                color = c.getForeground();
            }
        }

        if (color == null || color instanceof UIResource) {
            // Then use what we've locally defined
            color = getColorForState(context, type);
        }

Proposed fix is to check if current foregroundColor for DefaultTreeCellRenderer is UIResouce, then use that color itself.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8271315: Redo: Nimbus JTree renderer properties persist across L&F changes

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5178/head:pull/5178
$ git checkout pull/5178

Update a local copy of the PR:
$ git checkout pull/5178
$ git pull https://git.openjdk.java.net/jdk pull/5178/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5178

View PR using the GUI difftool:
$ git pr show -t 5178

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5178.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 19, 2021

👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

Loading

@openjdk openjdk bot added the rfr label Aug 19, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 19, 2021

@prsadhuk The following label will be automatically applied to this pull request:

  • swing

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

Loading

@openjdk openjdk bot added the swing label Aug 19, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Aug 19, 2021

Loading

"Tree.textForeground", "Tree.selectionBackground",
"Tree.textBackground", "Tree.selectionBorderColor"};

private static String failedKeys = null;
Copy link
Member

@aivanov-jdk aivanov-jdk Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary, you initialise it to null before the loop over the properties.

Loading

for (String propertyKey : defPropertyKeys) {
verifyProperty(propertyKey);
}
if(failedKeys != null) {
Copy link
Member

@aivanov-jdk aivanov-jdk Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(failedKeys != null) {
if (failedKeys != null) {

And in other places too, please.

Loading

//Check that the both uiResource option true and false are working for
//getDerivedColor method of NimbusLookAndFeel
Copy link
Member

@aivanov-jdk aivanov-jdk Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Check that the both uiResource option true and false are working for
//getDerivedColor method of NimbusLookAndFeel
// Check that both uiResource options true and false work for
// getDerivedColor method of NimbusLookAndFeel

Loading

failedKeys + " are not instance of UIResource for "
+ LF.getClassName());
}
} catch(UnsupportedLookAndFeelException e) {
Copy link
Member

@aivanov-jdk aivanov-jdk Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch(UnsupportedLookAndFeelException e) {
} catch (UnsupportedLookAndFeelException e) {

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Aug 23, 2021

@prsadhuk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8271315: Redo: Nimbus JTree renderer properties persist across L&F changes

Reviewed-by: aivanov

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 88 new commits pushed to the master branch:

  • 0f428ca: 8272570: C2: crash in PhaseCFG::global_code_motion
  • b17b821: 8272639: jpackaged applications using microphone on mac
  • 0e7288f: 8267125: AES Galois CounterMode (GCM) interleaved implementation using AVX512 + VAES instructions
  • 6ace805: 8272856: DoubleFlagWithIntegerValue uses G1GC-only flag
  • c547ead: 8272916: Copyright year was modified unintentionally in jlink.properties and ImagePluginStack.java
  • aaedac6: 8265261: java/nio/file/Files/InterruptCopy.java fails with java.lang.RuntimeException: Copy was not interrupted
  • d34f17c: 8270195: Add missing links between methods of JavaFX properties
  • f608e81: 8264322: Generate CDS archive when creating custom JDK image
  • f681d65: 8272806: [macOS] "Apple AWT Internal Exception" when input method is changed
  • 6e0328f: 8272725: G1: add documentation on needs_remset_update_t vs bool
  • ... and 78 more: https://git.openjdk.java.net/jdk/compare/36e2ddad4d2ef3ce27475af6244d0246a8315c0c...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

Loading

@openjdk openjdk bot added the ready label Aug 23, 2021
@mrserb
Copy link
Member

@mrserb mrserb commented Aug 25, 2021

I suggest checking that this new test catches the missed JDK-8266510 regression, and improve it if necessary.

Loading

@prsadhuk
Copy link
Contributor Author

@prsadhuk prsadhuk commented Aug 25, 2021

I tried creating automated test for that but not able to..I can create manual test but sInce it is easily seen in SwingSet2 JTree demo, we can verify that using SwingSet2..

Loading

@mrserb
Copy link
Member

@mrserb mrserb commented Aug 25, 2021

I tried creating automated test for that but not able to..I can create manual test but sInce it is easily seen in SwingSet2 JTree demo, we can verify that using SwingSet2.

I do not think it is so easy reproducible, it was reported externally around nine months after the fix. So it was missed by all our test cycles.

Loading

@prsadhuk
Copy link
Contributor Author

@prsadhuk prsadhuk commented Aug 25, 2021

It is reproducible but since is only color we tend to miss it since there is no rule that it has to be of that color...As I told, I can create manual test if that is what is needed..

Loading

@prsadhuk
Copy link
Contributor Author

@prsadhuk prsadhuk commented Aug 26, 2021

/integrate

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Aug 26, 2021

Going to push as commit e43a907.
Since your change was applied there have been 101 commits pushed to the master branch:

  • 11c9fd8: 8272975: ParallelGC: add documentation to heap memory layout
  • b94fd32: 8272859: Javadoc external links should only have feature version number in URL
  • 9166ba3: 8272973: Incorrect compile command used by TestIllegalArrayCopyBeforeInfiniteLoop
  • 49b2789: 8262751: RenderPipelineState assertion error in J2DDemo
  • a3308af: 8272836: Limit run time for java/lang/invoke/LFCaching tests
  • c4c76e2: 8272811: Document the effects of building with _GNU_SOURCE in os_posix.hpp
  • 673ce7e: 8272873: C2: Inlining should not depend on absolute call site counts
  • 7212561: 8267188: gc/stringdedup/TestStringDeduplicationInterned.java fails with Shenandoah
  • e36cbd8: 8242847: G1 should not clear mark bitmaps with no marks
  • 2ef6871: 8272447: Remove 'native' ranked Mutex
  • ... and 91 more: https://git.openjdk.java.net/jdk/compare/36e2ddad4d2ef3ce27475af6244d0246a8315c0c...master

Your commit was automatically rebased without conflicts.

Loading

@openjdk openjdk bot closed this Aug 26, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Aug 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 26, 2021

@prsadhuk Pushed as commit e43a907.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Loading

@prsadhuk prsadhuk deleted the JDK-8271315 branch Aug 26, 2021
@aivanov-jdk
Copy link
Member

@aivanov-jdk aivanov-jdk commented Aug 26, 2021

It is reproducible but since is only color we tend to miss it since there is no rule that it has to be of that color...As I told, I can create manual test if that is what is needed..

A manual test could be better: this way the issue gets documented. You could reproduce the issue with SwingSet2 but you have to look for it and remember what to do.

Loading

@aivanov-jdk
Copy link
Member

@aivanov-jdk aivanov-jdk commented Aug 26, 2021

I see you've added the manual test. Great!

Loading

@mrserb
Copy link
Member

@mrserb mrserb commented Aug 26, 2021

I think it was pushed too fast, w/o looking into the new test.

Loading

@aivanov-jdk
Copy link
Member

@aivanov-jdk aivanov-jdk commented Aug 26, 2021

I think it was pushed too fast, w/o looking into the new test.

Yep, it seems so.

I've submitted JDK-8273043 and made the test automatic. I'll create PR after running the test in the CI.

Loading

@aivanov-jdk
Copy link
Member

@aivanov-jdk aivanov-jdk commented Aug 26, 2021

I've submitted JDK-8273043 and made the test automatic. I'll create PR after running the test in the CI.

I've open the PR #5269. Testing is in progress.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants