Paints the column headings for the given table.

@param table the table to paint the headings for.
@param renderContext the RenderContext to paint to.
340934
private void paintColumnHeadings(final WTable table, final WebXmlRenderContext renderContext) {
		XmlStringBuilder xml = renderContext.getWriter();
		int[] columnOrder = table.getColumnOrder();
		TableModel model = table.getTableModel();
		final int columnCount = columnOrder == null ? table.getColumnCount() : columnOrder.length;

		xml.appendTagOpen("ui:thead");
		xml.appendOptionalAttribute("hidden", !table.isShowColumnHeaders(), "true");
		xml.appendClose();

		for (int i = 0; i < columnCount; i++) {
			int colIndex = columnOrder == null ? i : columnOrder[i];
			WTableColumn col = table.getColumn(colIndex);

			if (col.isVisible()) {
				boolean sortable = model.isSortable(colIndex);
				paintColumnHeading(col, sortable, renderContext);
			}
		}

		xml.appendEndTag("ui:thead");
	}
1222084
public void addJKTableColumn(final JKTableColumn col) {
		col.setIndex(this.tableColumns.size());
		this.tableColumns.add(col);
		this.visibilityManager.refreshVisibility();
		fireTableStructureChanged();
	}
103092
@Override
	protected void afterPaint(final RenderContext renderContext) {
		super.afterPaint(renderContext);

		if (this.isPressed() && renderContext instanceof WebXmlRenderContext) {
			PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();

			StringBuffer temp = dumpAll();
			writer.println("<br/><br/>");
			writer.println(temp);
		}
	}
360760
private void doPaintRows(final WTable table, final WebXmlRenderContext renderContext) {
		TableRepeater repeater = table.getRepeater();

		WComponent row = repeater.getRepeatedComponent();

		List<RowIdWrapper> wrappers = repeater.getBeanList();

		Set<?> otherSelectedRows = new HashSet<>(table.getSelectedRows());

		int index = -1;
		for (RowIdWrapper wrapper : wrappers) {
			index++;

			Object rowKey = wrapper.getRowKey();

			if (table.getSelectedRows().contains(rowKey)) {
				otherSelectedRows.remove(rowKey);
			}

			// Only rendering top level rows
			// Child rows handled by the layout, so dont paint the row
			if (wrapper.getParent() != null) {
				continue;
			}

			// Each row has its own context. This is why we can reuse the same
			// WComponent instance for each row.
			UIContext rowContext = repeater.getRowContext(wrapper, index);

			UIContextHolder.pushContext(rowContext);

			try {
				row.paint(renderContext);
			} finally {
				UIContextHolder.popContext();
			}
		}
		this.selectedOnOther = otherSelectedRows.size();
	}
1088256
public void buildTable(Table table, List<T> beans) {

        BeanItemContainer<T> container = new BeanItemContainer<T>(m_class);
        List<String> visibleCols = Lists.newArrayList();
        for (ColumnBean column : m_columns) {
            String propName = column.getProperty().getName();
            String columnHeader = column.getInfo().header();
            String localizedHeader = CmsVaadinUtils.getMessageText(columnHeader);
            if (CmsMessages.isUnknownKey(localizedHeader)) {
                localizedHeader = columnHeader;
            }
            localizedHeader = m_macroResolver.resolveMacros(localizedHeader);
            table.setColumnHeader(propName, localizedHeader);
            if (Button.class.isAssignableFrom(column.getProperty().getPropertyType())) {
                table.setColumnAlignment(propName, Align.CENTER);
            }
            visibleCols.add(propName);
        }
        table.setContainerDataSource(container);
        table.setVisibleColumns(visibleCols.toArray());

        for (ColumnBean column : m_columns) {
            Column info = column.getInfo();
            String name = column.getProperty().getName();
            if (info.width() >= 0) {
                table.setColumnWidth(name, info.width());
            }
            if (info.expandRatio() >= 0) {
                table.setColumnExpandRatio(name, info.expandRatio());
            }
        }
        for (T bean : beans) {
            container.addBean(bean);
        }

    }
744659
private void resolveTableColumns(Table table) {
        HsqlList set = new HsqlArrayList();
        collectAllColumnExpressions(set);
        for (int i = 0; i < set.size(); i++) {
            ExpressionColumn array_element = (ExpressionColumn)set.get(i);
            ColumnSchema column = table.getColumn(table.getColumnIndex(array_element.getAlias()));
            array_element.setAttributesAsColumn(column, false);

        }
    }
