在Eclipse RCP应用程序中,在Ubuntu 12.04 LTS上,我使用带有两列和TableViewer
样式的VIRTUAL
来显示大量数据(Records appox.500000)。
在Windows上,此数据加载速度非常快,而在Ubuntu上则需要更多时间。以下是代码 -
tvEq = new TableViewer(group_1, SWT.BORDER | SWT.FULL_SELECTION|SWT.VIRTUAL);
table = tvE.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_table.heightHint = 359;
table.setLayoutData(gd_table);
TableViewerColumn tableViewerColumn = new TableViewerColumn(tvE, SWT.NONE,0);
TableColumn tblclmn1 = tableViewerColumn.getColumn();
tblclmn1.setWidth(260);
tblclmn1.setText("Column1 ");
TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tvEq, SWT.NONE,1);
TableColumn tblclmn2 = tableViewerColumn_1.getColumn();
tblclmn2.setWidth(300);
tblclmn2.setText("Column 2");
tvEq.setUseHashlookup(true);
tvE.setContentProvider(new EContProv(tvE));
tvE.setLabelProvider(new EResultLP()); List<ECategory>eq=cvJs.getCombo().getItem(cvJs.getCombo().getSelectionIndex());
tvE.setInput(eq);
tvE.setItemCount(eq.size());
public class EContProv implements ILazyContentProvider {
private TableViewer viewer;
private List<ECategory> elements;
public EContProv(TableViewer viewer) {
this.viewer = viewer;
}
public void dispose() {
}
@SuppressWarnings("unchecked")
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.elements = (List<ECategory>) newInput;
}
public void updateElement(int index) {
viewer.replace(elements.get(index), index);
}
}
public class EQResultLP implements TableLabelProvider,ITableColorProvider,ITableFontProvider {
Color backColor=new Color(Display.getCurrent(),230,255,230);
Font backFont=new Font(Display.getCurrent(),"Tahoma",11, SWT.BOLD);
Font fontP=new Font(Display.getCurrent(),"Tahoma",11, SWT.NORMAL);
@Override
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
backColor.dispose();
backFont.dispose();
fontP.dispose();
}
@Override
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
@Override
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
@Override
public Font getFont(Object element, int columnIndex) {
ECategory cat=(ECategory)element;
if(columnIndex==0 && !cat.getColumn1().trim().equals("")){
return backFont;
}
return fontP;
}
@Override
public Color getForeground(Object element, int columnIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getBackground(Object element, int columnIndex) {
ECategory cat=(ECategory)element;
if(columnIndex==0 && !cat.getColumn1().trim().equals("")){
return backColor;
}
return null;
}
@Override
public Image getColumnImage(Object element, int columnIndex) {
ECategory cat=(ECategory)element;
if(columnIndex==0 && !cat.getColumn1().trim().equals("")){
return null;
}
if(columnIndex==1 && !cat.getColumn2().trim().equals("")){
return null;
}
return null;
}
@Override
public String getColumnText(Object element, int columnIndex) {
ECategory cat=(ECategory)element;
if(columnIndex==0){
return cat.getColumn1();
}
if(columnIndex==1){
return cat.getColumn2();
}
return null;
}
}
请帮帮我......