2009年5月14日星期四

Eclipse's CheckboxCellEditor

项目中需要把表格中的某列用checkbox表示出来,按照《eclipse从入门到精通》中的步骤没有弄出来。
这是eclipse celleditor的一些samples: http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet009CellEditors

TableViewerColumn TableColumn的区别?
TableViewerColumn .getColumn() 返回的是TableColumn对象。什么时候该用哪个呢?

尝试,ComboBoxCellEditor, 发现EditingSupport子类的getValue()需要返回Integer类型。CheckboxCellEditor则需要返回Boolean类型。
跟踪到CheckboxCellEditor的
protected Control createControl(Composite parent) {
return null;
},发现它根本没有实现。所以,CheckboxCellEditor是根本不能使用的。需要你继承它来完成这个方法。真是奇怪eclipse为什么不提供个实现呢?

最后发现了一个类似于CheckboxCellEditor的实现BooleanCellEditor: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/BooleanCellEditor.java?view=markup 但是,BooleanCellEditor需要运行在eclipse3.4。

没有评论:

发表评论