final PreferenceStore p = PreferenceLoader.getPreferenceStore();  for (int i = 0; i < columnIDs.length(); i++) { final int columnIndex = i; final int arrayItem = columnIDs.charAt(i) - 65;  TableColumn tableColumn = new TableColumn(table, COLUMN_ALIGNMENT[ arrayItem ]); p.setDefault(COLUMN_LABELS[ arrayItem ], COLUMN_DEFAULT_WIDTHS[ arrayItem ]); tableColumn.setText(G2GuiResources.getString(COLUMN_LABELS[ arrayItem ])); tableColumn.setWidth(p.getInt(COLUMN_LABELS[ arrayItem ]));  tableColumn.addDisposeListener(new DisposeListener() { public synchronized void widgetDisposed(DisposeEvent e) { TableColumn thisColumn = (TableColumn) e.widget;  if (!manualDispose) { p.setValue(COLUMN_LABELS[ arrayItem ], thisColumn.getWidth()); } } });  tableColumn.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { tableTreeSorter.setColumnIndex(columnIndex); tableTreeViewer.refresh(); } }); }
super.createColumns();
    public void createColumns() {        TableColumn[] tableColumns = tableTreeViewer.getTableTree().getTable().getColumns();        // The SWT TableColumn DisposeEvent.widget returns a width of 0 when manually disposing        manualDispose = true;        for (int i = tableColumns.length - 1; i > -1; i--) {            tableColumns[ i ].dispose();        }        manualDispose = false;        if (advancedMode) {            String prefCols = PreferenceLoader.loadString("downloadTableColumns");            if (GTableViewer.validColumnIDs(prefCols, ALL_COLUMNS)) {                columnIDs = prefCols;            } else {                columnIDs = ALL_COLUMNS;                PreferenceStore p = PreferenceLoader.getPreferenceStore();                p.setValue("downloadTableColumns", columnIDs);            }        } else {            columnIDs = BASIC_COLUMNS;        }        tableTreeViewer.setColumnIDs(columnIDs);        tableTreeViewer.setColumnProperties(COLUMN_LABELS);        table.setHeaderVisible(true);        if (cellEditors != null) {            for (int i = 0; i < cellEditors.length; i++) {                if (cellEditors[ i ] != null) {                    cellEditors[ i ].dispose();                }            }            cellEditors = null;        }        if (columnIDs.indexOf(NAME_COLUMN) > 0) {            cellEditors = new CellEditor[ columnIDs.length() ];            cellEditors[ columnIDs.indexOf(NAME_COLUMN) ] = new TextCellEditor(table);        }        final PreferenceStore p = PreferenceLoader.getPreferenceStore();        for (int i = 0; i < columnIDs.length(); i++) {            final int columnIndex = i;            final int arrayItem = columnIDs.charAt(i) - 65;            TableColumn tableColumn = new TableColumn(table, COLUMN_ALIGNMENT[ arrayItem ]);            p.setDefault(COLUMN_LABELS[ arrayItem ], COLUMN_DEFAULT_WIDTHS[ arrayItem ]);            tableColumn.setText(G2GuiResources.getString(COLUMN_LABELS[ arrayItem ]));            tableColumn.setWidth(p.getInt(COLUMN_LABELS[ arrayItem ]));            tableColumn.addDisposeListener(new DisposeListener() {                    public synchronized void widgetDisposed(DisposeEvent e) {                        TableColumn thisColumn = (TableColumn) e.widget;                        if (!manualDispose) {                            p.setValue(COLUMN_LABELS[ arrayItem ], thisColumn.getWidth());                        }                    }                });            tableColumn.addListener(SWT.Selection,                new Listener() {                    public void handleEvent(Event e) {                        tableTreeSorter.setColumnIndex(columnIndex);                        tableTreeViewer.refresh();                    }                });        }    }