166537
private void applyTableSettings(final WTable table) {
		table.setSelectMode(rbsSelect.getSelected());

		table.setSelectAllMode(rbsSelectAll.getSelected());
		table.setExpandMode(rbsExpand.getSelected());
		table.setSortMode(rbsSorting.getSelected());
		table.setStripingType(rbsStriping.getSelected());
		table.setSeparatorType(rbsSeparator.getSelected());
		table.setShowColumnHeaders(showColHeaders.isSelected());
		table.setExpandAll(expandAll.isSelected());
		table.setEditable(chbEditable.isSelected());
		table.setToggleSubRowSelection(table.getType() == WTable.Type.HIERARCHIC
				&& cbToggleSubRowSelection.isSelected()
				&& rbsExpand.getSelected() != WTable.ExpandMode.NONE
				&& rbsSelect.getSelected() == WTable.SelectMode.MULTIPLE);
		// row headers
		table.setRowHeaders(cbHasRowHeaders.isSelected());
		// Caption
		if (null == tfCaption.getText() || "".equals(tfCaption.getText())) {
			table.setCaption(null);
		} else {
			table.setCaption(tfCaption.getText());
		}

		// Pagination
		table.setPaginationMode(rbsPaging.getSelected());
		if (rbsPaging.getSelected() == PaginationMode.NONE) {
			table.setRowsPerPage(DEFAULT_ROWS_PER_PAGE);
			table.setRowsPerPageOptions(null);
			table.setPaginationLocation(WTable.PaginationLocation.AUTO);
		} else {
			// Options
			table.setRowsPerPageOptions(chbRowsPerPageOptions.isSelected() ? DEFAULT_ROWS_OPTIONS : null);
			// Rows
			int rows;
			if (numRowsPerPage.isEmpty() || numRowsPerPage.getNumber().intValue() < 1) {
				rows = DEFAULT_ROWS_PER_PAGE;
			} else {
				rows = numRowsPerPage.getNumber().intValue();
				if (chbRowsPerPageOptions.isSelected() && !DEFAULT_ROWS_OPTIONS.contains(rows)) {
					rows = DEFAULT_ROWS_PER_PAGE;
					numRowsPerPage.setNumber(rows);
				}
			}
			table.setRowsPerPage(rows);
			table.setPaginationLocation(paginationControlsLocation.getSelected());
		}
		// enable responsive design for phones.
		table.setHtmlClass(cbEnableRespond.isSelected() ? "wc-respond" : "");

		List<COLUMN> cols = (List<COLUMN>) columnOrder.getSelected();
		int[] order = new int[cols.size()];
		int i = 0;
		for (COLUMN col : cols) {
			order[i++] = col.getCol();
		}
		table.setColumnOrder(order);
	}
1163541
private JTable withColRenderers(final JTable table) {
        // Data renderers
        final DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();

        // BigDecimal
        table.setDefaultRenderer(BigDecimal.class, new TableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {

                final BigDecimal bd = (BigDecimal) value;

                return dtcr.getTableCellRendererComponent(table, bd.toString(), isSelected, hasFocus, row, column);
            }
        });

        // Boolean
        table.setDefaultRenderer(Boolean.class, new TableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {

                final Boolean b = (Boolean) value;

                return dtcr.getTableCellRendererComponent(table, Boolean.toString(b), isSelected, hasFocus, row, column);
            }
        });

        // Date
        table.setDefaultRenderer(java.sql.Date.class, new TableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {

                final java.sql.Date d = (java.sql.Date) value;

                return dtcr.getTableCellRendererComponent(table, String.format("%tF", d), isSelected, hasFocus, row, column);
            }
        });

        // Time
        table.setDefaultRenderer(Time.class, new TableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {

                final Time t = (Time) value;

                return dtcr.getTableCellRendererComponent(table, String.format("%tr", t), isSelected, hasFocus, row, column);
            }
        });

        // Timestamp
        table.setDefaultRenderer(Timestamp.class, new TableCellRenderer() {
            public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {

                final Time t = (Time) value;

                return dtcr.getTableCellRendererComponent(table, String.format("%tr", t), isSelected, hasFocus, row, column);
            }
        });

        return table;
    }
1040093
public void setColumnCellStyles (int column, String... styles)
    {
        int rowCount = getRowCount();
        for (int row = 0; row < rowCount; ++row) {
            setStyleNames(row, column, styles);
        }
    }
195149
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WDecoratedLabel label = (WDecoratedLabel) component;
		XmlStringBuilder xml = renderContext.getWriter();
		WComponent head = label.getHead();
		WComponent body = label.getBody();
		WComponent tail = label.getTail();

		xml.appendTagOpen("ui:decoratedlabel");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", label.isHidden(), "true");
		xml.appendClose();

		if (head != null && head.isVisible()) {
			xml.appendTagOpen("ui:labelhead");
			xml.appendAttribute("id", label.getId() + "-head");
			xml.appendClose();
			head.paint(renderContext);
			xml.appendEndTag("ui:labelhead");
		}

		xml.appendTagOpen("ui:labelbody");
		xml.appendAttribute("id", label.getId() + "-body");
		xml.appendClose();
		body.paint(renderContext);
		xml.appendEndTag("ui:labelbody");

		if (tail != null && tail.isVisible()) {
			xml.appendTagOpen("ui:labeltail");
			xml.appendAttribute("id", label.getId() + "-tail");
			xml.appendClose();
			tail.paint(renderContext);
			xml.appendEndTag("ui:labeltail");
		}

		xml.appendEndTag("ui:decoratedlabel");
	}
