Eclipse Plugin Central

Plugin Design - Switching from TableViewer to TreeViewer at running time

gamby - Dec 13, 2007 - 09:38 AM
Post subject: Switching from TableViewer to TreeViewer at running time
Hi all,

I would like to be able to switch (pushing a button for example) from a TableViewer to a TreeViewer and viceversa inside the same View obviously.

In this way I could provide the user with a double way to access data.

I'm able to show both viewer, but I don't able to show ONLY one viewer once

There isn't a method like "removeCurrentViewer()"...

Any hint would be appreciated,
thanks in advance and best regards
Gamby
tlorbeer - Dec 16, 2007 - 06:00 PM
Post subject:
Hi,

1. set your viewer to null
2. dispose the underlying control
3. create the new control on same parent
4. create the new viewer

Thomas
gamby - Jan 09, 2008 - 11:24 AM
Post subject:
Quote:

1. set your viewer to null
2. dispose the underlying control
3. create the new control on same parent
4. create the new viewer


Hi, thanks....but I have already followed that "pattern"...

My doubts are about the content, which is unique and it is set one time to table viewer and on time to tree viewer.

But, when I dispose a control, also the content input is destroyed...and so, to preserve it, I clone it then dispose the control...

However, I'm able only to switch the first time from table to tree, then, switching to table again, I don't see the content...

Any hint?
Thanks in advance.
Best regards.
Raffaele
Andrea_Casarella - Apr 07, 2008 - 06:39 PM
Post subject: Switching from TableViewer to TreeViewer
Sorry but I had the same problem but although the suggestion I cannot manage this view transition.

I create a method
ClassTableViewer.this.changeView();

where I create a new instance of a TableTreeViewer but I can't see any result.

Java snipped:
Control control = viewer.getControl();
control.setParent(parent);
// viewer is an instance of a TableViewer which is already shown
viewer = null;
control.dispose();

ttv = new TableTreeViewer(control.getParent());
ttv.getTableTree().setLayoutData(new GridData(GridData.FILL_BOTH));
// Set up the table
Table table = ttv.getTableTree().getTable();
new TableColumn(table, SWT.LEFT).setText("Package");
new TableColumn(table, SWT.LEFT).setText("Classes");
new TableColumn(table, SWT.RIGHT).setText("YADDA");
new TableColumn(table, SWT.RIGHT).setText("LOREM");
new TableColumn(table, SWT.RIGHT).setText("IPSUM");

// Expand everything
ttv.expandAll();

// Pack the columns
for (int i = 0, n = table.getColumnCount(); i < n; i++) {
table.getColumn(i).pack();
}

// Turn on the header and the lines
table.setHeaderVisible(true);
table.setLinesVisible(true);

}
Can anyone help me!!
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits