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

java.lang.Object
  extended by org.openoffice.ide.eclipse.core.gui.rows.LabeledRow
      extended by org.openoffice.ide.eclipse.core.gui.rows.ChoiceRow
Direct Known Subclasses:
AbstractConfigRow

public class ChoiceRow
extends LabeledRow

Row class that could managed a combo box to select a value among others

In order to use this class correctly, please add items and define the default one. As every row type, don't forget to set the Modification listener to be notified of the value changes. This class supports internationalized items since the version 1.0.3.

Author:
cedricbosdo
See Also:
LabeledRow

Field Summary
 
Fields inherited from class org.openoffice.ide.eclipse.core.gui.rows.LabeledRow
LAYOUT_COLUMNS, mBrowse, mField, mLabel, mListener, mProperty
 
Constructor Summary
ChoiceRow(org.eclipse.swt.widgets.Composite pParent, java.lang.String pProperty, java.lang.String pLabel, java.lang.String pBrowse, boolean pLink)
          Create a new choice row with a button on the right.
 
Method Summary
 void add(java.lang.String pItem)
          Append the item at the end of the item list.
 void add(java.lang.String pItem, int pIndex)
          Adds the provided item at the provided position.
 void add(java.lang.String pText, java.lang.String pValue)
          adds an internationalized item at the end of the list.
 void add(java.lang.String pText, java.lang.String pValue, int pIndex)
          Adds a translated item.
 void addAll(java.lang.String[] pItems)
          Adds all the strings contained in items at the end of the item list.
 java.lang.String getItem(int pIndex)
          Deprecated. This methods only returns the text of the item, use getValue() to get the selected value.
 int getItemCount()
          Returns the number of items of the combo box.
 java.lang.String getValue()
          Get or calculate the value of this property.
 java.lang.String getValue(int pIndex)
          Returns the value of the i-th item.
 void remove(int pIndex)
          Remove the item at the position corresponding to index.
 void remove(int pStart, int pEnd)
          Removes all the items between start and end positions.
 void remove(java.lang.String pText)
          Removes the items with the provided text.
 void removeAll()
          Removes all the items of the combo box.
 void select(int pIndex)
          Select the item at the position corresponding to index.
 void select(java.lang.String pValue)
          Set the provided text as the active item if the item is present in the choice.
 void setBrowseSelectionListener(org.eclipse.swt.events.SelectionListener pListener)
          Set the listener for the browse button action.
 
Methods inherited from class org.openoffice.ide.eclipse.core.gui.rows.LabeledRow
addBrowseSelectionListener, createContent, fillRow, fireFieldChangedEvent, getLabel, getProperty, removeFieldChangedlistener, setEnabled, setFieldChangedListener, setLabel, setTooltip, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChoiceRow

public ChoiceRow(org.eclipse.swt.widgets.Composite pParent,
                 java.lang.String pProperty,
                 java.lang.String pLabel,
                 java.lang.String pBrowse,
                 boolean pLink)
Create a new choice row with a button on the right. The parent composite should have a grid layout with 3 horizontal spans.

Parameters:
pParent - the parent composite where to create the row
pProperty - the property name of the row
pLabel - label the label to print on the left of the row
pBrowse - the label of the button
pLink - true to show a link for the browse button
Method Detail

setBrowseSelectionListener

public void setBrowseSelectionListener(org.eclipse.swt.events.SelectionListener pListener)
Set the listener for the browse button action. There is only on listener, because there is generally no need for more.

Parameters:
pListener - the browse action listener

addAll

public void addAll(java.lang.String[] pItems)
Adds all the strings contained in items at the end of the item list.

Parameters:
pItems - Array of items to appends to the existing ones.

add

public void add(java.lang.String pText,
                java.lang.String pValue,
                int pIndex)
Adds a translated item.

This method adds the text to the combo box and deals with its translation. If the text is already contained in the box, nothing will be done.

Parameters:
pText - the translated item text
pValue - the item value
pIndex - the item index

add

public void add(java.lang.String pText,
                java.lang.String pValue)
adds an internationalized item at the end of the list.

Parameters:
pText - the internationalized text
pValue - the value of the item
See Also:
add(String, String, int)

add

public void add(java.lang.String pItem,
                int pIndex)
Adds the provided item at the provided position.

Parameters:
pItem - text of the item to add
pIndex - position where to add the item in the list
See Also:
add(java.lang.String, java.lang.String, int)

add

public void add(java.lang.String pItem)
Append the item at the end of the item list.

Parameters:
pItem - text of the item to append
See Also:
add(java.lang.String, java.lang.String, int)

remove

public void remove(java.lang.String pText)
Removes the items with the provided text.

Parameters:
pText - text of the items to remove
See Also:
Combo.remove(java.lang.String)

remove

public void remove(int pIndex)
Remove the item at the position corresponding to index.

Parameters:
pIndex - position of the item to remove
See Also:
Combo.remove(int)

remove

public void remove(int pStart,
                   int pEnd)
Removes all the items between start and end positions.

Parameters:
pStart - position of the first item to remove
pEnd - position of the last item to remove
See Also:
Combo.remove(int, int)

removeAll

public void removeAll()
Removes all the items of the combo box.

See Also:
Combo.removeAll()

select

public void select(int pIndex)
Select the item at the position corresponding to index.

Parameters:
pIndex - position of the item to select
See Also:
Combo.select(int)

select

public void select(java.lang.String pValue)
Set the provided text as the active item if the item is present in the choice. Otherwise, do nothing.

Parameters:
pValue - value of the item to select

getItem

public java.lang.String getItem(int pIndex)
Deprecated. This methods only returns the text of the item, use getValue() to get the selected value.

Returns the index the item of the choice.

Parameters:
pIndex - position of the item to fetch
Returns:
the index the item of the choice
See Also:
Combo.getItem(int)

getItemCount

public int getItemCount()
Returns the number of items of the combo box.

Returns:
number of items of the combo box
See Also:
Combo.getItemCount()

getValue

public java.lang.String getValue()
Description copied from class: LabeledRow
Get or calculate the value of this property.

Specified by:
getValue in class LabeledRow
Returns:
the selected value.
Since:
1.0.3 This method returns the language independent value of the item

getValue

public java.lang.String getValue(int pIndex)
Returns the value of the i-th item.

Parameters:
pIndex - the index of the value to get
Returns:
the language independent value of the item