473180
private void paintColumnHeading(final WTableColumn col, final boolean sortable,
			final WebXmlRenderContext renderContext) {
		XmlStringBuilder xml = renderContext.getWriter();
		int width = col.getWidth();
		Alignment align = col.getAlign();

		xml.appendTagOpen("ui:th");
		xml.appendOptionalAttribute("width", width > 0, width);
		xml.appendOptionalAttribute("sortable", sortable, "true");

		if (Alignment.RIGHT.equals(align)) {
			xml.appendAttribute("align", "right");
		} else if (Alignment.CENTER.equals(align)) {
			xml.appendAttribute("align", "center");
		}

		xml.appendClose();

		col.paint(renderContext);

		xml.appendEndTag("ui:th");
	}
1304007
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WSection section = (WSection) component;
		XmlStringBuilder xml = renderContext.getWriter();

		boolean renderChildren = isRenderContent(section);

		xml.appendTagOpen("ui:section");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		if (SectionMode.LAZY.equals(section.getMode())) {
			xml.appendOptionalAttribute("hidden", !renderChildren, "true");
		} else {
			xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
		}

		SectionMode mode = section.getMode();
		if (mode != null) {
			switch (mode) {
				case LAZY:
					xml.appendAttribute("mode", "lazy");
					break;
				case EAGER:
					xml.appendAttribute("mode", "eager");
					break;
				default:
					throw new SystemException("Unknown section mode: " + section.getMode());
			}
		}

		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(section, renderContext);

		if (renderChildren) {
			// Label
			section.getDecoratedLabel().paint(renderContext);
			// Content
			section.getContent().paint(renderContext);
		}

		xml.appendEndTag("ui:section");
	}
1116795
@Override
	public void paint(final RenderContext renderContext) {
		super.paint(renderContext);

		if (!DebugUtil.isDebugFeaturesEnabled() || !(renderContext instanceof WebXmlRenderContext)) {
			return;
		}

		XmlStringBuilder xml = ((WebXmlRenderContext) renderContext).getWriter();

		xml.appendTag("ui:debug");
		writeDebugInfo(getUI(), xml);
		xml.appendEndTag("ui:debug");
	}
230358
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		XmlStringBuilder xml = renderContext.getWriter();
		xml.appendTagOpen("hr");
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendEnd();
	}
737674
public function displayTable($table)
    {
        $headers = $this->makeHeaders($table[0]);

        $rows = [];

        foreach ($table as $row) {
            $rows[] = (array) $row;
        }

        $this->table = $this->getHelperSet()->get('table');

        $this->table->setHeaders($headers)->setRows($rows);

        $this->table->render($this->getOutput());
    }
696078
public static void adjustColumnWidths(JTable table, int maxWidth)
    {
        final int safety = 20;
        for (int c = 0; c < table.getColumnCount(); c++)
        {
            TableColumn column = table.getColumnModel().getColumn(c);

            TableCellRenderer headerRenderer = column.getHeaderRenderer();
            if (headerRenderer == null) {
                headerRenderer = table.getTableHeader().getDefaultRenderer();
            }
            Component headerComponent = 
                headerRenderer.getTableCellRendererComponent(
                    table, column.getHeaderValue(), false, false, 0, 0);
            int width = headerComponent.getPreferredSize().width;

            for (int r = 0; r < table.getRowCount(); r++) 
            {
                TableCellRenderer cellRenderer = table.getCellRenderer(r, c);
                Component cellComponent = 
                    cellRenderer.getTableCellRendererComponent(
                        table, table.getValueAt(r, c), 
                        false, false, r, c);
                Dimension d = cellComponent.getPreferredSize();
                //System.out.println(
                //    "Preferred is "+d.width+" for "+cellComponent);
                width = Math.max(width, d.width);
            }
            column.setPreferredWidth(Math.min(maxWidth, width + safety));
        }
    }
1346970
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTabSet tabSet = (WTabSet) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:tabset");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendAttribute("type", getTypeAsString(tabSet.getType()));
		xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true");
		xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight());
		xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true");
		xml.appendOptionalAttribute("single",
				TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(),
				"true");
		if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) {
			xml.appendOptionalAttribute("groupName", tabSet.getGroupName());
		}
		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(tabSet, renderContext);

		paintChildren(tabSet, renderContext);

		xml.appendEndTag("ui:tabset");
	}