Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableViewer getTable method problem(table is not availbale to get table items once after user conforms OK.)
TableViewer getTable method problem [message #662605] Thu, 31 March 2011 09:35 Go to next message
Dharam  is currently offline Dharam Friend
Messages: 18
Registered: December 2010
Junior Member
Hi,

This code is from class extending Dialog,

protected Control createDialogArea(Composite parent) {
createViewer(parent);
}

private void createViewer(Composite parent) {
viewer = new TableViewer(parent, SWT...... | ..);
createColumns(parent, viewer);
viewer.setInput(getModel());
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(true);
...
}

private void createColumns(Composite parent, TableViewer viewer) {
....
}

private void printTableRows()
{
TabelItem[] items=viewer.getTable().getItems() ///Problem??

}

As shown in above sample code, it says that viewer.getTable() is disposed & throws SWT Exception.

I can't understand this. Wht can be alternative solution to get all rows later in table once user conforms Dialog.OK?

On getting status OK, I am using getters to get updated data from table.

Thanks
Dharam
Re: TableViewer getTable method problem [message #662618 is a reply to message #662605] Thu, 31 March 2011 10:01 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-03-31 11:35, Dharam wrote:
> Hi,
>
> This code is from class extending Dialog,
>
> protected Control createDialogArea(Composite parent) {
> createViewer(parent);
> }
>
> private void createViewer(Composite parent) {
> viewer = new TableViewer(parent, SWT...... | ..); createColumns(parent,
> viewer);
> viewer.setInput(getModel());
> viewer.getTable().setHeaderVisible(true);
> viewer.getTable().setLinesVisible(true);
> ..
> }
>
> private void createColumns(Composite parent, TableViewer viewer) {
> ...
> }
>
> private void printTableRows()
> {
> TabelItem[] items=viewer.getTable().getItems() ///Problem??
> }
>
> As shown in above sample code, it says that viewer.getTable() is
> disposed & throws SWT Exception.
>
> I can't understand this. Wht can be alternative solution to get all rows
> later in table once user conforms Dialog.OK?
> On getting status OK, I am using getters to get updated data from table.

From your snippet it is not clear, *when* printTableRows() is called as
part of your Dialog life-cycle - providing such elementary information
in error descriptions is crucial.

I assume you are calling the above function after the dialog composites
(and their children) have been disposed, e.g. after closing it. A good
idea is to override okPressed() and to perform your code *before*
invoking the super.okPressed(). At this point you know the user-decision
and you still have all controls available.

HTH & Greetings from Bremen,

Daniel Krügler
Previous Topic:Problems using Editingsupport combined with Drag and Drop
Next Topic:ComboViewer Data Bind
Goto Forum:
  


Current Time: Tue Apr 16 08:26:23 GMT 2024

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

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

Back to the top