Bug 551999 - TableEditor doesn't move with cell
Summary: TableEditor doesn't move with cell
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.14   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-10 06:35 EDT by Thomas Wolf CLA
Modified: 2019-10-10 09:12 EDT (History)
1 user (show)

See Also:


Attachments
Modified Snippet126 with extra column to remove items (3.51 KB, text/plain)
2019-10-10 06:35 EDT, Thomas Wolf CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wolf CLA 2019-10-10 06:35:28 EDT
Created attachment 280224 [details]
Modified Snippet126 with extra column to remove items

TableEditors don't move correctly when a TableItem is removed. Run the attached Snippet126. It adds a fourth column (for simplicity's sake I've used checkboxes again). When that checkbox is selected, the corresponding TableItem is removed.

Note that the TableEditors don't move; an empty line is shown.

Root cause is that the editors don't get any event when an item is removed since the table doesn't fire any.

One work-around is shown in the commented-out lines: forcing a resize event makes the editors re-position. But that's a hack.
Comment 1 Eric Williams CLA 2019-10-10 09:00:19 EDT
I was just reading bug 514359 the other day but couldn't think of a concrete answer at the time.

Does this happen on Linux only? What does it the behaviour look like on Mac?
Comment 2 Thomas Wolf CLA 2019-10-10 09:12:50 EDT
No, all platforms show the same behavior. As I wrote, the underlying problem is that there's no notification on item removal. So there's nothing a TableEditor could listen to. It does listen to a variety of events (either in TableEditor or in ControlEditor), one of them being SWT.Resize on the table, which is why the work-around works.

Another work-around might be to keep a collection of all editors and call layout() on all of them. But that's even worse than the "briefly change the size" hack. Ideally Table would fire an event, and then editors could listen to it and re-layout themselves. (I guess similar problems exist if one adds a new table item between existing items, or if there's dynamic sorting of items.)