Support for color selection in a cell ? [message #1066746] |
Thu, 04 July 2013 04:27  |
Eclipse User |
|
|
|
Hello,
We are currently using JFace TableViewers in some places in our application. We were thinking of replacing it with a NatTable control to see whether some of the "issues" that we are experiencing can be solved with NatTable.
However, we need to be able to select colors, similar as the JFace ColorCellEditor is providing.
Does NatTable provide such a feature ? I've been browsing through the API doc and saw that there's no support for color cell editors. However, there is ColorPicker class, so I don't if this can be used in any way within a cell ?
Thank you,
Cédric
|
|
|
|
Re: Support for color selection in a cell ? [message #1067044 is a reply to message #1066749] |
Fri, 05 July 2013 11:08   |
Eclipse User |
|
|
|
Hi Dirk,
Thanks for the useful help. I'm almost done with this, this was in fact easier than expected. I am able to show the color dialog on click and I am also able to fill the background color with a custom cell painter.
However, I'm now stuck with a small problem: in the AbstractDialogCellEditor class, the RGB color returned by my editor is converted to a string because of this code:
@Override
public Object getCanonicalValue(IEditErrorHandler conversionErrorHandler) {
Object canonicalValue;
try {
if (this.displayConverter != null) {
//always do the conversion to check for valid entered data
canonicalValue = this.displayConverter.displayToCanonicalValue(
this.layerCell, this.configRegistry, getEditorValue());
} else {
canonicalValue = getEditorValue();
}
//if the conversion succeeded, remove error rendering if exists
conversionErrorHandler.removeError(this);
} catch (ConversionFailedException e) {
// conversion failed
conversionErrorHandler.displayError(this, e);
throw e;
} catch (Exception e) {
// conversion failed
conversionErrorHandler.displayError(this, e);
throw new ConversionFailedException(e.getMessage(), e);
}
return canonicalValue;
}
The displayConverter is a DefaultDisplayConverter. Looking at the code, if this displayConverter would be null, this would solve my problem (the getEditorValue() method returns the RGB object).
I tried to attach a null display converter in my edit configuration but that doesn't work:
configRegistry.registerConfigAttribute(
CellConfigAttributes.DISPLAY_CONVERTER, null, DisplayMode.EDIT,
COLOR_FIELD_NAME);
How can I correct that ?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03718 seconds