Package org.eclipse.jface.widgets
Class TreeColumnFactory
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F,I,P>
org.eclipse.jface.widgets.AbstractItemFactory<TreeColumnFactory,TreeColumn,Tree>
org.eclipse.jface.widgets.TreeColumnFactory
This class provides a convenient shorthand for creating and initializing
TreeColumn
. This offers several benefits over creating TreeColumn
normal way:
- The same factory can be used many times to create several TreeColumn instances
- The setters on TreeColumnFactory all return "this", allowing them to be chained
- TreeColumnFactory accepts a Lambda for
SelectionEvent
(seeonSelect(java.util.function.Consumer<org.eclipse.swt.events.SelectionEvent>)
)
TreeColumn column = TreeColumnFactory.newTreeColumn(SWT.CENTER) // .text("Tree Column") // .onSelect(event -> columnClicked(event)) // .create(tree);
The above example creates a tree column, sets text, registers a SelectionListener and finally creates the tree column in "tree".
TreeColumnFactory factory = TreeColumnFactory.newTreeColumn(SWT.CENTER).onSelect(event -> columnClicked(event)); factory.text("Column 1").create(tree); factory.text("Column 2").create(tree); factory.text("Column 3").create(tree);
The above example creates three tree 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 TreeColumnFactory
newTreeColumn
(int style) Creates a new TreeColumnFactory 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
-
newTreeColumn
Creates a new TreeColumnFactory with the given style. Refer toTreeColumn(Tree, int)
for possible styles.- Returns:
- a new TreeColumnFactory 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:
-