Skip to content

Added refreshCells method #135

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 5 commits into
base: master
Choose a base branch
from
Open

Added refreshCells method #135

wants to merge 5 commits into from

Conversation

Jugen
Copy link
Contributor

@Jugen Jugen commented Aug 13, 2025

This adds the ability to refresh a Cell without updating it's item. This is needed in situations where the context the item is in changes the way it is displayed, without the item itself changing.

@Symeon94
Copy link

The changes seem fine, but I have to say that I don't understand what situation you are tackling with this one. The index is needed only when we create them item isn't it ? And if that is not the case, normally the update on the LiveList should change the item itself (as shown by the UT for the LiveList).

Could you give a case where this would be broken?

@Jugen
Copy link
Contributor Author

Jugen commented Aug 13, 2025

I'm thinking of the following use case in RichTextFX when using setVisibleOnlyStyler:

Say you have a code editor and for comment blocks you have one colour and for JavaDoc you have another. When the developer changes the first line of the comment block to a JavaDoc then that line will automatically get restyled as it has changed. However the following lines of the comment will not be restyled unless a change of some sort occurs on them. There are two options here:

  1. Change the styling on the succeeding lines with something like codeArea.setStyle( p, List.of("JavaDoc") ), or
  2. Invoke a new public method codeArea.refreshParagraph( p ) which will call virtualFlow.refreshCell( p ) here.

In both cases above the visible only styler will be invoked and which you use is dependent on your circumstances.
If for example your document has imbedded styling that you don't want to mess with then the 2nd option is available.

@Symeon94
Copy link

Ok. My only comment (but maybe that will come with your changes in RichTextFX) is that maybe we should test via a UT that it does refresh the paragraph with the appropriate index number (for instance, instead of modifying line i you replace two lines by an open group comment /* which should change style to all following paragraph but changing their index at the same time).

Aside from this little proposal, your in better position than me to assess the validity of your change (I confess that I have not touch my style code for a few weeks, I'm waiting for your change to fix the style update issue).

@Jugen Jugen changed the title Added refreshCell method Added refreshCells method Aug 14, 2025
Copy link

@Symeon94 Symeon94 left a comment

Choose a reason for hiding this comment

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

Overall it's much better now (I still don't see UT though).
I think the exception if fromItem >= toItem might be a bit radical (but feel free to ignore my comment).

*/
public void refreshCells(int fromItem, int toItem) {
int start = Math.min( fromItem, toItem );
int end = Math.max( fromItem, toItem );
if (fromItem >= toItem) throw new IllegalArgumentException(

Choose a reason for hiding this comment

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

That is radical, there is no harm simply not doing anything in that case.

Choose a reason for hiding this comment

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

Adding a small note, in any case the fromItem < toItem will cover that case, so you could simply remove your exception and it would work fine.

@Jugen
Copy link
Contributor Author

Jugen commented Aug 15, 2025

Added another UT, if you think there are other cases that should be checked please let me know.

@Symeon94
Copy link

Thanks for taking the time to do that. I listed them previously:

  • fromItem == toItem
  • fromItem > toItem
  • min > start
  • max < end
  • min == start
  • max == end
  • min < start
  • max > end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants