Package org.eclipse.jface.widgets
Class TableColumnFactory
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F,I,P>
org.eclipse.jface.widgets.AbstractItemFactory<TableColumnFactory,TableColumn,Table>
org.eclipse.jface.widgets.TableColumnFactory
public final class TableColumnFactory
extends AbstractItemFactory<TableColumnFactory,TableColumn,Table>
This class provides a convenient shorthand for creating and initializing
TableColumn
. This offers several benefits over creating TableColumn
normal way:
- The same factory can be used many times to create several TableColumn instances
- The setters on TableColumnFactory all return "this", allowing them to be chained
- TableColumnFactory accepts a Lambda for
SelectionEvent
(seeonSelect(java.util.function.Consumer<org.eclipse.swt.events.SelectionEvent>)
)
TableColumn column = TableColumnFactory.newTableColumn(SWT.CENTER) // .text("Table Column") // .onSelect(event -> columnClicked(event)) // .create(table);
The above example creates a table column, sets text, registers a SelectionListener and finally creates the table column in "table".
TableColumnFactory factory = TableColumnFactory.newTableColumn(SWT.CENTER).onSelect(event -> columnClicked(event)); factory.text("Column 1").create(table); factory.text("Column 2").create(table); factory.text("Column 3").create(table);
The above example creates three table columns using the same instance of factory.
- Since:
- 3.18
-
Method Summary
Modifier and TypeMethodDescriptionalign
(int alignment) Controls how text and images will be displayed in the receiver.moveable
(boolean moveable) Sets the moveable attribute.static TableColumnFactory
newTableColumn
(int style) Creates a new TableColumnFactory with the given style.onSelect
(Consumer<SelectionEvent> consumer) Creates aSelectionListener
and registers it for the widgetSelected event.resizable
(boolean resizable) Sets the resizable attribute.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.width
(int width) Sets the width of the receiver.Methods inherited from class org.eclipse.jface.widgets.AbstractItemFactory
image, text
Methods inherited from class org.eclipse.jface.widgets.AbstractWidgetFactory
addProperty, cast, create, data, data
-
Method Details
-
newTableColumn
Creates a new TableColumnFactory with the given style. Refer toTableColumn(Table, int)
for possible styles.- Returns:
- a new TableColumnFactory 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:
-
align
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
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
Sets the width of the receiver.- Parameters:
width
- the width- Returns:
- this
- See Also:
-
moveable
Sets the moveable attribute.- Parameters:
moveable
- the moveable attribute- Returns:
- this
- Since:
- 3.19
- See Also:
-
resizable
Sets the resizable attribute.- Parameters:
resizable
- the resize attribute- Returns:
- this
- Since:
- 3.19
- See Also:
-