Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 634556a3cffcfd044266f86c4c16f581f0e5dc2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.viewers;

import org.eclipse.core.runtime.Assert;

/**
 * Describes the width of a table column in terms of a weight, 
 * a minimum width, and whether the column is resizable.
 * <p>
 * This class may be instantiated; it is not intended to be subclassed.
 * </p>
 */
public class ColumnWeightData extends ColumnLayoutData {

    /** 
     * Default width of a column (in pixels).
     */
    public static final int MINIMUM_WIDTH = 20;

    /**
     * The column's minimum width in pixels.
     */
    public int minimumWidth;

    /**
     * The column's weight.
     */
    public int weight;

    /**
     * Creates a resizable column width with the given weight and a default
     * minimum width.
     *
     * @param weight the weight of the column
     */
    public ColumnWeightData(int weight) {
        this(weight, true);
    }

    /**
     * Creates a resizable column width with the given weight and minimum width.
     *
     * @param weight the weight of the column
     * @param minimumWidth the minimum width of the column in pixels
     */
    public ColumnWeightData(int weight, int minimumWidth) {
        this(weight, minimumWidth, true);
    }

    /**
     * Creates a column width with the given weight and minimum width.
     *
     * @param weight the weight of the column
     * @param minimumWidth the minimum width of the column in pixels
     * @param resizable <code>true</code> if the column is resizable,
     *   and <code>false</code> if size of the column is fixed
     */
    public ColumnWeightData(int weight, int minimumWidth, boolean resizable) {
        super(resizable);
        Assert.isTrue(weight >= 0);
        Assert.isTrue(minimumWidth >= 0);
        this.weight = weight;
        this.minimumWidth = minimumWidth;
    }

    /**
     * Creates a column width with the given weight and a default
     * minimum width.
     *
     * @param weight the weight of the column
     * @param resizable <code>true</code> if the column is resizable,
     *   and <code>false</code> if size of the column is fixed
     */
    public ColumnWeightData(int weight, boolean resizable) {
        this(weight, MINIMUM_WIDTH, resizable);
    }
}

Back to the top