public class BasicField extends java.lang.Object implements IField
Basic Platform Field
Base class of all dialog fields. Dialog fields manage controls together with the model, independently from the creation time of the widgets.
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.swt.widgets.Control |
fLabelControl
The label widget of this field.
|
protected java.lang.String |
fLabelText
The text for the label widget of this field.
|
protected boolean |
fUseFormLayout
Flag indicating if field is used with a form layout (in a form editor for instance).
|
protected IWidgetFactory |
fWidgetFactory
The widget factory to use for widgets creation.
|
protected static int |
MAX_WITDH
The maximum width allowed for this field.
|
Constructor and Description |
---|
BasicField(IWidgetFactory widgetFactory)
Constructor.
|
Modifier and Type | Method and Description | |||
---|---|---|---|---|
void |
addFieldListener(IFieldListener listener)
Adds the given field listener in the listeners list of this field.
|
|||
protected void |
assertCompositeNotNull(org.eclipse.swt.widgets.Composite composite)
Asserts the specified
composite is not null . |
|||
static org.eclipse.swt.widgets.Control |
createEmptySpace(org.eclipse.swt.widgets.Composite parent)
Creates a spacer control.
|
|||
protected static org.eclipse.swt.widgets.Control |
createEmptySpace(org.eclipse.swt.widgets.Composite parent,
int span)
Creates a spacer control with the given span.
|
|||
protected org.eclipse.swt.widgets.Control |
createLabelControl(org.eclipse.swt.widgets.Composite parent,
boolean multiLine,
int hspan)
Creates the label control.
|
|||
protected static org.eclipse.swt.widgets.Composite |
createSpecificComposite(org.eclipse.swt.widgets.Composite parent,
int nColumns,
int span,
boolean hgrab,
boolean vgrab,
boolean useFormLayout)
Creates and returns a specific
Composite that can be used by subclasses in some specific cases (e.g. |
|||
protected void |
dialogFieldChanged()
Programatical invocation of a dialog field change.
|
|||
void |
dispose()
Disposes of the operating system resources associated with the field.
|
|||
protected org.eclipse.swt.widgets.Control[] |
doFillIntoGrid(org.eclipse.swt.widgets.Composite parent,
int nColumns)
/!\
| To be re-implemented by platform field implementors.
| /!\
|
|
org.eclipse.swt.widgets.Control[] |
fillIntoGrid(org.eclipse.swt.widgets.Composite parent,
int nColumns)
Creates all controls of the dialog field and fills it to a composite.
|
|||
org.eclipse.swt.widgets.Control |
getLabelControl() |
|||
protected org.eclipse.swt.widgets.Control |
getLabelControl(org.eclipse.swt.widgets.Composite parent,
boolean multiLine,
int hspan)
Returns the label control of this field, creates it if required.
|
|||
protected org.eclipse.swt.widgets.Control |
getLabelControl(org.eclipse.swt.widgets.Composite parent,
int hspan) |
|||
protected int |
getNumberOfControls()
Returns the number of columns of the dialog field.
|
|||
boolean |
isEnabled()
Gets the enable state of the dialog field.
|
|||
protected boolean |
isOkToUse(org.eclipse.swt.widgets.Control control)
Checks if the specified
control is not null neither disposed. |
|||
void |
refresh()
Brings the UI in sync with the model.
|
|||
void |
removeFieldListener(IFieldListener listener)
Removes the given field listener from the listeners list of this field.
|
|||
void |
setEnabled(boolean enabled)
Sets the enable state of the dialog field.
|
|||
protected boolean |
setFocus()
Tries to set the focus to this field.
|
|||
void |
setLabelText(java.lang.String labeltext)
Sets the label of the dialog field.
|
|||
void |
setToolTipText(java.lang.String toolTip)
Sets the tool tip of the dialog field.
|
|||
protected void |
updateEnableState()
Called when the enable state changed.
|
protected static final int MAX_WITDH
protected boolean fUseFormLayout
protected IWidgetFactory fWidgetFactory
protected org.eclipse.swt.widgets.Control fLabelControl
protected java.lang.String fLabelText
public BasicField(IWidgetFactory widgetFactory)
widgetFactory
- The widget factory to use for widgets creation.protected final boolean isOkToUse(org.eclipse.swt.widgets.Control control)
control
is not null
neither disposed.control
- The Control
whose usability must be verified.true
if the specified control is ok to be used;false
otherwise.protected final void assertCompositeNotNull(org.eclipse.swt.widgets.Composite composite)
composite
is not null
.composite
- The composite that is expected to be not null
.protected static final org.eclipse.swt.widgets.Composite createSpecificComposite(org.eclipse.swt.widgets.Composite parent, int nColumns, int span, boolean hgrab, boolean vgrab, boolean useFormLayout)
Composite
that can be used by subclasses in some specific cases (e.g. list
button field or string button field).parent
- The parent of the composite to create.nColumns
- The number of columns inside the created composite itself.span
- The number of columns the created composite will take up.hgrab
- Flag indicating whether composite should be made wide enough to fit the remaining horizontal space.vgrab
- Flag indicating whether composite should be made wide enough to fit the remaining vertical space.useFormLayout
- Flag indicating if a form layout is expected to be used (e.g. in form editor).protected static final org.eclipse.swt.widgets.Control createEmptySpace(org.eclipse.swt.widgets.Composite parent, int span)
The specified composite
is assumed to have either TableWrapLayout
or GridLayout
layout.
parent
- The parent composite.span
- The number of column cells the empty space control will take up.public static final org.eclipse.swt.widgets.Control createEmptySpace(org.eclipse.swt.widgets.Composite parent)
parent
- The parent composite.public org.eclipse.swt.widgets.Control[] fillIntoGrid(org.eclipse.swt.widgets.Composite parent, int nColumns)
IField
fillIntoGrid
in interface IField
parent
- The parent composite into which this field must be created.nColumns
- The number of columns over which this field must span.GridLayout
,
FormLayout
protected org.eclipse.swt.widgets.Control[] doFillIntoGrid(org.eclipse.swt.widgets.Composite parent, int nColumns)
/!\ | To be re-implemented by platform field implementors. | /!\ |
parent
- The parent composite of this dialog field.nColumns
- The number of columns of this dialog field.protected final org.eclipse.swt.widgets.Control getLabelControl(org.eclipse.swt.widgets.Composite parent, int hspan)
parent
- The parent composite inside which label control must exist.hspan
- The number of columns the label control is supposed to take up.protected final org.eclipse.swt.widgets.Control getLabelControl(org.eclipse.swt.widgets.Composite parent, boolean multiLine, int hspan)
After having requested label control creation (when label does not already exist), method sets layout data on label according to parent layout (form layout or not).
parent
- The parent composite inside which label control must be created.multiLine
- Flag indicating if field is made of several lines or not.hspan
- The number of columns the label control is supposed to take up.protected org.eclipse.swt.widgets.Control createLabelControl(org.eclipse.swt.widgets.Composite parent, boolean multiLine, int hspan)
For the creation of the label control, widget factory is used if possible.
parent
- The parent composite (supposed to be not null).multiLine
- true if this field is multi-line.hspan
- The number of columns the text widget must span.public org.eclipse.swt.widgets.Control getLabelControl()
getLabelControl
in interface IField
protected int getNumberOfControls()
public void setLabelText(java.lang.String labeltext)
IField
setLabelText
in interface IField
labeltext
- The text of the label.public void setToolTipText(java.lang.String toolTip)
IField
setToolTipText
in interface IField
toolTip
- The text to use as tool tip.public final boolean isEnabled()
public final void setEnabled(boolean enabled)
setEnabled
in interface IField
enabled
- The new enable state.protected void updateEnableState()
public void dispose()
IField
protected boolean setFocus()
true
if the dialog field can take focus. To be
re-implemented by dialog field implementors.public final void addFieldListener(IFieldListener listener)
IField
addFieldListener
in interface IField
listener
- The field listener to add.public void removeFieldListener(IFieldListener listener)
IField
removeFieldListener
in interface IField
listener
- The field listener to remove.protected void dialogFieldChanged()
public void refresh()