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