Deletion of TableColumns [message #451103] |
Wed, 23 February 2005 01:26  |
Eclipse User |
|
|
|
Hi,
I am using Eclipse 3.0.1. I am supposed to present some statistical
info in a Table. Based on the user input, the result table may change in
no. of Columns and rows. So when the user selected any cell or row header
or column header, accordingly i need to display diffenrent set of rows and
columns. For that, i have to delete the existing Columns and create the
new set of Columns.
First Time, when i created the table, it shows the contents. But after
getting a user request, when i redraw the table, the cell content is not
visible. I need a better way to delete the existing Columns. I have
included the source snipplet. Can anyone suggest me a better way to solve
this.
public class TestSummariserTable extends Composite{
Table tblSales;
TableViewer viewer;
Composite cmpSalesTable;
public TestSummariserTable(Composite arg0, int arg1) {
super(arg0, arg1);
cmpSalesTable = new Composite(this, SWT.NONE);
createTblSales();
cmpSalesTable.setLayout(new FillLayout());
}
private void createTblSales() {
tblSales = new Table(cmpSalesTable, SWT.NONE);
tblSales.setVisible(true);
tblSales.setLinesVisible(true);
tblSales.setHeaderVisible(true);
processTblSales();
}
private void processTblSales() {
createColumns();
viewer = new TableViewer(tblSales);
viewer.setContentProvider(new SalesDashboardContentProvider());
viewer.setLabelProvider(new SalesDashboardLabelProvider());
viewer.setInput("");
viewer.refresh();
addListener();
}
private void addListener() {
tblSales.addListener (SWT.MouseDown, new Listener () {
public void handleEvent (Event event) {
if (true)//Cell Selected
{
cmpSalesTable = null;
//Here , i need to some solution to drop the
existing Columns
createTblSales();
}
else if (true)//Row Header Selected
{
cmpSalesTable = null;
createTblSales();
}
else{
//if Column Header Selected
cmpSalesTable = null;
createTblSales();
}
}
});
}
private void createColumns() {
//Based On the User input, No. of Columns to be created varies
}
}
|
|
|
|
|
Re: Deletion of TableColumns [message #451139 is a reply to message #451123] |
Thu, 24 February 2005 06:09  |
Eclipse User |
|
|
|
Thanks For the reply.
It works well.
Steve Northover wrote:
> You don't need the clearAll().
> "melko" <melko@gmx.at> wrote in message news:cvhtn4$84j$1@www.eclipse.org...
>> try this:
>>
>> public static void renewTable(Table table){
>> TableColumn tblCol[] = table.getColumns();
>> int iSize = tblCol.length;
>> for(int i = iSize - 1; i >=0 ; i--)
>> tblCol[i].dispose();
>> table.clearAll();
>> table.removeAll();
>> }
>>
>> I hope I could help you!!
>>
>> take care.
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03863 seconds