<commit_before>/*
 * Copyright (c) 1998-2016 by <NAME>. All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * version 2.0. If a copy of the MPL was not distributed with this file, You
 * can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This Source Code Form is "Incompatible With Secondary Licenses", as defined
 * by the Mozilla Public License, version 2.0.
 */

package com.trollworks.gcs.widgets.outline;

import com.trollworks.toolkit.ui.widget.outline.Column;
import com.trollworks.toolkit.ui.widget.outline.Outline;
import com.trollworks.toolkit.ui.widget.outline.OutlineModel;

import java.util.ArrayList;

/** Utilities for columns. */
public class ColumnUtils {
	/**
	 * Packs the columns to their preferred sizes.
	 * 
	 * @param outline The {@link Outline} to pack.
	 * @param width The width available for all columns.
	 */
	public static void pack(Outline outline, int width) {
		OutlineModel outlineModel = outline.getModel();
		int count = outlineModel.getColumnCount();
		ArrayList<Column> changed = new ArrayList<>();
		int[] widths = new int[count];
		Column column;
		if (outline.shouldDrawColumnDividers()) {
			width -= count - 1;
		}
		for (int i = 0; i < count; i++) {
			column = outlineModel.getColumnAtIndex(i);
			widths[i] = column.getPreferredWidth(outline);
			width -= widths[i];
		}
		if (width >= 0) {
			widths[0] += width;
		} else {
			int pos = 0;
			int[] list = new int[count];
			int[] minList = new int[count];
			for (int i = 0; i < count; i++) {
				column = outlineModel.getColumnAtIndex(i);
				if (column.getRowCell(null).participatesInDynamicRowLayout()) {
					int min = column.getPreferredHeaderWidth();

					if (min < widths[i]) {
						list[pos] = i;<commit_msg>Give excess space to the hierarchy column<commit_after>/*
 * Copyright (c) 1998-2016 by <NAME>. All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * version 2.0. If a copy of the MPL was not distributed with this file, You
 * can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This Source Code Form is "Incompatible With Secondary Licenses", as defined
 * by the Mozilla Public License, version 2.0.
 */

package com.trollworks.gcs.widgets.outline;

import com.trollworks.toolkit.ui.widget.outline.Column;
import com.trollworks.toolkit.ui.widget.outline.Outline;
import com.trollworks.toolkit.ui.widget.outline.OutlineModel;

import java.util.ArrayList;

/** Utilities for columns. */
public class ColumnUtils {
	/**
	 * Packs the columns to their preferred sizes.
	 *
	 * @param outline The {@link Outline} to pack.
	 * @param width The width available for all columns.
	 */
	public static void pack(Outline outline, int width) {
		OutlineModel outlineModel = outline.getModel();
		int count = outlineModel.getColumnCount();
		ArrayList<Column> changed = new ArrayList<>();
		int[] widths = new int[count];
		Column column;
		if (outline.shouldDrawColumnDividers()) {
			width -= count - 1;
		}
		for (int i = 0; i < count; i++) {
			column = outlineModel.getColumnAtIndex(i);
			widths[i] = column.getPreferredWidth(outline);
			width -= widths[i];
		}
		if (width >= 0) {
			if (width > 0) {
				for (int i = 0; i < count; i++) {
					column = outlineModel.getColumnAtIndex(i);
					if (outlineModel.isHierarchyColumn(column)) {
						widths[i] += width;
						width = 0;
						break;
					}
				}
				if (width > 0) {
					widths[0] += width;
				}
			}
		} else {
			int pos = 0;
			int[] list = new int[count];
			int[] minList = new int[count];
			for (int i = 0; i < count; i++) {
				column = outlineModel.getColumnAtIndex(i);
				if (column.getRowCell(null).participatesInDynamicRowLayout()) {
					int min = column.getPreferredHeaderWidth();

					if (min < widths[i]) {
						list[pos] = i;
{'fraction_non_alphanumeric': 0.12797074954296161, 'fraction_numerical': 0.01149125097936798, 'mean_word_length': 3.372146118721461, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4666265', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1211, 'n_words': 379}