Adjusts the widths and heights of the cells of the supplied table to fit their contents.
548372
public static void sizeToContents (JTable table)
    {
        TableModel model = table.getModel();
        TableColumn column = null;
        Component comp = null;
        int ccount = table.getColumnModel().getColumnCount(),
            rcount = model.getRowCount(), cellHeight = 0;

        for (int cc = 0; cc < ccount; cc++) {
            int headerWidth = 0, cellWidth = 0;
            column = table.getColumnModel().getColumn(cc);
            try {
                comp = column.getHeaderRenderer().getTableCellRendererComponent(
                    null, column.getHeaderValue(), false, false, 0, 0);
                headerWidth = comp.getPreferredSize().width;
            } catch (NullPointerException e) {
                // getHeaderRenderer() this doesn't work in 1.3
            }

            for (int rr = 0; rr < rcount; rr++) {
                Object cellValue = model.getValueAt(rr, cc);
                comp = table.getDefaultRenderer(model.getColumnClass(cc)).
                    getTableCellRendererComponent(table, cellValue, false, false, 0, cc);
                Dimension psize = comp.getPreferredSize();
                cellWidth = Math.max(psize.width, cellWidth);
                cellHeight = Math.max(psize.height, cellHeight);
            }
            column.setPreferredWidth(Math.max(headerWidth, cellWidth));
        }

        if (cellHeight > 0) {
            table.setRowHeight(cellHeight);
        }
    }
596132
def fix_row_widths

      fill_cells(@row_offset - 1, 0)

      max = 0

      @data.each_with_index do |row|
        max = row.length unless max >= row.length
      end

      @data.each_with_index do |row,idx|
        if row.length < max
          row = row + [ @base_cell_options.merge({content: ''}) ] * (max - row.length)
          @data[idx] = row
        end
      end

    end
395692
private function executeColumnWidths(): void
  {
    $this->loadOldColumns();

    $this->loadColumns();

    $this->enhanceColumns();

    $this->mergeColumns();

    $this->writeColumns();
  }
186289
function adjustWidth(table, delta, index) {
        var tableDetails = getTableDetails(table);
        var tableGrid = getTableGrid(tableDetails);

        function setSizes(newSizes, styleExtension) {
          Tools.each(newSizes, function (cell) {
            editor.dom.setStyle(cell.element, 'width', cell.width + styleExtension);
            editor.dom.setAttrib(cell.element, 'width', null);
          });
        }

        function getNewTablePercentWidth() {
          return index < tableGrid.grid.maxCols - 1 ? getCurrentTablePercentWidth(table) :
            getCurrentTablePercentWidth(table) + getTablePercentDelta(table, delta);
        }

        function getNewTablePixelWidth() {
          return index < tableGrid.grid.maxCols - 1 ? getComputedStyleSize(table, 'width') :
            getComputedStyleSize(table, 'width') + delta;
        }

        function setTableSize(newTableWidth, styleExtension, isPercentBased) {
          if (index == tableGrid.grid.maxCols - 1 || !isPercentBased) {
            editor.dom.setStyle(table, 'width', newTableWidth + styleExtension);
            editor.dom.setAttrib(table, 'width', null);
          }
        }

        var percentageBased = isPercentageBasedSize(table.width) ||
          isPercentageBasedSize(table.style.width);

        var widths = getWidths(tableGrid, percentageBased, table);

        var step = percentageBased ? getCellPercentDelta(table, delta) : delta;
        // TODO: change the min for percentage maybe?
        var deltas = determineDeltas(widths, index, step, RESIZE_MINIMUM_WIDTH, percentageBased, table);
        var newWidths = [];

        for (var i = 0; i < deltas.length; i++) {
          newWidths.push(deltas[i] + widths[i]);
        }

        var newSizes = recalculateWidths(tableGrid, newWidths);
        var styleExtension = percentageBased ? '%' : 'px';
        var newTableWidth = percentageBased ? getNewTablePercentWidth() :
          getNewTablePixelWidth();

        editor.undoManager.transact(function () {
          setSizes(newSizes, styleExtension);
          setTableSize(newTableWidth, styleExtension, percentageBased);
        });
      }
