I need to create dynamic columnas in one TableViewer, in an eclipse RCP Application.
The idea is that I need to create a cross table.
Column 0 | Column 1| Column 2| Column 3| Column n
=================================================
Data 0,0 | Data 0,1| Data 0,2| Data 0,3| Data 0,n
Data 1,0 | Data 1,1| Data 1,2| Data 1,3| Data 1,n
Data 2,0 | Data 2,1| Data 2,2| Data 2,3| Data 2,n
Data 3,0 | Data 3,1| Data 3,2| Data 3,3| Data 3,n
I'm using this to create dynamic columns.
//Recuperar Crossing Block del Grupo
for (int i=0; i < cbsCombinado.size(); i++) {
tableViewerColumn = new TableViewerColumn(this.tableCombinadoViewer, SWT.NONE);
tblclmnParcela = tableViewerColumn.getColumn();
tblclmnParcela.setWidth(100);
tblclmnParcela.setText( cbsCombinado.get(i).getNroParcela().toString());
tblclmnParcela.setData(cbsCombinado.get(i)); //Asigno el Participante.
};
So i'm reading records from database an create a columns with each record.
The problem is that I need to retrieve the data that I set in te column. I need to get the Id of column n and row i, to query a Database.
Any idea? Best Regards
Hi, my approach is this right now. create a classwith an ArrayList of columns:
class Grilla {
private BloqueCruzamiento bc_x;
private ArrayList<BloqueCruzamiento> bc_list_y;
private Boolean selected;
}
and the ContentProvider:
class BloqueCruzaCombContentProvider implements IStructuredContentProvider {
public void dispose() {
// TODO Auto-generated method stub
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// TODO Auto-generated method stub
}
@SuppressWarnings("unchecked")
public Object[] getElements(Object obj) {
ArrayList<Grilla> grid = (ArrayList<Grilla>) obj;
return grid.toArray();
}
}
And this is how I populate the ArrayList:
List<Grilla> cbsArrayL = new ArrayList<Grilla>() ;
Grilla grid = new Grilla();
for (BloqueCruzamiento cb : cbs) {
grid.bc_x = cb;
grid.bc_list_y = new ArrayList<BloqueCruzamiento>();
grid.selected = false;
for (BloqueCruzamiento ccb : cbsCombinado)
{
grid.bc_list_y.add(ccb);
}
cbsArrayL.add(grid);
grid = new Grilla();
}
tableCombinadoViewer.setContentProvider(new BloqueCruzaCombContentProvider());
tableCombinadoViewer.setLabelProvider(new BloqueCruzaCombLabelProvider());
if (cbs!=null) tableCombinadoViewer.setInput(cbsArrayL);
My goal now is to make each CELL editable, but under some circumstances the should NOT be editable. Regards Again