@Override public void controlResized(ControlEvent e) { int restWidth = 0; for (CodeViewerColumn col : CodeViewerColumn.values()) { if (col.equals(column)) continue; restWidth += grid.getColumn(col.ordinal()).getWidth(); } if (grid.getVerticalBar().isVisible()) { restWidth += grid.getVerticalBar().getSize().x; } int totalWidth = grid.getBounds().width; grid.getColumn(column.ordinal()).setWidth(totalWidth - restWidth - 4); }
public void setModel(IProcedure input) { Logger.debug("Set model", Level.GUI, this); m_input = input; m_renderers = new SourceRenderer[5]; m_renderers[0] = new BpRenderer(input); m_renderers[1] = new LineRenderer(input); m_renderers[2] = new SourceRenderer(input); m_renderers[3] = new DataRenderer(input); m_renderers[4] = new StatusRenderer(input); for (CodeViewerColumn col : CodeViewerColumn.values()) { getGrid().getColumn(col.ordinal()).setCellRenderer(m_renderers[col.ordinal()]); } input.getExecutionManager().addListener(this); applyItemHeight(); super.setInput(input); showLastLine(); }
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); } }
/** * ************************************************************************* 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()); } }