Thank you for the feedback!

The property is being added to Labeled, which happens to be a base class for 
the cells' skins.  The truncated property therefore must work in all the 
subclasses, even those where computePrefWidth is hacked via 
`Properties.DEFER_TO_PARENT_PREF_WIDTH`.

> Second, I would rather want to see if this can be changed without adding some 
> flags which once again will not help application developers that may want to 
> extend something like this.

This is a much more difficult task:  First, it needs a careful discussion on 
which APIs to add, if any (there is a possibility that some people might say 
that no new APIs are needed as one can always create an instance of Text or 
Label and use it to get the sizing).  There might be a need to undo the hacks 
made by the founding father such as `Properties.DEFER_TO_PARENT_PREF_WIDTH`.  I 
would say all this is out of scope for this PR, as it achieves its goal without 
introducing the new APIs.

> IMO, the separation of concern is wrong. A Cell should always give back the 
> prefWidth, other callers should think if they want to use the pref width or 
> the table column width.

Why cells are controls is slightly beyond me, but who am I to ask?  I would say 
there should be one control in this picture, and that is TableView (or any 
other cell-based control) whose job is to size and lay out its various parts.  
The current design is different, and it is out of scope for this PR to change 
the design.

> In order to move this forward, I would like to see only the necessary changes

And that 's exactly what you see here - only the necessary changes (that 
unfortunately include undoing the earlier hacks in cells).

As for tests - I certainly agree, but that would be a manual test.  The 
behavior can be verified with the examples in JDK-8205211, I just felt the 
value of a manual test is rather low.  What I would rather see is an automated 
test that actually verifies the new property behavior down to a pixel.  Any 
ideas how to make one?

-andy

From: Marius Hanl <mariush...@web.de>
Date: Monday, March 11, 2024 at 15:49
To: Daniel Peintner <daniel.peint...@gmail.com>
Cc: Andy Goryachev <andy.goryac...@oracle.com>, openjfx-dev@openjdk.org 
<openjfx-dev@openjdk.org>
Subject: Aw: Re: [External] : Re: Q: Labeled.textTruncated Property (RFE)
I think this can still be implemented for cells without any special handling.
It is rather unexpected that a cell does not give the correct pref width, so we 
need to think about how to improve the current situation.
In my opinion, it should not be the concern of the Cell to give the actual 
width of the column it belongs to, but the pref width, as we would expect.
We need to check where this is called.

-- Marius


Gesendet: Donnerstag, 07. März 2024 um 16:07 Uhr
Von: "Daniel Peintner" <daniel.peint...@gmail.com>
An: "Andy Goryachev" <andy.goryac...@oracle.com>
Cc: "openjfx-dev@openjdk.org" <openjfx-dev@openjdk.org>
Betreff: Re: [External] : Re: Q: Labeled.textTruncated Property (RFE)
Andy, all,

Some comments below:


  1.  Even if it is possible to do the same with public means I think it is 
useful. Anyhow we need to promote the solutions better (e.g., on StackOverflow)

  2.  I tried to achieve what you did in JavaFX core for my use-case, TableView 
cells.

     *   In my real application I tried and failed since the boolean condition 
in 
https://github.com/openjdk/jfx/blob/8a5cb17ed6525b0a218595865ead3e399e3b29dd/modules/javafx.controls/src/main/java/javafx/scene/control/Labeled.java#L838-L841<https://urldefense.com/v3/__https:/github.com/openjdk/jfx/blob/8a5cb17ed6525b0a218595865ead3e399e3b29dd/modules/javafx.controls/src/main/java/javafx/scene/control/Labeled.java*L838-L841__;Iw!!ACWV5N9M2RV99hQ!JoAaduFdFfQdPcSVdkE7oZbkwg6oeCdmWsh0RTvQALlv9ti--OQHFGtHU3gRE_WPiNLBxlX6eVCGufL5rk0kXFjO$>
 always reports false
     *   Hence I tried to create a short self-contained TableView example to 
