Package org.eclipse.jface.widgets

# Class TreeColumnFactory

java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<TreeColumnFactory,TreeColumn,Tree>
org.eclipse.jface.widgets.AbstractItemFactory<TreeColumnFactory,TreeColumn,Tree>
org.eclipse.jface.widgets.TreeColumnFactory

public final class TreeColumnFactory extends AbstractItemFactory<TreeColumnFactory,TreeColumn,Tree>
This class provides a convenient shorthand for creating and initializing `TreeColumn`. This offers several benefits over creating TreeColumn normal way:

- The same factory can be used many times to create several TreeColumn instances
- The setters on TreeColumnFactory all return "this", allowing them to be chained
- TreeColumnFactory accepts a Lambda for `SelectionEvent` (see `onSelect(java.util.function.Consumer<org.eclipse.swt.events.SelectionEvent>)`)

Example usage:

     TreeColumn column = TreeColumnFactory.newTreeColumn(SWT.CENTER) //
                    .text("Tree Column") //
                    .onSelect(event -> columnClicked(event)) //
                    .create(tree);

The above example creates a tree column, sets text, registers a SelectionListener and finally creates the tree column in "tree".

     TreeColumnFactory factory = TreeColumnFactory.newTreeColumn(SWT.CENTER).onSelect(event -> columnClicked(event));
     factory.text("Column 1").create(tree);
     factory.text("Column 2").create(tree);
     factory.text("Column 3").create(tree);

The above example creates three tree columns using the same instance of factory.

Since:
  3.18

## Method Summary

Modifier and Type
Method
Description
`TreeColumnFactory`
`align(int alignment)`
Controls how text and images will be displayed in the receiver.
`TreeColumnFactory`
`moveable(boolean moveable)`
Sets the moveable attribute.
`static TreeColumnFactory`
`newTreeColumn(int style)`
Creates a new TreeColumnFactory with the given style.
`TreeColumnFactory`
`onSelect(Consumer<SelectionEvent> consumer)`
Creates a `SelectionListener` and registers it for the widgetSelected event.
`TreeColumnFactory`
`resizable(boolean resizable)`
Sets the resizable attribute.
`TreeColumnFactory`
`tooltip(String tooltip)`
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.
`TreeColumnFactory`
`width(int width)`
Sets the width of the receiver.

### Methods inherited from class org.eclipse.jface.widgets.AbstractItemFactory

`image, text`

### Methods inherited from class org.eclipse.jface.widgets.AbstractWidgetFactory

`addProperty, cast, create, data, data`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### newTreeColumn

public static TreeColumnFactory newTreeColumn(int style)
Creates a new TreeColumnFactory with the given style. Refer to `TreeColumn(Tree, int)` for possible styles.

Returns:
  a new TreeColumnFactory instance

### onSelect

public TreeColumnFactory onSelect(Consumer<SelectionEvent> consumer)
Creates a `SelectionListener` and registers it for the widgetSelected event. If the receiver is selected by the user the given consumer is invoked. The `SelectionEvent` is passed to the consumer.

Parameters:
  `consumer` - the consumer whose accept method is called
Returns:
  this
See Also:
  - `TreeColumn.addSelectionListener(SelectionListener)`
  - `SelectionListener.widgetSelectedAdapter(Consumer)`

### align

public TreeColumnFactory align(int alignment)
Controls how text and images will be displayed in the receiver. The argument should be one of LEFT, RIGHT or CENTER. Note that due to a restriction on some platforms, the first column is always left aligned.

Parameters:
  `alignment` - the alignment
Returns:
  this
See Also:
  - `TreeColumn.setAlignment(int)`

### tooltip

public TreeColumnFactory tooltip(String tooltip)
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown. The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.

Parameters:
  `tooltip` - the tool tip text
Returns:
  this
See Also:
  - `TreeColumn.setToolTipText(String)`

### width

public TreeColumnFactory width(int width)
Sets the width of the receiver.

Parameters:
  `width` - the width
Returns:
  this
See Also:
  - `TreeColumn.setWidth(int)`

### moveable

public TreeColumnFactory moveable(boolean moveable)
Sets the moveable attribute.

Parameters:
  `moveable` - the moveable attribute
Returns:
  this
Since:
  3.19
See Also:
  - `TreeColumn.setMoveable(boolean)`

### resizable

public TreeColumnFactory resizable(boolean resizable)
Sets the resizable attribute.

Parameters:
  `resizable` - the resize attribute
Returns:
  this
Since:
  3.19
See Also:
  - `TreeColumn.setResizable(boolean)`