Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 268497
Collapse All | Expand All

(-)src/org/eclipse/nebula/jface/GridColumnLayout.java (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 BestSolution.at and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.nebula.jface;
12
13
import org.eclipse.jface.layout.AbstractColumnLayout;
14
import org.eclipse.jface.viewers.ColumnLayoutData;
15
import org.eclipse.jface.viewers.ColumnPixelData;
16
import org.eclipse.nebula.widgets.grid.Grid;
17
import org.eclipse.nebula.widgets.grid.GridColumn;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Scrollable;
20
import org.eclipse.swt.widgets.Widget;
21
22
/**
23
 * A dynamic column layout for nebula grid
24
 */
25
public class GridColumnLayout extends AbstractColumnLayout {
26
	/**
27
	 * {@inheritDoc}
28
	 * 
29
	 * @since 0.9
30
	 */
31
	protected int getColumnCount(Scrollable tableTree) {
32
		return ((Grid) tableTree).getColumnCount();
33
	}
34
35
	/**
36
	 * {@inheritDoc}
37
	 * 
38
	 * @since 0.9
39
	 */
40
	protected void setColumnWidths(Scrollable tableTree, int[] widths) {
41
		GridColumn[] columns = ((Grid) tableTree).getColumns();
42
		for (int i = 0; i < widths.length; i++) {
43
			columns[i].setWidth(widths[i]);
44
		}
45
	}
46
47
	/**
48
	 * {@inheritDoc}
49
	 * 
50
	 * @since 0.9
51
	 */
52
	protected ColumnLayoutData getLayoutData(Scrollable tableTree,
53
			int columnIndex) {
54
		GridColumn column = ((Grid) tableTree).getColumn(columnIndex);
55
		return (ColumnLayoutData) column.getData(LAYOUT_DATA);
56
	}
57
58
	Composite getComposite(Widget column) {
59
		return ((GridColumn) column).getParent().getParent();
60
	}
61
62
	/**
63
	 * {@inheritDoc}
64
	 * 
65
	 * @since 0.9
66
	 */
67
	protected void updateColumnData(Widget column) {
68
		GridColumn tColumn = (GridColumn) column;
69
		Grid t = tColumn.getParent();
70
71
		tColumn.setData(LAYOUT_DATA, new ColumnPixelData(tColumn.getWidth()));
72
		layout(t.getParent(), true);
73
	}
74
}

Return to bug 268497