Package org.eclipse.jface.widgets
Class TableFactory
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F,C,Composite>
org.eclipse.jface.widgets.AbstractControlFactory<TableFactory,Table>
org.eclipse.jface.widgets.TableFactory
This class provides a convenient shorthand for creating and initializing
Table
. This offers several benefits over creating Table normal way:
- The same factory can be used many times to create several Table instances
- The setters on TableFactory all return "this", allowing them to be chained
- TableFactory accepts a Lambda for
SelectionEvent
(seeonSelect(java.util.function.Consumer<org.eclipse.swt.events.SelectionEvent>)
)
Table table = TableFactory.newTable(SWT.CHECK) // .headerVisible(true) // .linesVisible(true) // .onSelect(e -> tableClicked(e)) // .create(parent);
The above example creates a table, sets some properties, registers a SelectionListener and finally creates the table in "parent".
Note that this class does not extend AbstractCompositeFactory
even
though Table extends Composite. This is because Table is not supposed to be
used like a Composite.
- Since:
- 3.18
-
Method Summary
Modifier and TypeMethodDescriptionheaderVisible
(boolean visible) Marks the receiver's header as visible if the argument is true, and marks it invisible otherwise.itemCount
(int count) Sets the number of items contained in the receiver.linesVisible
(boolean visible) Marks the receiver's lines as visible if the argument is true, and marks it invisible otherwise.static TableFactory
newTable
(int style) Creates a new TableFactory with the given style.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
-
newTable
Creates a new TableFactory with the given style. Refer toTable(Composite, int)
for possible styles.- Returns:
- a new TableFactory 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:
-
headerVisible
Marks the receiver's header as visible if the argument is true, and marks it invisible otherwise.- Parameters:
visible
- the visibility state- Returns:
- this
- See Also:
-
linesVisible
Marks the receiver's lines as visible if the argument is true, and marks it invisible otherwise. Note that some platforms draw grid lines while others may draw alternating row colors.- Parameters:
visible
- the visibility state- Returns:
- this
- See Also:
-
itemCount
Sets the number of items contained in the receiver.- Parameters:
count
- the number of items- Returns:
- this
- See Also:
-