01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.viewers;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: /**
15: * Describes the width of a table column in terms of a weight,
16: * a minimum width, and whether the column is resizable.
17: * <p>
18: * This class may be instantiated; it is not intended to be subclassed.
19: * </p>
20: */
21: public class ColumnWeightData extends ColumnLayoutData {
22:
23: /**
24: * Default width of a column (in pixels).
25: */
26: public static final int MINIMUM_WIDTH = 20;
27:
28: /**
29: * The column's minimum width in pixels.
30: */
31: public int minimumWidth;
32:
33: /**
34: * The column's weight.
35: */
36: public int weight;
37:
38: /**
39: * Creates a resizable column width with the given weight and a default
40: * minimum width.
41: *
42: * @param weight the weight of the column
43: */
44: public ColumnWeightData(int weight) {
45: this (weight, true);
46: }
47:
48: /**
49: * Creates a resizable column width with the given weight and minimum width.
50: *
51: * @param weight the weight of the column
52: * @param minimumWidth the minimum width of the column in pixels
53: */
54: public ColumnWeightData(int weight, int minimumWidth) {
55: this (weight, minimumWidth, true);
56: }
57:
58: /**
59: * Creates a column width with the given weight and minimum width.
60: *
61: * @param weight the weight of the column
62: * @param minimumWidth the minimum width of the column in pixels
63: * @param resizable <code>true</code> if the column is resizable,
64: * and <code>false</code> if size of the column is fixed
65: */
66: public ColumnWeightData(int weight, int minimumWidth,
67: boolean resizable) {
68: super (resizable);
69: Assert.isTrue(weight >= 0);
70: Assert.isTrue(minimumWidth >= 0);
71: this .weight = weight;
72: this .minimumWidth = minimumWidth;
73: }
74:
75: /**
76: * Creates a column width with the given weight and a default
77: * minimum width.
78: *
79: * @param weight the weight of the column
80: * @param resizable <code>true</code> if the column is resizable,
81: * and <code>false</code> if size of the column is fixed
82: */
83: public ColumnWeightData(int weight, boolean resizable) {
84: this(weight, MINIMUM_WIDTH, resizable);
85: }
86: }
|