Package org.eclipse.jface.widgets
Class DateTimeFactory
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F,C,Composite>
org.eclipse.jface.widgets.AbstractControlFactory<DateTimeFactory,DateTime>
org.eclipse.jface.widgets.DateTimeFactory
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(java.util.function.Consumer<org.eclipse.swt.events.SelectionEvent>)
) accepts a Lambda forSelectionEvent
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic DateTimeFactory
newDateTime
(int style) Creates a new DateTimeFactory with the given style.onDefaultSelect
(Consumer<SelectionEvent> consumer) Creates aSelectionListener
and registers it for the widgetDefaultSelected event.onSelect
(Consumer<SelectionEvent> consumer) Creates aSelectionListener
and registers it for the widgetSelected event.Methods inherited from class org.eclipse.jface.widgets.AbstractControlFactory
background, enabled, font, foreground, layoutData, orientation, supplyLayoutData, tooltip
Methods inherited from class org.eclipse.jface.widgets.AbstractWidgetFactory
addProperty, cast, create, data, data
-
Method Details
-
newDateTime
Creates a new DateTimeFactory with the given style. Refer toDateTime(Composite, int)
for possible styles.- Returns:
- a new DateTimeFactory instance
-
onSelect
Creates aSelectionListener
and registers it for the widgetSelected event. If the receiver is selected by the user the given consumer is invoked. TheSelectionEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-
onDefaultSelect
Creates aSelectionListener
and registers it for the widgetDefaultSelected event. If the receiver is selected by the user the given consumer is invoked. TheSelectionEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-