/** * ************************************************************************* Create the table * columns ************************************************************************ */ protected void createColumns() { for (CodeViewerColumn colModel : CodeViewerColumn.values()) { // Create the TableColumn with right alignment int style = colModel.getAlignment() | SWT.H_SCROLL; GridViewerColumn viewerColumn = new GridViewerColumn(this, style); GridColumn column = viewerColumn.getColumn(); column.setText(colModel.getName()); column.setAlignment(colModel.getAlignment()); column.setWidth(colModel.getInitialWidth()); column.setResizeable(colModel.isResizable()); } }
public void resetColumnWidths() { int totalWidth = 0; for (CodeViewerColumn colModel : CodeViewerColumn.values()) { if (colModel.equals(CodeViewerColumn.CODE)) continue; GridColumn column = getGrid().getColumn(colModel.ordinal()); int width = colModel.getInitialWidth(); totalWidth += width; column.setWidth(width); } int gridWidth = getGrid().getBounds().width; if (getGrid().getVerticalBar().isVisible()) { gridWidth -= getGrid().getVerticalBar().getSize().x; } if (totalWidth < gridWidth) { int widthForCode = gridWidth - totalWidth - 4; getGrid().getColumn(CodeViewerColumn.CODE.ordinal()).setWidth(widthForCode); } }