Class SashFactory


public final class SashFactory extends AbstractControlFactory<SashFactory, Sash>
This class provides a convenient shorthand for creating and initializing Sash. This offers several benefits over creating Sash normal way:
  • The same factory can be used many times to create several Sash instances
  • The setters on SashFactory all return "this", allowing them to be chained
  • SashFactory accepts a Lambda for SelectionEvent (see onSelect(Consumer))
Example usage:
Sash sash = SashFactory.newSash(SWT.HORIZONTAL) //
                .onSelect(event -> sashSelected(event)) //
                .layoutData(gridData) //
                .create(parent);

The above example creates a horizontal sash, registers a SelectionListener and finally creates the sash in "parent".

GridDataFactory gridDataFactory = GridDataFactory.swtDefaults();
SashFactory sashFactory = SashFactory.newSash(SWT.HORIZONTAL).onSelect(event -> sashSelected(event))
                .layout(gridDataFactory::create);
sashFactory.data("Sash 1").create(parent);
sashFactory.data("Sash 2").create(parent);
sashFactory.data("Sash 3").create(parent);

The above example creates three sashs using the same instance of SashFactory. Note the layout method. A Supplier is used to create unique GridData for every single sash.

Since:
3.21