1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.common;
\r
14 import org.simantics.browsing.ui.Column;
\r
15 import org.simantics.browsing.ui.Column.Align;
\r
18 * A factory for constructing new {@link Column} instances in chained
\r
19 * initialization coding style. The same factory can be used to create any
\r
20 * number of new {@link Column} instances.
\r
24 * @author Tuukka Lehtonen
\r
26 public class ColumnFactory {
\r
38 boolean grab = false;
\r
40 private ColumnFactory(String key) {
\r
42 this.alignment = Align.LEFT;
\r
43 this.width = Column.DEFAULT_CONTROL_WIDTH;
\r
47 private ColumnFactory(String key, Align alignment, int width, String tooltip) {
\r
49 this.alignment = alignment;
\r
51 this.tooltip = tooltip;
\r
54 public static ColumnFactory defaults(String key) {
\r
55 return new ColumnFactory(key);
\r
58 public static ColumnFactory get(Column c) {
\r
59 return new ColumnFactory(c.getKey(), c.getAlignment(), c.getWidth(), c.getTooltip());
\r
62 public ColumnFactory key(String key) {
\r
67 public ColumnFactory label(String label) {
\r
72 public ColumnFactory alignment(Align alignment) {
\r
73 this.alignment = alignment;
\r
77 public ColumnFactory width(int width) {
\r
82 public ColumnFactory tooltip(String tooltip) {
\r
83 this.tooltip = tooltip;
\r
87 public ColumnFactory grab() {
\r
92 public Column toColumn() {
\r
93 return new Column(key, label, alignment, width, tooltip, grab);
\r