Source:
private void createConfigureColumnsAction(Menu parent) { new MenuItem(parent, SWT.SEPARATOR); final MenuItem configureColumns = new MenuItem(parent, SWT.PUSH); configureColumns.setText(Messages.ConfigurableColumnTableViewerSupport_Configure_Columns); configureColumns.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { TableColumnDescriptor[] colDesc = new TableColumnDescriptor[columnDescriptors.length]; for (int i = colDesc.length - 1; i >= 0; --i) { TableColumnDescriptor p = columnDescriptors[i]; if (p != null) { colDesc[i] = new TableColumnDescriptor(p); } } final TableColumnDescriptorDialog selectionDialog = new TableColumnDescriptorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), colDesc); selectionDialog.create(); int resultCode = selectionDialog.open(); if (resultCode == Window.OK) { TableColumnDescriptor[] colDesc1 = selectionDialog.getColumnDescriptors(); for (int i = 0; i < colDesc1.length; i++) { TableColumnDescriptor tableColumnDescriptors = colDesc1[i]; TableColumnDescriptor orgTableColumnDescriptors = columnDescriptors[i]; if (!orgTableColumnDescriptors.equals(tableColumnDescriptors)) { TableColumn tableColumn = viewer.getTable().getColumn(i); if (orgTableColumnDescriptors.getAlignment() != tableColumnDescriptors.getAlignment()) { orgTableColumnDescriptors.setAlignment(tableColumnDescriptors.getAlignment()); tableColumn.setAlignment(tableColumnDescriptors.getAlignment()); } if (orgTableColumnDescriptors.getWidths() != tableColumnDescriptors.getWidths()) { orgTableColumnDescriptors.setWidths(tableColumnDescriptors.getWidths()); tableColumn.setWidth(tableColumnDescriptors.getWidths()); } if (orgTableColumnDescriptors.isDefaultSortColumn() != tableColumnDescriptors .isDefaultSortColumn()) { orgTableColumnDescriptors .setDefaultSortColumn(tableColumnDescriptors.isDefaultSortColumn()); } if (orgTableColumnDescriptors.isAutoSize() != tableColumnDescriptors.isAutoSize()) { orgTableColumnDescriptors.setAutoSize(tableColumnDescriptors.isAutoSize()); } if (orgTableColumnDescriptors.getSortDirection() != tableColumnDescriptors .getSortDirection()) { orgTableColumnDescriptors.setSortDirection(tableColumnDescriptors.getSortDirection()); } } } viewer.refresh(); } } }); }

Target:
private void createConfigureColumnsAction(Menu parent) { new MenuItem(parent, SWT.SEPARATOR); MenuItem configureColumns = new MenuItem(parent, SWT.PUSH); configureColumns.setText(Messages.ConfigurableColumnTableViewerSupport_Configure_Columns); configureColumns.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableColumnDescriptor[] tempColumnDescriptors = new TableColumnDescriptor[columnDescriptors.length]; for (int i = tempColumnDescriptors.length - 1; i >= 0; --i) { tempColumnDescriptors[i] = new TableColumnDescriptor(columnDescriptors[i]); } final TableColumnDescriptorDialog selectionDialog = new TableColumnDescriptorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), tempColumnDescriptors); selectionDialog.create(); int resultCode = selectionDialog.open(); if (resultCode == Window.OK) { for (int i = 0; i < tempColumnDescriptors.length; i++) { TableColumnDescriptor tempTableColumnDescriptor = tempColumnDescriptors[i]; TableColumnDescriptor orgTableColumnDescriptor = columnDescriptors[i]; if (!orgTableColumnDescriptor.equals(tempTableColumnDescriptor)) { TableColumn tableColumn = viewer.getTable().getColumn(i); orgTableColumnDescriptor.setAlignment(tempTableColumnDescriptor.getAlignment()); tableColumn.setAlignment(tempTableColumnDescriptor.getAlignment()); orgTableColumnDescriptor.setWidths(tempTableColumnDescriptor.getWidth()); tableColumn.setWidth(tempTableColumnDescriptor.getWidth()); orgTableColumnDescriptor.setSortDirection(tempTableColumnDescriptor.getSortDirection()); orgTableColumnDescriptor .setDefaultSortColumn(tempTableColumnDescriptor.isDefaultSortColumn()); if (tempTableColumnDescriptor.isDefaultSortColumn()) { viewer.getTable().setSortColumn(tableColumn); viewer.getTable().setSortDirection(tempTableColumnDescriptor.getSortDirection()); } orgTableColumnDescriptor.setAutoSize(tempTableColumnDescriptor.isAutoSize()); } } } } }); }