Class DateTimeFactory


public final class DateTimeFactory extends AbstractControlFactory<DateTimeFactory, DateTime>
This class provides a convenient shorthand for creating and initializing DateTime. This offers several benefits over creating with widget the normal way:
  • The same factory can be used many times to create several instances
  • The setters all return "this", allowing them to be chained
  • The onSelect(Consumer)) accepts a Lambda for SelectionEvent
Example usage:
DateTime DateTime = DateTimeFactory.newDateTime(SWT.BORDER) //
                .onSelect(event -> DateTimeClicked(event)) //
                .layoutData(gridData) //
                .create(parent);

The above example creates a new DateTime, registers a SelectionListener and finally creates the DateTime in "parent".

GridDataFactory gridDataFactory = GridDataFactory.swtDefaults();
DateTimeFactory DateTimeFactory = DateTimeFactory.newDateTime(SWT.BORDER).onSelect(event -> DateTimeClicked(event))
                .layout(gridDataFactory::create);
DateTimeFactory.create(parent);
DateTimeFactory.create(parent);
DateTimeFactory.create(parent);

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

Since:
3.22