mysql - How to create dynamic columns with values with TableViewer Jface -
i need create dynamic columnas in 1 tableviewer, in eclipse rcp application.
the idea need create 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 create dynamic columns.
//recuperar crossing block del grupo (int i=0; < 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 database create columns each record.
the problem need retrieve data set in te column. need id of column n , row i, query database.
any idea? best regards
hi, approach right now. create classwith arraylist of columns:
class grilla { private bloquecruzamiento bc_x; private arraylist<bloquecruzamiento> bc_list_y; private boolean selected; } and 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 how populate arraylist:
list<grilla> cbsarrayl = new arraylist<grilla>() ; grilla grid = new grilla(); (bloquecruzamiento cb : cbs) { grid.bc_x = cb; grid.bc_list_y = new arraylist<bloquecruzamiento>(); grid.selected = false; (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 make each cell editable, under circumstances should not editable. regards again
i assume have 1 java class each of table structures displaying. can hence use java reflection api give headings table viewer columns , display data
edit: see ur code has 70% of needs done. repeating steps additional details sake of understanding
- define java class describing fields in table. include getters , setters fields. if there 'n' different tables create 'n' such classes getters , setters. 1 of classes named
employee - an array list of 1 of above classes become input tableviewer use .use
tableviewer.setinput(emplist) - now implement own label provider. within labelprovider's
getvalue()method should make use of reflection api callgetxxxx()of table field wish show. reference here. reflection nothing introspection api provided java gets details class , it's properties. - you can enable editing creating new class sub-classing
editingsupportclass , adding instance columnviewer'saddeditingsupport()method
remember tableviewer column headers can field names of employee class can got reflection api .
hope clarifies
Comments
Post a Comment