I have a problem with removing the columns from a TableViewer. I have an RCP app that has an IViewPart. The ViewPart is listening for the partClosed event from a specific editor. When that happens, the part needs to clear it's TableViewer and show a blank 1 column table.

However, it doesn't seem to be working and I have two issues:

1. if I grab the TableColumn array from the table (viewer.getTable().getColumns() ) and I iterate over that array going forward (form 0 to the end), I get an IndexOutOfBoundsException on the second index(1) even though I know the array is 4. Oddly, if I iterate backwards, it can traverse all 4 columns without issue (i.e., starting with index 3 and going to 0).
2. However, it never deletes the first column's data. The header is wiped out, but the data remains.

Has anyone ever seen this and if so how did they resolve it? I can't seem to figure out why I can't iterate from 0 to n but I can go from n to 0. That suggests I've done something odd or weird.