CheckboxCellEditor displays strings? [message #195855] |
Fri, 23 February 2007 14:25  |
Eclipse User |
|
|
|
Hi,
I'm using a CheckboxCellEditor within a tableViewer.
The problem is that it displays strings "true" and "false" instead of a
checkbox.
Any suggestions?
Thanks
Charlie
|
|
|
|
Re: CheckboxCellEditor displays strings? [message #195952 is a reply to message #195927] |
Sat, 24 February 2007 11:22  |
Eclipse User |
|
|
|
Hi Wayne,
I'm using a TableViewer and an ICellModifier; I don't want to implement
a custom control.
I'm posting a solution here that might help other people.
I create a CellEditor[] with instantiation of CheckboxCellEditor and
pass it to the TableViewer
I cache the TableViewer instance in the the constructor of the class
that implements ICellModifier, and toggle the field in the modify (...)
method.
Calling tableViewer.refresh() forces the LabelProvider to update a
String representation of the field in the table.
Charlie
//////////////////////////////////////////////////////////// ////////////////
public void modify(Object element, String property, Object value)
{
if (! (element instanceof TableItem) )
return;
TableItem tableItem = (TableItem) element;
Object object = tableItem.getData();
if (! (object instanceof DownloadableObjectInfo) )
return;
DownloadableObjectInfo downloadableObjectInfo =
(DownloadableObjectInfo) object;
//////////////////////////////////////////////////////////// ////////
if
(property.equalsIgnoreCase(MailListDownloadLabelProvider.DOW NLOAD_FLAG_COLUMN_TEXT)
)
{
if (downloadableObjectInfo.isDownloadFlag())
downloadableObjectInfo.setDownloadFlag(false);
else
downloadableObjectInfo.setDownloadFlag(true);
if (null != tableViewer) // overkill, we checked in the Contructor
tableViewer.refresh();
}// if
(property.equalsIgnoreCase(MailListDownloadLabelProvider.DOW NLOAD_FLAG_COLUMN_TEXT)
)
if
(property.equalsIgnoreCase(MailListDownloadLabelProvider.DEL ETE_FLAG_COLUMN_TEXT)
)
{
if (downloadableObjectInfo.isDeleteFlag())
downloadableObjectInfo.setDeleteFlag(false);
else
downloadableObjectInfo.setDeleteFlag(true);
if (null != tableViewer) // overkill, we checked in the Contructor
tableViewer.refresh();
}// if
(property.equalsIgnoreCase(MailListDownloadLabelProvider.DEL ETE_FLAG_COLUMN_TEXT)
)
}// public void modify(Object element, String property, Object value)
//////////////////////////////////////////////////////////// ////////////////
}// public class MailListDownloadCellModifier implements ICellModifier
Wayne Beaton wrote:
> Charlie Kelly wrote:
>> Hi,
>>
>> I'm using a CheckboxCellEditor within a tableViewer.
>> The problem is that it displays strings "true" and "false" instead of
>> a checkbox.
>>
>> Any suggestions?
>>
>> Thanks
>>
>> Charlie
>
> You'll have to add a paint listener to the table and draw the cell
> yourself.
>
> There's examples on how to do this in the SWT Snippets
> (http://www.eclipse.org/swt/snippets).
>
> Wayne
|
|
|
Powered by
FUDForum. Page generated in 0.08097 seconds