Package org.eclipse.jface.widgets
Class SashFormFactory
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F,C,Composite>
org.eclipse.jface.widgets.AbstractControlFactory<SashFormFactory,SashForm>
org.eclipse.jface.widgets.SashFormFactory
This class provides a convenient shorthand for creating and initializing
SashForm
. This offers several benefits over creating SashForm normal
way:
- The same factory can be used many times to create several SashForm instances
- The setters on SashFormFactory all return "this", allowing them to be chained
SashForm sashForm = SashFormFactory.newFormSash(SWT.HORIZONTAL).create(parent); Composite c1 = CompositeFactory.newComposite(SWT.NONE).create(sashForm); Composite c2 = CompositeFactory.newComposite(SWT.NONE).create(sashForm); sashForm.setWeights(new int[] { 30, 70 });
The above example creates a horizontal sash. Note that
SashForm.setWeights(int[])
can only be called after children have
been added to the SashForm. Hence this method is not part of this factory.
GridDataFactory gridDataFactory = GridDataFactory.swtDefaults(); SashFactory sashFactory = SashFactory.newSash(SWT.HORIZONTAL).layout(gridDataFactory::create); sashFactory.data("Sash 1").create(parent); sashFactory.data("Sash 2").create(parent); sashFactory.data("Sash 3").create(parent);
The above example creates three sashForms using the same instance of SashFormFactory. Note the layout method. A Supplier is used to create unique GridData for every single sash.
- Since:
- 3.21
-
Method Summary
Modifier and TypeMethodDescriptionstatic SashFormFactory
newSashForm
(int style) Creates a new SashFormFactory with the given style.sashWidth
(int width) Specify the width of the sashes when the controls in the SashForm are laid out.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
-
newSashForm
Creates a new SashFormFactory with the given style. Refer toSashForm(Composite, int)
for possible styles.- Returns:
- a new SashFormFactory instance
-
sashWidth
Specify the width of the sashes when the controls in the SashForm are laid out.- Parameters:
width
- the width of the sashes- Returns:
- this
- See Also:
-