Class 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: 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 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:
    • 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:
    • 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:
    • width

      public TreeColumnFactory width(int width)
      Sets the width of the receiver.
      Parameters:
      width - the width
      Returns:
      this
      See Also:
    • moveable

      public TreeColumnFactory moveable(boolean moveable)
      Sets the moveable attribute.
      Parameters:
      moveable - the moveable attribute
      Returns:
      this
      Since:
      3.19
      See Also:
    • resizable

      public TreeColumnFactory resizable(boolean resizable)
      Sets the resizable attribute.
      Parameters:
      resizable - the resize attribute
      Returns:
      this
      Since:
      3.19
      See Also: