Skip to main content



      Home
Home » Newcomers » Newcomers » CheckboxCellEditor displays strings?
CheckboxCellEditor displays strings? [message #195855] Fri, 23 February 2007 14:25 Go to next message
Eclipse UserFriend
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 #195927 is a reply to message #195855] Sat, 24 February 2007 08:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

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
Re: CheckboxCellEditor displays strings? [message #195952 is a reply to message #195927] Sat, 24 February 2007 11:22 Go to previous message
Eclipse UserFriend
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
Previous Topic:HTTP Status 503 - Servlet org.eclipse.help.internal.webapp.jsp.index_jsp
Next Topic:how to move a project to new directory?
Goto Forum:
  


Current Time: Thu Jun 05 16:56:46 EDT 2025

Powered by FUDForum. Page generated in 0.08097 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top