| Summary: | [GTK] TableColumn#pack does not work for virtual table | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Samantha Chan <chanskw> | ||||
| Component: | SWT | Assignee: | Xi Yan <xixiyan> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | arunkumar.thondapu, eclipse, ericwill, lufimtse, niraj.modi, xixiyan | ||||
| Version: | 3.2 | Keywords: | triaged | ||||
| Target Milestone: | 4.9 M2 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux-GTK | ||||||
| See Also: |
https://git.eclipse.org/r/124620 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ebc68f80d66ed176ef3bb5409964b9c502d19556 https://git.eclipse.org/r/126031 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=110467fbdd4dac0efc1995fef03b4ab92d527232 |
||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 131184 | ||||||
| Attachments: |
|
||||||
This is intentional. In order for pack to work, it would need to send a SetData event for every row in the column. This does not make sense for a virtual table. The idea of the virtual table is that there are a large number of rows and it is too expensive to set the text and image for all the rows. The text and image are only requested as required (made visible etc). Pack needs to figure out which cell is widest by examinign the width of the text and image for every row. Closing this bug report as wont fix. You should use TableColumn.setWidth() for virtual tables. On Windows and Motif, pack actually works. The size seems to be calculated based on what's being displayed. This is different on Linux GTK. When calling pack, it does nothing. When running the same testcae, pressing the button will pack the columns on windows and motif, but not on Linux GTK. Please reconsider this bug if possible. Veronika - I am just trying this out again. If I place my mouse at the column header and double click right on the border. The columns would resize to the preferred size. Why is it that we cannot do this programatically via #pack? It's never mentioned in the javadoc that this would not work with virtual tables. I am not sure that using #setWidth to work around this is the right way to go. As a client, I do not think we should write our own code to simulate the #pack behaviour. And I don't think we can do it more efficiently than doing it in the swt layer. Thanks... Samantha Not sure if you got my previous comments. Re-opening for comments. Thanks... Samantha OSX has the same behaviour Samantha, I have not forgotten this bug - I just need to find some time to get to work on it. Hi Veronika - Just wondering if there is any chance of getting this fixed for 3.2? Let me know if there is anything else I can do to help with this. Thanks... Samantha In RC1, I fixed pack for virtual table on GTK and Mac OS X (already worked for Windows and Motif). The only reason I haven't closed this bug yet is because I am working on implementing the same sort for TreeColumn. Clearing milestone since this bug is still open. Bogdan to see whether Veronika fixed this for Tree as well. Still missing the the TreeColumn code in RC4. This bug is still reproducible, not sure how important it is though. Tossing it back into the pool. Moving to 4.8. Moving to 4.9, please re-target as required. New Gerrit change created: https://git.eclipse.org/r/124620 Gerrit change https://git.eclipse.org/r/124620 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ebc68f80d66ed176ef3bb5409964b9c502d19556 (In reply to Eclipse Genie from comment #16) > Gerrit change https://git.eclipse.org/r/124620 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=ebc68f80d66ed176ef3bb5409964b9c502d19556 In master now. Thanks for the patch Xi! *** Bug 531875 has been marked as a duplicate of this bug. *** The latest changes cause an NPE when invoking pack on a virtual table. Attached you'll find a snippet to reproduce. Created attachment 274967 [details]
Sample to reproduce the NPE
New Gerrit change created: https://git.eclipse.org/r/126031 Gerrit change https://git.eclipse.org/r/126031 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=110467fbdd4dac0efc1995fef03b4ab92d527232 (In reply to Eclipse Genie from comment #22) > Gerrit change https://git.eclipse.org/r/126031 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=110467fbdd4dac0efc1995fef03b4ab92d527232 Patch is in master, thanks for catching that Thomas. |
I am using a virtual table, packing the columns after data is populated in the table has no effect on Linux GTK. If the table is defined as non-virtual, TableColumn#pack works as expected. /* * Testcase to demonstrate problem with Table not * being able to pack columns for virtual tables */ public class TestTableBug { private static TableColumn column1; private static TableColumn column2; private static TableColumn column3; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.VIRTUAL); final TableCursor cursor = new TableCursor(table, SWT.NONE); table.setLayoutData(new GridData(GridData.FILL_BOTH)); column1 = new TableColumn(table, SWT.NONE); column1.setText("A"); column2 = new TableColumn(table, SWT.NONE); column1.setText("B"); column3 = new TableColumn(table, SWT.NONE); column1.setText("C"); for (int i = 0; i < 500; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"}); } // These have no effects on Linux GTK? column1.pack(); column2.pack(); column3.pack(); Button action = new Button(shell, SWT.PUSH); action.setText("Pack Columns"); action.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { // These have no effects on Linux GTK? column1.pack(); column2.pack(); column3.pack(); } public void widgetDefaultSelected(SelectionEvent e) { }}); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }