flow-components icon indicating copy to clipboard operation
flow-components copied to clipboard

feat: Implement colors in custom formatting for vaadin-spreadsheet

Open thevaadinman opened this issue 9 months ago • 9 comments
trafficstars

Description

Fixes #6835. Does not introduce new public API. Enables the use of named colors and indexed colors compatible with Excel: black, white, red, green, blue, yellow, magenta, cyan, as well as Color 1-56.

Type of change

  • [x] Feature

Checklist

  • [x] I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • [x] I have added a description following the guideline.
  • [x] The issue is created in the corresponding repository and I have referenced it.
  • [x] I have added tests to ensure my change is effective and works as intended.
  • [x] New and existing tests are passing locally with my change.
  • [x] I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • [x] Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

thevaadinman avatar Feb 25 '25 02:02 thevaadinman

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 25 '25 02:02 CLAassistant

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Feb 25 '25 02:02 CLAassistant

SonarCloud Code Analysis result can be ignored, it's hallucinating and complaining about existing code. Submitted code now looks quite ugly after application of mandatory "beautification" step, which I suggest be dropped or tuned for the future.

thevaadinman avatar Feb 25 '25 12:02 thevaadinman

Looks like I'll have to shim the custom cell formatting bits. This will take a while.

thevaadinman avatar Feb 25 '25 13:02 thevaadinman

There seems to be a hard-to-resolve issue with getting the reworked CellFormatPart class to load reliably. All tests thus far have worked locally, but something seems very different on the CI cluster.

thevaadinman avatar Feb 26 '25 15:02 thevaadinman

This set of changes adds a field called textColor to CellData and modifies the client side code to propagate the value of that field to where it needs to go, so that the CSS color attribute can be set when needed. That field gets set by CustomDataFormatter, which uses the POI CellFormat class to interpret the format string and extract the assigned color value.

In order to properly support the indexed colors used by Excel and Google Sheets, the class org.apache.poi.ss.format.CellFormatPart was modified to properly identify and map the color values. This was sufficient to achieve color support in testing, but when run on the CI cluster, the overloaded class was not picked up correctly, and necessitated renaming the customized version of the class to VCellFormatPart and including a large chunk of POI code modified to point to that class, while remaining compatible with the rest of POI in use.

In addition to the functional changes and tests, the root POM was modified in order to allow turning the formatter off and on as needed, and to ignore POI code.

This does create the potential to make future POI upgrades more difficult until the corrected functionality of the CellFormatPart class has been successfully submitted to Apache POI upstream, after which the V-prefixed POI classes can be removed and the main code returned to compatibility with mainline.

thevaadinman avatar Mar 19 '25 16:03 thevaadinman

Appeasing SonarCloud Code Analysis is beyond the scope of this feature.

thevaadinman avatar Mar 19 '25 18:03 thevaadinman

Added change to transmit color as a string of six hex digits instead of rgb(nnn,nnn,nnn) for marginal space savings. The original spec suggested the creation of a more open text-color-to-stylename mapper which would map text color to CSS values, but at this time I remain unconvinced that there would be any practical benefit to adding such a structure, while it would certainly increase the complexity of the code and consequently make it more resistant to maintenance, and potentially introduce style specificity related issues. I remain open to arguments in favor of such a feature.

thevaadinman avatar Mar 24 '25 13:03 thevaadinman

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

sonarqubecloud[bot] avatar Apr 10 '25 12:04 sonarqubecloud[bot]

Closing in favour of component factory release.

yuriy-fix avatar Apr 15 '25 11:04 yuriy-fix