Community
Participate
Working Groups
Build Identifier: 1.7.2.v20110903-1845 If table constructed by TableViewer has many columns (~ 400) and column.pack() is called on each column, header & data cells are not drawn correctly after table has been scrolled fast in horizontal direction (either data or header cell does not show its content before moving mouse over it). Additionally, header cells get misaligned with data cells. This can be related to previous error – column size information might be not available while column.pack() call leading to wrong calculation. Reproducible: Always Steps to Reproduce: 1. Execute following code: ========================= snippet begin ========================== /* * Copyright 2006-2009 Opensys TM by Javlin, a.s. All rights reserved. * Opensys TM by Javlin PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * Opensys TM by Javlin a.s.; Kremencova 18; Prague; Czech Republic * www.cloveretl.com; info@cloveretl.com * */ package swt.tableviewer.test; import java.awt.Dimension; import java.awt.Toolkit; import java.util.LinkedHashSet; import java.util.Random; import java.util.Set; import org.eclipse.jface.layout.TableColumnLayout; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; /** * @author "Michal Oprendek" (info@cloveretl.com) * (c) Javlin, a.s. (www.cloveretl.com) * * @created 17.1.2012 */ public class WideTableViewerTest extends ApplicationWindow { /** * Generates random data for the table * * @author "Michal Oprendek" (info@cloveretl.com) * (c) Javlin, a.s. (www.cloveretl.com) * * @created 18.1.2012 */ private static class DataSource { private static final int NUMBER_OF_COLUMNS = 400; private static final int CELL_MIN_SIZE = 20; private static final int CELL_MAX_SIZE = 60; private String[] data; private String[] headers; private Random random = new Random(); DataSource() { data = new String[NUMBER_OF_COLUMNS]; headers = new String[NUMBER_OF_COLUMNS]; for (int i = 0; i < NUMBER_OF_COLUMNS; i++) { headers[i] = generateRandomString(); data[i] = generateRandomString(); } } private String generateRandomString() { StringBuilder sb = new StringBuilder(); int length = random.nextInt(CELL_MAX_SIZE - CELL_MIN_SIZE) + CELL_MIN_SIZE; for (int j = 0; j < length; j++) { sb.append((char) ('A' + random.nextInt(26))); } return sb.toString(); } } private class TableLabelProvider extends LabelProvider implements ITableLabelProvider { public Image getColumnImage(Object element, int columnIndex) { return null; } public String getColumnText(Object element, int columnIndex) { return dataSource.data[columnIndex]; } } private static class ContentProvider implements IStructuredContentProvider { public Object[] getElements(Object inputElement) { if (inputElement instanceof String[][]) { return ((String[][]) inputElement); } else { throw new IllegalArgumentException("String[][] expected, " + inputElement.getClass() + " got"); } } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } private Table table; private TableViewer tableViewer; private final DataSource dataSource = new DataSource(); /** * Create the application window, */ public WideTableViewerTest() { super(null); setShellStyle(SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.RESIZE); } /** * Create contents of the application window. * * @param parent */ @Override protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, false)); // Create the composite Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // Add TableColumnLayout TableColumnLayout layout = new TableColumnLayout(); composite.setLayout(layout); tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION); table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); Set<TableColumn> columns = new LinkedHashSet<TableColumn>(); for (String header : dataSource.headers) { TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn tblclmnFirst = tableViewerColumn.getColumn(); columns.add(tblclmnFirst); layout.setColumnData(tblclmnFirst, new ColumnWeightData(2, ColumnWeightData.MINIMUM_WIDTH, true)); tblclmnFirst.setText(header); } tableViewer.setLabelProvider(new TableLabelProvider()); tableViewer.setContentProvider(new ContentProvider()); String[][] lines = new String[1][]; lines[0] = dataSource.data; tableViewer.setInput(lines); for (TableColumn tc : columns) { tc.pack(); } return container; } /** * Launch the application. * * @param args */ public static void main(String args[]) { try { WideTableViewerTest window = new WideTableViewerTest(); window.setBlockOnOpen(true); window.open(); Display.getCurrent().dispose(); } catch (Exception e) { e.printStackTrace(); } } /** * Configure the shell. * * @param newShell */ @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Wide Table Viewer Test"); } /** * Return the initial size of the window. */ @Override protected Point getInitialSize() { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); return new Point(dim.width, dim.height); } } ========================= snippet end ============================ 2. Scroll fast in horizontal direction to the second almost to the end Expected: 1. Whole content is properly displayed 2. Header cells are aligned with relative data cells Seen: 1. Some (sometimes header, sometime data) cells get their content only after e. g. moving mouse over them 2. Data cell boundaries are not directly aligned with corresponding header cells
Hello, has anyone triaged this bug? I think it does have sufficient information in it to proceed. Thank you!
Sorry for the delay. This is a known limitation in SysListView32. The header cannot be wider than 32K pixels. There is nothing SWT can do to fix this. *** This bug has been marked as a duplicate of bug 79980 ***