net.sf.commonclipse.preferences
Class AddRemoveListFieldEditor

java.lang.Object
  extended by org.eclipse.jface.preference.FieldEditor
      extended by net.sf.commonclipse.preferences.AddRemoveListFieldEditor

public class AddRemoveListFieldEditor
extends org.eclipse.jface.preference.FieldEditor

A field editor for displaying and storing a list of strings. Buttons are provided for adding items to the list and removing items from the list. Implementation from http://www.eclipse.org/articles/Article-Field-Editors/field_editors.html

Version:
$Revision: 1.5 $ ($Author: fgiust $)
Author:
fgiust

Field Summary
(package private)  org.eclipse.swt.widgets.List list
          The list of items.
 
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
 
Constructor Summary
AddRemoveListFieldEditor(java.lang.String name, java.lang.String labelText, org.eclipse.swt.widgets.Composite parent)
          Creates a string field editor of unlimited width.
AddRemoveListFieldEditor(java.lang.String name, java.lang.String labelText, java.lang.String addButtonText, java.lang.String removeButtonText, org.eclipse.swt.widgets.Composite parent)
          Creates a string field editor of unlimited width.
 
Method Summary
(package private)  void add()
          Adds the string in the text field to the list.
protected  void adjustForNumColumns(int numColumns)
           
static boolean containsOnlyValidChars(java.lang.String str)
          Checks the the given String doesn't contains invalid chars.
protected  void doFillIntoGrid(org.eclipse.swt.widgets.Composite parent, int numColumns)
           
protected  void doLoad()
           
protected  void doLoadDefault()
           
protected  void doStore()
           
 int getNumberOfControls()
           
(package private)  void selectionChanged()
          Sets the enablement of the remove button depending on the selection in the list.
 void setAddButtonText(java.lang.String text)
          Sets the label for the button that adds the contents of the text field to the list.
 void setRemoveButtonText(java.lang.String text)
          Sets the label for the button that removes the selected item from the list.
 void setSeparator(java.lang.String listSeparator)
          Sets the string that separates items in the list when the list is stored as a single String in the preference store.
 
Methods inherited from class org.eclipse.jface.preference.FieldEditor
applyFont, checkParent, clearErrorMessage, clearMessage, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, createControl, dispose, fillIntoGrid, fireStateChanged, fireValueChanged, getFieldEditorFontName, getLabelControl, getLabelControl, getLabelText, getPage, getPreferenceName, getPreferencePage, getPreferenceStore, init, isValid, load, loadDefault, presentsDefaultValue, refreshValidState, setButtonLayoutData, setEnabled, setFocus, setLabelText, setPage, setPreferenceName, setPreferencePage, setPreferenceStore, setPresentsDefaultValue, setPropertyChangeListener, showErrorMessage, showMessage, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list

org.eclipse.swt.widgets.List list
The list of items.

Constructor Detail

AddRemoveListFieldEditor

public AddRemoveListFieldEditor(java.lang.String name,
                                java.lang.String labelText,
                                org.eclipse.swt.widgets.Composite parent)
Creates a string field editor of unlimited width. Use the method setTextLimit to limit the text.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
parent - the parent of the field editor's control

AddRemoveListFieldEditor

public AddRemoveListFieldEditor(java.lang.String name,
                                java.lang.String labelText,
                                java.lang.String addButtonText,
                                java.lang.String removeButtonText,
                                org.eclipse.swt.widgets.Composite parent)
Creates a string field editor of unlimited width. Use the method setTextLimit to limit the text.

Parameters:
name - the name of the preference this field editor works on
labelText - the label text of the field editor
addButtonText - text for the "add" button
removeButtonText - text for the "remove" buttom
parent - the parent of the field editor's control
Method Detail

adjustForNumColumns

protected void adjustForNumColumns(int numColumns)
Specified by:
adjustForNumColumns in class org.eclipse.jface.preference.FieldEditor
See Also:
FieldEditor.adjustForNumColumns(int)

doFillIntoGrid

protected void doFillIntoGrid(org.eclipse.swt.widgets.Composite parent,
                              int numColumns)
Specified by:
doFillIntoGrid in class org.eclipse.jface.preference.FieldEditor
See Also:
(Composite, int)

doLoad

protected void doLoad()
Specified by:
doLoad in class org.eclipse.jface.preference.FieldEditor
See Also:
FieldEditor.doLoad()

doLoadDefault

protected void doLoadDefault()
Specified by:
doLoadDefault in class org.eclipse.jface.preference.FieldEditor
See Also:
FieldEditor.doLoadDefault()

doStore

protected void doStore()
Specified by:
doStore in class org.eclipse.jface.preference.FieldEditor
See Also:
FieldEditor.doStore()

getNumberOfControls

public int getNumberOfControls()
Specified by:
getNumberOfControls in class org.eclipse.jface.preference.FieldEditor
See Also:
FieldEditor.getNumberOfControls()

add

void add()
Adds the string in the text field to the list.


containsOnlyValidChars

public static boolean containsOnlyValidChars(java.lang.String str)
Checks the the given String doesn't contains invalid chars.

Parameters:
str - input String
Returns:
true if the string doesn't contains invalid chars.

setAddButtonText

public void setAddButtonText(java.lang.String text)
Sets the label for the button that adds the contents of the text field to the list.

Parameters:
text - "add" button text

setRemoveButtonText

public void setRemoveButtonText(java.lang.String text)
Sets the label for the button that removes the selected item from the list.

Parameters:
text - "remove" button text

setSeparator

public void setSeparator(java.lang.String listSeparator)
Sets the string that separates items in the list when the list is stored as a single String in the preference store.

Parameters:
listSeparator - token used as a delimiter when converting the array in a single string

selectionChanged

void selectionChanged()
Sets the enablement of the remove button depending on the selection in the list.



Copyright © 2003-2005 sourceforge. All Rights Reserved.