@Test public void testColumnOrderAccessors() { WDataTable table = new WDataTable(); table.addColumn(new WTableColumn("col1", WText.class)); table.addColumn(new WTableColumn("col2", WText.class)); int[] order1 = new int[]{0, 1}; int[] order2 = new int[]{1, 0}; Assert. assertNull("Should not have a custom column order by default", table. getColumnOrder()); table.setColumnOrder(order1); Assert.assertSame("Incorrect default column order", order1, table.getColumnOrder()); table.setLocked(true); setActiveContext(createUIContext()); table.setColumnOrder(order2); Assert.assertSame("Incorrect column order for modified session", order2, table. getColumnOrder()); setActiveContext(createUIContext()); Assert.assertSame("Incorrect column order for other sessions", order1, table. getColumnOrder()); }
/** * Paints the column headings for the given table. * * @param table the table to paint the headings for. * @param renderContext the RenderContext to paint to. */ private void paintColumnHeadings(final WDataTable table, final WebXmlRenderContext renderContext) { XmlStringBuilder xml = renderContext.getWriter(); int[] columnOrder = table.getColumnOrder(); TableDataModel model = table.getDataModel(); final int columnCount = table.getColumnCount(); xml.appendTagOpen("ui:thead"); xml.appendOptionalAttribute("hidden", !table.isShowColumnHeaders(), "true"); xml.appendClose(); if (table.isShowRowHeaders()) { paintColumnHeading(table.getRowHeaderColumn(), false, renderContext); } 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"); }
int[] columnOrder = table.getColumnOrder(); int rowIndex = getRowIndex(table, (SubUIContext) uic); boolean unselectable = table.getSelectMode() != SelectMode.NONE