Skip to content

8354795: DialogPane show details button wipes out base style class "hyperlink" #1779

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,6 @@
import com.sun.javafx.scene.control.skin.Utils;
import com.sun.javafx.scene.control.skin.resources.ControlResources;
import javafx.beans.DefaultProperty;
import javafx.beans.InvalidationListener;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
Expand Down Expand Up @@ -818,16 +817,15 @@ protected Node createDetailsButton() {
final Hyperlink detailsButton = new Hyperlink();
final String moreText = ControlResources.getString("Dialog.detail.button.more"); //$NON-NLS-1$
final String lessText = ControlResources.getString("Dialog.detail.button.less"); //$NON-NLS-1$
final ObservableList<String> styleClasses = detailsButton.getStyleClass();

InvalidationListener expandedListener = o -> {
final boolean isExpanded = isExpanded();
detailsButton.setText(isExpanded ? lessText : moreText);
detailsButton.getStyleClass().setAll("details-button", (isExpanded ? "less" : "more")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
};
styleClasses.add("details-button"); //$NON-NLS-1$
Copy link
Contributor

Choose a reason for hiding this comment

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

do we use these //$NON-NLS-1$ in jfx?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do not know if we do, as there is also non-public code that I don't have access to. I've kept them as-is to make sure the change is focused and doesn't break anything else.

If I had to guess then probably not, if you can ask around and find out I'll be happy to remove them.

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle Apr 16, 2025

Choose a reason for hiding this comment

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

I'll double check and will let you know tomorrow.

A code search shows that these are only used in 5 classes: ButtonBar, ButtonBarSkin, Dialog, DialogPane, Properties, so chances are it's a digital fossil.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm that we don't use these //$NON-NLS-* comments in javaFX.

<rant>
These comments were invented as a way to solve the localization problem. The problem is real, but the "solution" was exactly the opposite. Instead of marking the strings that don't need to be localized, what should have happened is to mark the string that need to be localized - with the information containing the context!

example:

// verb, as in "execute this test"
String run = "Run";

What I've done with some other projects was

String run = TXT.get("Class.LocalizedResourceID.verb, as in execute this test", "Run");

</rant>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I can remove them.

Copy link
Contributor

Choose a reason for hiding this comment

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

line 822 should be

styleClasses.setAll("details-button");


// we call the listener immediately to ensure the state is correct at start up
expandedListener.invalidated(null);
expandedProperty().addListener(expandedListener);
expandedProperty().subscribe(expanded -> {
styleClasses.remove(expanded ? "more" : "less"); //$NON-NLS-1$ //$NON-NLS-2$
styleClasses.add(expanded ? "less" : "more"); //$NON-NLS-1$ //$NON-NLS-2$
detailsButton.setText(expanded ? lessText : moreText);
});

detailsButton.setOnAction(ae -> setExpanded(!isExpanded()));
return detailsButton;
Expand Down