explore it further, see Gist 
https://gist.github.com/danielpeintner/9b561eb57261e8c5bc608f1346df74cf<https://urldefense.com/v3/__https:/gist.github.com/danielpeintner/9b561eb57261e8c5bc608f1346df74cf__;!!ACWV5N9M2RV99hQ!JoAaduFdFfQdPcSVdkE7oZbkwg6oeCdmWsh0RTvQALlv9ti--OQHFGtHU3gRE_WPiNLBxlX6eVCGufL5rgWNKS4B$>
It still fails :-(
     *   The Email field in the table ideally should report "true" once the 
text entered exceeds the visible view. Somehow it fails... getWidth() and  
prefWidth(-1) always return the same double value. Please try the Gist above to 
confirm.
e.g., edit cell and extend the email text to longer than column width --> 
results in System.out "Table-Email-Cell !isWrapText: 182.0 < 182.0 --> false"
     *   Hence I also added a *normal* MyLabel example which does work as 
intended
Maybe I miss something obvious but TableCells seem to be special Labeled 
instances and behave differently.

Thanks,

-- Daniel

[1] 
https://stackoverflow.com/a/52432862<https://urldefense.com/v3/__https:/stackoverflow.com/a/52432862__;!!ACWV5N9M2RV99hQ!JoAaduFdFfQdPcSVdkE7oZbkwg6oeCdmWsh0RTvQALlv9ti--OQHFGtHU3gRE_WPiNLBxlX6eVCGufL5riJDXXyw$>


On Wed, Mar 6, 2024 at 6:10 PM Andy Goryachev 
<andy.goryac...@oracle.com<mailto:andy.goryac...@oracle.com>> wrote:
Dear Daniel:

Thank you for confirming the need for this enhancement.  Your case is covered 
by this ticket (I included a wrong ticket in my previous message by mistake, 
sorry):

JDK-8327483<https://bugs.openjdk.org/browse/JDK-8327483> TreeView: Allow for 
tooltip when cell text is truncated

My only concern is that this functionality theoretically can be achieved by the 
application code just as easy, since the solution does not use any internal 
APIs, as can be seen here: 
https://github.com/openjdk/jfx/pull/1389<https://urldefense.com/v3/__https:/github.com/openjdk/jfx/pull/1389__;!!ACWV5N9M2RV99hQ!LUwCrjMEKxlGC0k5v9-zO0Axw6TqddmMJM7_6onFdHOLL1eo5MDNu1lVj7grGquhgJdnqXX_eCyA7MGEMNyIivVMcBB9XfY$>

-andy


From: Daniel Peintner 
<daniel.peint...@gmail.com<mailto:daniel.peint...@gmail.com>>
Date: Tuesday, March 5, 2024 at 23:53
To: Andy Goryachev <andy.goryac...@oracle.com<mailto:andy.goryac...@oracle.com>>
Cc: openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org> 
<openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org>>
Subject: [External] : Re: Q: Labeled.textTruncated Property (RFE)
Hi Andy, all,

Thank you for the effort which I very much appreciate.
We have a similar use-case as the one mentioned in JDK-8205211.

We would like to show a Tooltip with the corresponding text once the text is 
shown with ellipsis for a TableCell. The *hacky* solution we are using is 
sketched in [1] and requires us to calculate the width again. Moreover, once 
different fonts come into the game it becomes even more brittle.

Having an easy (easier?) way to detect and observe whether a label is truncated 
is of importance for us and definitely improves the usability of JavaFX.

Thanks,

-- Daniel

[1] 
https://stackoverflow.com/a/52432862<https://urldefense.com/v3/__https:/stackoverflow.com/a/52432862__;!!ACWV5N9M2RV99hQ!LUwCrjMEKxlGC0k5v9-zO0Axw6TqddmMJM7_6onFdHOLL1eo5MDNu1lVj7grGquhgJdnqXX_eCyA7MGEMNyIivVMSbAOrZg$>

On Tue, Mar 5, 2024 at 10:15 PM Andy Goryachev 
<andy.goryac...@oracle.com<mailto:andy.goryac...@oracle.com>> wrote:
Dear colleagues:

Do you think a new property, ReadOnlyBooleanProperty textTruncated, should be 
added to the Labeled control?


On one hand, we do have a couple of tickets in JBS requesting that:


  *   JDK-8091891<https://bugs.openjdk.org/browse/JDK-8091891> TreeView: There 
is no tooltip available on truncated node
  *   JDK-8205211<https://bugs.openjdk.org/browse/JDK-8205211> Ability to show 
Tooltip only when text is shown with ellipsis (...)

On the other hand, this functionality can in theory be implemented at the 
application level, although the number of changes required might be 
uncomfortably large in the case of Tree/TreeTable/TableView.

JBS:

  *   JDK-8092102<https://bugs.openjdk.org/browse/JDK-8092102> Labeled: 
truncated property



Pull Request: 
https://github.com/openjdk/jfx/pull/1389<https://urldefense.com/v3/__https:/github.com/openjdk/jfx/pull/1389__;!!ACWV5N9M2RV99hQ!LUwCrjMEKxlGC0k5v9-zO0Axw6TqddmMJM7_6onFdHOLL1eo5MDNu1lVj7grGquhgJdnqXX_eCyA7MGEMNyIivVMcBB9XfY$>

What do you think?

-andy

Reply via email to