Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to provide the initial checked state for the items of a TableViewer with SWT.CHECK?
How to provide the initial checked state for the items of a TableViewer with SWT.CHECK? [message #331712] Thu, 18 September 2008 03:41 Go to next message
yau is currently offline yauFriend
Messages: 14
Registered: July 2009
Junior Member
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 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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
------------------------------------------------------------ --------
Previous Topic:Re: how to get out of "NLS unused message" in log file
Next Topic:Hyperlinks don't go away
Goto Forum:
  


Current Time: Sat Jul 27 16:47:28 GMT 2024

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

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

Back to the top