org.eclipse.xtext.ui.editor.tasks.dialogfields
Class DialogField

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.tasks.dialogfields.DialogField
Direct Known Subclasses:
ComboDialogField, ListDialogField, SelectionButtonDialogField, StringDialogField

public class DialogField
extends java.lang.Object

Base class of all dialog fields. Dialog fields manage controls together with the model, independed from the creation time of the widgets. - support for automated layouting. - enable / disable, set focus a concept of the base class. DialogField have a label.


Field Summary
protected  java.lang.String fLabelText
           
 
Constructor Summary
DialogField()
           
 
Method Summary
protected  void assertCompositeNotNull(org.eclipse.swt.widgets.Composite comp)
           
protected  void assertEnoughColumns(int nColumns)
           
static org.eclipse.swt.widgets.Control createEmptySpace(org.eclipse.swt.widgets.Composite parent)
          Creates a spacer control.
static org.eclipse.swt.widgets.Control createEmptySpace(org.eclipse.swt.widgets.Composite parent, int span)
          Creates a spacer control with the given span.
 void dialogFieldChanged()
          Programatical invocation of a dialog field change.
 org.eclipse.swt.widgets.Control[] doFillIntoGrid(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.Label getLabelControl(org.eclipse.swt.widgets.Composite parent)
          Creates or returns the created label widget.
 int getNumberOfControls()
          Returns the number of columns of the dialog field.
protected static org.eclipse.swt.layout.GridData gridDataForLabel(int span)
           
 boolean isEnabled()
          Gets the enable state of the dialog field.
protected  boolean isOkToUse(org.eclipse.swt.widgets.Control control)
          Tests is the control is not null and not disposed.
 void postSetFocusOnDialogField(org.eclipse.swt.widgets.Display display)
          Posts setFocus to the display event queue.
 void refresh()
          Brings the UI in sync with the model.
 void setDialogFieldListener(IDialogFieldListener listener)
          Defines the listener for this dialog field.
 void setEnabled(boolean enabled)
          Sets the enable state of the dialog field.
 boolean setFocus()
          Tries to set the focus to the dialog field.
 void setLabelText(java.lang.String labeltext)
          Sets the label of the dialog field.
protected  void updateEnableState()
          Called when the enable state changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fLabelText

protected java.lang.String fLabelText
Constructor Detail

DialogField

public DialogField()
Method Detail

setLabelText

public void setLabelText(java.lang.String labeltext)
Sets the label of the dialog field.


setDialogFieldListener

public final void setDialogFieldListener(IDialogFieldListener listener)
Defines the listener for this dialog field.


dialogFieldChanged

public void dialogFieldChanged()
Programatical invocation of a dialog field change.


setFocus

public boolean setFocus()
Tries to set the focus to the dialog field. Returns true if the dialog field can take focus. To be reimplemented by dialog field implementors.


postSetFocusOnDialogField

public void postSetFocusOnDialogField(org.eclipse.swt.widgets.Display display)
Posts setFocus to the display event queue.


doFillIntoGrid

public org.eclipse.swt.widgets.Control[] doFillIntoGrid(org.eclipse.swt.widgets.Composite parent,
                                                        int nColumns)
Creates all controls of the dialog field and fills it to a composite. The composite is assumed to have MGridLayout as layout. The dialog field will adjust its controls' spans to the number of columns given. To be reimplemented by dialog field implementors.


getNumberOfControls

public int getNumberOfControls()
Returns the number of columns of the dialog field. To be reimplemented by dialog field implementors.


gridDataForLabel

protected static org.eclipse.swt.layout.GridData gridDataForLabel(int span)

getLabelControl

public org.eclipse.swt.widgets.Label getLabelControl(org.eclipse.swt.widgets.Composite parent)
Creates or returns the created label widget.

Parameters:
parent - The parent composite or null if the widget has already been created.

createEmptySpace

public static org.eclipse.swt.widgets.Control createEmptySpace(org.eclipse.swt.widgets.Composite parent)
Creates a spacer control.

Parameters:
parent - The parent composite

createEmptySpace

public static org.eclipse.swt.widgets.Control createEmptySpace(org.eclipse.swt.widgets.Composite parent,
                                                               int span)
Creates a spacer control with the given span. The composite is assumed to have MGridLayout as layout.

Parameters:
parent - The parent composite

isOkToUse

protected final boolean isOkToUse(org.eclipse.swt.widgets.Control control)
Tests is the control is not null and not disposed.


setEnabled

public final void setEnabled(boolean enabled)
Sets the enable state of the dialog field.


updateEnableState

protected void updateEnableState()
Called when the enable state changed. To be extended by dialog field implementors.


refresh

public void refresh()
Brings the UI in sync with the model. Only needed when model was changed in different thread whil UI was lready created.


isEnabled

public final boolean isEnabled()
Gets the enable state of the dialog field.


assertCompositeNotNull

protected final void assertCompositeNotNull(org.eclipse.swt.widgets.Composite comp)

assertEnoughColumns

protected final void assertEnoughColumns(int nColumns)