How to provide the initial checked state for the items of a TableViewer with SWT.CHECK? [message #331712] |
Thu, 18 September 2008 03:41  |
Eclipse User |
|
|
|
Hi,
I tried search any snippets or articles related to this topic, but I have
not found.
Currently, I do an iteration to initialize the check state for each item
after setInput();
public void reloadDataIntoView(){
theTableViewer.setInput(getModel());
for (TableItem item: theTableViewer.getTable().getItems()) {
ModelType data = (ModelType)item.getData();
item.setChecked(data.isChecked());
}
}
But I think, perhaps somebody could tell me there is other better methods to
achieve this purpose.
Thanks!
Best regards,
Yau. K.J.
|
|
|
Re: How to provide the initial checked state for the items of a TableViewer with SWT.CHECK? [message #331713 is a reply to message #331712] |
Thu, 18 September 2008 06:25  |
Eclipse User |
|
|
|
Hi,
There's not API for this though it might make sense. Could you file a
bug against Platform/UI and cc me on the bug.
In the meanwhile you could subclass CheckedTableViewer and overload
protected ViewerRow internalCreateNewRowPart(int style, int rowIndex) {
super.internalCreateNewRowPart(style|SWT.CHECK, rowIndex)
}
This internal API and CheckedTableViewer says you should not subclass
but its the only possibility I currently see without revisiting the
whole table items. Please not that this method is called whenever a new
item is created.
Tom
Yau K.J. schrieb:
> Hi,
>
> I tried search any snippets or articles related to this topic, but I have
> not found.
>
> Currently, I do an iteration to initialize the check state for each item
> after setInput();
>
> public void reloadDataIntoView(){
> theTableViewer.setInput(getModel());
> for (TableItem item: theTableViewer.getTable().getItems()) {
> ModelType data = (ModelType)item.getData();
> item.setChecked(data.isChecked());
> }
> }
>
> But I think, perhaps somebody could tell me there is other better methods to
> achieve this purpose.
> Thanks!
>
> Best regards,
> Yau. K.J.
>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Powered by
FUDForum. Page generated in 0.03004 seconds