/** * Move a table column from its original position to a new position. * * <p>The table expands automatically when the <code>to</code> column is beyond the current table * dimensions. * * <p> * * @see WTable#moveRow(int from, int to) */ public void moveColumn(int from, int to) { if (from < 0 || from >= (int) this.columns_.size()) { logger.error( new StringWriter() .append("moveColumn: the from index is not a valid column index.") .toString()); return; } WTableColumn from_tc = this.getColumnAt(from); this.columns_.remove(from_tc); if (to > (int) this.columns_.size()) { this.getColumnAt(to); } this.columns_.add(0 + to, from_tc); for (int i = 0; i < this.rows_.size(); i++) { List<WTableRow.TableData> cells = this.rows_.get(i).cells_; WTableRow.TableData cell = cells.get(from); cells.remove(0 + from); cells.add(0 + to, cell); } this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }