Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] [from e.tools] how to set a checkbox on any Table column?

First, please excuse 2 sins in advance:

* my asking this question in a list instead of eclipse.tools: this
  question has spawned at least 2 threads (not both from me :-) in the
  newsgroup, neither of which has (IMO) been usefully answered. Note
  that I will cheerfully serialize a useful answer to the Eclipse Wiki
  or other location, as well as e.tools.

* my asking both of platform-{swt, ui}-dev: I'm not sure if this
  question involves only SWT, or only JFace, or both, and I'm unsure
  to which list to make JFace queries.

The question is: how can one create a Table so that every cell in any
specified column(s), not merely the first, displays a checkbox?

Note the column caveat: I have made a Table with checkboxes in the
first column by using the Table ctor, as demonstrated by

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/snippits/snippet113.html

(Also note, just to prove that I'm not a shirker, that I have
documented at

http://eclipsewiki.swiki.net/2583

how to run a snippet, from either the workbench or the commandline.)
However my UI would be more appropriate (and my boss happier :-) if
the checkboxes were in the 3rd column. Both I and another newsgrouper
have tried to do this in what appears to be "the obvious way": just
iterate over the columns, and put a CheckboxCellEditor on the desired
column, e.g.

  cellEditors[0] = new TextCellEditor(table);
  cellEditors[1] = new TextCellEditor(table);
  cellEditors[2] = new CheckboxCellEditor(table);

The texts work, but no checkbox displays. Interestingly, one observes
(again, not just me) a "checkbox-style" interaction. If one put
(boolean) data on a cell in the 3rd column, it displays as text. If
one then clicks on a cell in the 3rd column, the strings toggle
("false" <-> "true"), and don't become editable.

So 

* Is this a CheckboxCellEditor bug?

- If so, I'll report to bugzilla. Meanwhile, is there a workaround?

* If not, what am I doing wrong?

* Could someone post a snippet that shows how to display a (working)
  checkbox in a Table column other than the first?



Back to the top