409041
def auto_adjust_widths
      column_widths = []

      rows.each do |row|
        row.columns.each_with_index do |col, i|
          column_widths[i] = [col.required_width, (column_widths[i] || 0)].max
        end
      end

      rows.each do |row|
        row.columns.each_with_index do |col, i|
          col.width = column_widths[i]
        end
      end
    end
833673
function setColumnWidth(column, newWidth) {
    // if (column != this.lastVisibleColumn) {
    if (newWidth > this.minColumnWidth || newWidth == this.minColumnWidth) {
        var nowVisibleThIndex = this.getVisibleIndexOfColumn(column),
            oldWidth = column.options.width,
            changeWidth = newWidth - oldWidth,
            cWidth = this.contentWidth + changeWidth;
        this.contentWidth = this.contentWidthChange(cWidth);
        $('#' + this.options.id + '_header_table col:eq(' + nowVisibleThIndex + ')').css('width', newWidth + "px");
        $('#' + this.options.id + '_content_table col:eq(' + nowVisibleThIndex + ')').css('width', newWidth + "px");
        column.options.width = newWidth;
        column.options.realWidth = newWidth;
        this.resetThVariable();
        this.saveGridCompColumnArrToLocal();
    }
    this.resetLastVisibleColumnWidth();
    this.columnsVisibleFun();
    // }
}
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);
	}
976976
function insertTableFragmentAtRange(
    opts: Options,
    change: Change,
    range: Range,
    // This fragment should contain only one table,
    // with a valid number of cells
    fragment: Document
): Change {
    const insertedTable = fragment.nodes.first();
    if (
        !(
            fragment.nodes.size === 1 &&
            insertedTable &&
            insertedTable.type === opts.typeTable
        )
    ) {
        throw new Error('Expected to insert a fragment containing one table');
    }

    const { value } = change;
    const targetPosition = TablePosition.create(
        opts,
        value.document,
        value.selection.startKey
    );

    const fragmentRows = insertedTable.nodes;
    const fragmentHeight = fragmentRows.size;
    const fragmentWidth = fragmentRows.first().nodes.size;

    // Insert columns and rows to accomodate the incoming pasted cells
    const missingWidth =
        fragmentWidth +
        targetPosition.getColumnIndex() -
        targetPosition.getWidth();
    const missingHeight =
        fragmentHeight +
        targetPosition.getRowIndex() -
        targetPosition.getHeight();

    if (missingWidth > 0) {
        // Add columns
        Array(missingWidth)
            .fill()
            .forEach(() => {
                insertColumn(opts, change, targetPosition.getWidth());
            });
    }
    if (missingHeight > 0) {
        // Add rows
        Array(missingHeight)
            .fill()
            .forEach(() => {
                insertRow(opts, change, targetPosition.getHeight());
            });
    }

    // Patch the inserted table over the target table, overwritting the cells
    const existingTable = change.value.document.getDescendant(
        targetPosition.table.key
    );

    fragmentRows.forEach((fragmentRow, fragmentRowIndex) => {
        fragmentRow.nodes.forEach((newCell, fragmentColumnIndex) => {
            const existingCell = existingTable.nodes
                .get(targetPosition.getRowIndex() + fragmentRowIndex)
                .nodes.get(
                    targetPosition.getColumnIndex() + fragmentColumnIndex
                );

            change.replaceNodeByKey(existingCell.key, newCell, {
                normalize: false
            });
        });
    });

    const lastPastedCell = fragmentRows.last().nodes.last();
    return change.collapseToEndOf(lastPastedCell);
}
1085926
private void organizeColumns()
    {
        columns = new Vector<TableColumn>();
        for (int bi = 0; bi < nested.size(); bi++)
        {
            Box box = nested.elementAt(bi);
            if (box instanceof TableColumn)
            {
                TableColumn col = (TableColumn) box;
                if (col.getSpecifiedWidth().equals(""))
                    col.setSpecifiedWidth(colwidth); //when column width is not set, use the group width
                for (int i = 0; i < col.getSpan(); i++)
                {
                    if (i == 0)
                        columns.add(col);
                    else
                        columns.add(col.copyBox());
                }
            }
        }
        //when there are no <col> elements, use the span attribute
        if (columns.isEmpty())
        {
            TableColumn col = new TableColumn(TableColumn.createAnonymousColumn(getParent().getElement().getOwnerDocument()), g, ctx);
            col.setSpecifiedWidth(colwidth);
            for (int i = 0; i < span; i++)
                columns.add(col.copyBox());
        }
    }
