PDA

View Full Version : [OPEN] [FNR] ColorPalette surprise



ddanny
15 Sep 2010, 12:46 AM
I have a place in my app, where the user can select different colors. I used a ColorMenu for that, which encapsulates a ColorPalette. I used to set the customer preferred colors like this: menu.getColorPalette().setColors();

I was setting 30 colors and this used to work with gxt 2.1.2.

Now, with the new gxt 2.2, it looks like it is not working anymore. Looking at the ColorPalette code, I was surprised to see that the new ColorPalette is hard-coded to use exactly 40 colors displayed in a 5 (rows) * 8 (columns) matrix. See the code below...



Grid grid = new Grid(5, 8);
grid.getElement().setAttribute("role", "presentation");
grid.setCellPadding(0);
grid.setCellSpacing(0);
int mark = 0;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 8; j++) {
String c = colors[mark];
grid.setHTML(i, j, "<a aria-label=" + c + " id=" + XDOM.getUniqueId() + " role=gridcell row=" + i + " col=" + j + " class=\"color-" + c
+ "\"><em role=presentation><span role=presentation style=\"background:#" + c + "\" unselectable=\"on\">&#160;</span></em></a>");
mark++;
}
}


So I think I have 2 options:
1. Set exactly 40 colors.
2. Use the ColorPalette default colors.

Any other solutions to make the old code still work?

sven
15 Sep 2010, 1:00 AM
I will fix the code so also more or less nodes will work without an exception.