Dynamic tables in a view [message #896284] |
Tue, 17 July 2012 21:03 |
Timothy Vogel Messages: 82 Registered: July 2009 |
Member |
|
|
I can't get a view to behave and I'm hoping you have some suggestions.
Based on a menu choice, I need to display a different table of data in a single view. My approach is to subclass Composite with the correct columns, attributes and data for each table. Based on the value passed from the menu handler to the view, I create an instance of the correct subclass. The issue is the table does not fill the view and when creating the second one, the first still appears.
I have tried various combinations of layouts and computeSize but without success. If I copy the table code into the createPartControl, the appearance is correct but I don't think this will work for dynamically setting the table.
pseudo code
class ReferenceTable extends ViewPart {
createPartControl(Composite parent) {
parent.setLayoutData(new GridLayout();
}
setTable(String tableName) {
if previous table
dispose previous table
compositeTable = new RequestedTable(parent, SWT.NONE);
parent.layout();
}
}
class RequestedTable extends Composite {
public RequestedTable(Composite parent, int style) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new FillLayout());
TableColumnLayout tcl_composite = new TableColumnLayout();
composite.setLayout(tcl_composite);
tableViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
table = tableViewer.getTable();
// create columns in table here
// load data into table
// enable viewer to show data
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(data);
}
}
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03248 seconds