1276306
def set_cols_width(self, array):
        

        self._check_row_size(array)
        try:
            array = map(int, array)
            if reduce(min, array) <= 0:
                raise ValueError
        except ValueError:
            sys.stderr.write("Wrong argument in column width specification\n")
            raise
        self._width = array
393115
def adjustSize( self ):
        
        cell      = self.scene().cellWidth() * 2
        minheight = cell
        minwidth  = 2 * cell
        
        # fit to the grid size
        metrics = QFontMetrics(QApplication.font())
        width   = metrics.width(self.displayName()) + 20
        width   = ((width/cell) * cell) + (cell % width)
        
        height  = self.rect().height()
        
        # adjust for the icon
        icon = self.icon()
        if icon and not icon.isNull():
            width += self.iconSize().width() + 2
            height = max(height, self.iconSize().height() + 2)
        
        w = max(width, minwidth)
        h = max(height, minheight)
        
        max_w = self.maximumWidth()
        max_h = self.maximumHeight()
        
        if max_w is not None:
            w = min(w, max_w)
        if max_h is not None:
            h = min(h, max_h)
        
        self.setMinimumWidth(w)
        self.setMinimumHeight(h)
        
        self.rebuild()
1175068
def _adjust_rowcol(self, insertion_point, no_to_insert, axis, tab=None):
        """"""

        if axis == 2:
            self._shift_rowcol(insertion_point, no_to_insert)
            return

        assert axis in (0, 1)

        cell_sizes = self.col_widths if axis else self.row_heights
        set_cell_size = self.set_col_width if axis else self.set_row_height

        new_sizes = {}
        del_sizes = []

        for pos, table in cell_sizes:
            if pos > insertion_point and (tab is None or tab == table):
                if 0 <= pos + no_to_insert < self.shape[axis]:
                    new_sizes[(pos + no_to_insert, table)] = \
                        cell_sizes[(pos, table)]
                del_sizes.append((pos, table))

        for pos, table in new_sizes:
            set_cell_size(pos, table, new_sizes[(pos, table)])

        for pos, table in del_sizes:
            if (pos, table) not in new_sizes:
                set_cell_size(pos, table, None)
541396
function() {
				if (list && colWidth) {
					var cl = 'elfinder-cwd-colwidth',
					first = cwd.find('tr[id]:first'),
					former;
					if (! first.hasClass(cl)) {
						former = cwd.find('tr.'+cl);
						former.removeClass(cl).find('td').css('width', '');
						first.addClass(cl);
						cwd.find('table:first').css('table-layout', 'fixed');
						$.each($.merge(['name'], customCols), function(i, k) {
							var w = colWidth[k] || first.find('td.elfinder-col-'+k).width();
							first.find('td.elfinder-col-'+k).width(w);
						});
					}
				}
			}
778797
def _row_resized(self, row, old_height, new_height):
        """"""
        self.dataTable.setRowHeight(row, new_height)
        self._update_layout()
344611
def adapt_table_cell!(parsed_cell)
      # Saving off the original data
      parsed_cell['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_cell))

      parsed_cell['value'] = parsed_cell.delete(:value)
      parsed_cell['line'] = parsed_cell.delete(:location)[:line]
    end
239955
def _setInsertFromTable(self, value):
        """"""
        self._insertFromTable = value
        if value:
            self.insertElement = self.insertElementTable
        else:
            self.insertElement = self.insertElementNormal
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));
        }
    }