org.openoffice.ide.eclipse.core.gui.rows
Class LabeledRow

java.lang.Object
  extended by org.openoffice.ide.eclipse.core.gui.rows.LabeledRow
Direct Known Subclasses:
BooleanRow, ChoiceRow, DialogRow, FileRow, TextRow

public abstract class LabeledRow
extends java.lang.Object

Basic class for a property row. Subclasses will override:

Their constructor should respect the following steps:
  1. Use the property constructor
  2. Create the label and field controls to be used
  3. Call createContents

Author:
cedricbosdo

Field Summary
static int LAYOUT_COLUMNS
           
protected  org.eclipse.swt.widgets.Control mBrowse
           
protected  org.eclipse.swt.widgets.Control mField
           
protected  org.eclipse.swt.widgets.Control mLabel
           
protected  IFieldChangedListener mListener
           
protected  java.lang.String mProperty
           
 
Constructor Summary
LabeledRow(org.eclipse.swt.widgets.Composite pParent, java.lang.String pProperty, org.eclipse.swt.widgets.Control pLabel, org.eclipse.swt.widgets.Control pField, java.lang.String pBrowseText, boolean pLink)
          Create a field base.
LabeledRow(java.lang.String pProperty)
          Simple constructor only defining the property.
 
Method Summary
 void addBrowseSelectionListener(org.eclipse.swt.events.SelectionListener pListener)
          Add a selection listener to the browse link or button (depends on the arguments of the constructor).
protected  void createContent(org.eclipse.swt.widgets.Composite pParent, org.eclipse.swt.widgets.Control pLabel, org.eclipse.swt.widgets.Control pField, java.lang.String pBrowseText, boolean pLink)
          Stores the row controls, creates the button if its text is not null and layout the controls.
protected  void fillRow(org.eclipse.swt.widgets.Composite pParent)
          Method organizing the different graphic components in the parent composite.
protected  void fireFieldChangedEvent(FieldEvent pEvent)
          Fires a change of the row.
 java.lang.String getLabel()
          Returns the row label.
 java.lang.String getProperty()
          Property getter.
abstract  java.lang.String getValue()
          Get or calculate the value of this property.
 void removeFieldChangedlistener()
          Removes the field changes listener.
 void setEnabled(boolean pEnabled)
          Set the enabled state of the field and the browse button if the latter exists.
 void setFieldChangedListener(IFieldChangedListener pListener)
          Defines the listener that will react to the field changes.
 void setLabel(java.lang.String pNewLabel)
          Replace the current label by a new one.
 void setTooltip(java.lang.String pTooltip)
          Set the tooltip message of the row.
 void setVisible(boolean pVisible)
          Toggle the visibily of the line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_COLUMNS

public static final int LAYOUT_COLUMNS
See Also:
Constant Field Values

mLabel

protected org.eclipse.swt.widgets.Control mLabel

mField

protected org.eclipse.swt.widgets.Control mField

mBrowse

protected org.eclipse.swt.widgets.Control mBrowse

mProperty

protected java.lang.String mProperty

mListener

protected IFieldChangedListener mListener
Constructor Detail

LabeledRow

public LabeledRow(java.lang.String pProperty)
Simple constructor only defining the property. This constructor should only be called by the subclasses.

Parameters:
pProperty - property value given in the field changed event.

LabeledRow

public LabeledRow(org.eclipse.swt.widgets.Composite pParent,
                  java.lang.String pProperty,
                  org.eclipse.swt.widgets.Control pLabel,
                  org.eclipse.swt.widgets.Control pField,
                  java.lang.String pBrowseText,
                  boolean pLink)
Create a field base. This constructor may not be used by subclasses.

Parameters:
pParent - Composite in which the row will be added
pProperty - Property value given in the field changed event.
pLabel - Control to use for the label. The most common is a text control, but it could be something else like an hyperlink.
pField - Control containing the field data.
pBrowseText - Button text. If null, the button isn't created.
pLink - the browse is shown as a link if true, otherwise it is a button.
Method Detail

setTooltip

public void setTooltip(java.lang.String pTooltip)
Set the tooltip message of the row.

Parameters:
pTooltip - the tooltip message

setLabel

public void setLabel(java.lang.String pNewLabel)
Replace the current label by a new one.

Parameters:
pNewLabel - New label to use

getLabel

public java.lang.String getLabel()
Returns the row label.

Returns:
the row label

addBrowseSelectionListener

public void addBrowseSelectionListener(org.eclipse.swt.events.SelectionListener pListener)
Add a selection listener to the browse link or button (depends on the arguments of the constructor).

Parameters:
pListener - the listener to add

createContent

protected void createContent(org.eclipse.swt.widgets.Composite pParent,
                             org.eclipse.swt.widgets.Control pLabel,
                             org.eclipse.swt.widgets.Control pField,
                             java.lang.String pBrowseText,
                             boolean pLink)
Stores the row controls, creates the button if its text is not null and layout the controls.

Parameters:
pParent - the parent composite where to create the controls
pLabel - the control for the label
pField - the control for the field
pBrowseText - the text to show on the right button of the row.
pLink - the browse is shown as a link if true, otherwise it is a button.

getProperty

public java.lang.String getProperty()
Property getter.

Returns:
the property

getValue

public abstract java.lang.String getValue()
Get or calculate the value of this property.

Returns:
the property value

fillRow

protected void fillRow(org.eclipse.swt.widgets.Composite pParent)
Method organizing the different graphic components in the parent composite.

Parameters:
pParent - Parent composite.

setFieldChangedListener

public void setFieldChangedListener(IFieldChangedListener pListener)
Defines the listener that will react to the field changes.

Parameters:
pListener - field changes listener

removeFieldChangedlistener

public void removeFieldChangedlistener()
Removes the field changes listener.


fireFieldChangedEvent

protected void fireFieldChangedEvent(FieldEvent pEvent)
Fires a change of the row.

Parameters:
pEvent - the event to throw for the change

setVisible

public void setVisible(boolean pVisible)
Toggle the visibily of the line.

Parameters:
pVisible - if true the components will visible, otherwise they will be hidden.

setEnabled

public void setEnabled(boolean pEnabled)
Set the enabled state of the field and the browse button if the latter exists.

Parameters:
pEnabled - true activate the row, otherwise the row is desactivated