com.limegroup.gnutella.gui
Class StandardListEditor

java.lang.Object
  extended bycom.limegroup.gnutella.gui.StandardListEditor

public final class StandardListEditor
extends java.lang.Object

This reusable component is a list with buttons for adding and removing elements. The add button brings up a dialog window to retrieve the element to add from the user. The remove button is only enabled when there is an item selected in the list.


Constructor Summary
StandardListEditor(java.awt.event.ActionListener listener)
          Creates a StandardListEditor with the default settings for the names of the add and remove buttons and that uses the specified ActionListener instance as the listener for the add button.
StandardListEditor(java.lang.String INPUT_FIELD_KEY)
          Creates a StandardListEditor with the list of elements on the left and buttons for adding and removing elements on the right.
StandardListEditor(java.lang.String ADD_BUTTON_KEY, java.lang.String REMOVE_BUTTON_KEY, java.lang.String INPUT_FIELD_KEY)
          More flexible constructor that allows the text for the add and remove buttons to be set and that allows a custom ActionListener for the add button.
 
Method Summary
 void addFile(java.io.File file)
          Adds the specified File instance to the end of the list.
 void addString(java.lang.String string)
          Adds the specified String instance to the end of the list.
 void clearSelection()
          Clears the selections in the list.
 java.awt.Component getComponent()
          Provides access to the wrapped Component of the StandardListEditor.
 java.io.File[] getDataAsFileArray()
          Returns an array of the underlying data represented as File instances.
 java.lang.Object[] getDataAsObjectArray()
          Returns an array of the underlying data represented as objects.
 java.lang.String[] getDataAsStringArray()
          Returns an array of the underlying data represented as strings by calling toString() on each element.
 boolean getListChanged()
          Returns whether or not the list has changed since the last call to reset the list.
 void resetList()
          Resets the value for whether or not the list has changed to false.
 void setListData(java.io.File[] data)
          Sets the data in the underlying ListModel.
 void setListData(java.lang.String[] data)
          Sets the data in the underlying ListModel.
 void setListData(java.util.Vector data)
          Sets the data in the underlying ListModel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardListEditor

public StandardListEditor(java.lang.String INPUT_FIELD_KEY)
Creates a StandardListEditor with the list of elements on the left and buttons for adding and removing elements on the right. The key allows for a custom label for the text field in the dialog window that the "Add..." button pops up. For example, using

OPTIONS_AUTO_CONNECT_INPUT_FIELD_LABEL=Enter Host Address:

in the messages bundle will make "Enter Host Address: " appear as the label for the text field in dialog window popped up by the "add" button.

Parameters:
INPUT_FIELD_KEY - the key for the locale-specific label for the dialog window popped up by the "Add..." button

StandardListEditor

public StandardListEditor(java.awt.event.ActionListener listener)
Creates a StandardListEditor with the default settings for the names of the add and remove buttons and that uses the specified ActionListener instance as the listener for the add button.


StandardListEditor

public StandardListEditor(java.lang.String ADD_BUTTON_KEY,
                          java.lang.String REMOVE_BUTTON_KEY,
                          java.lang.String INPUT_FIELD_KEY)
More flexible constructor that allows the text for the add and remove buttons to be set and that allows a custom ActionListener for the add button.

Parameters:
ADD_BUTTON_KEY - the key for the locale-specific string to use for the add button
REMOVE_BUTTON_KEY - the key for the locale-specific string to use for the remove button
INPUT_FIELD_KEY - the key for the locale-specific string to use for the label in the generic text input component used by default
Method Detail

getComponent

public java.awt.Component getComponent()
Provides access to the wrapped Component of the StandardListEditor. This is the Component that other gui elements should add.

Returns:
the underlying Component that contains all of the elements fo the StandardListEditor

addFile

public void addFile(java.io.File file)
Adds the specified File instance to the end of the list.

Parameters:
file - the File to add

addString

public void addString(java.lang.String string)
Adds the specified String instance to the end of the list.

Parameters:
string - the String to add

setListData

public void setListData(java.util.Vector data)
Sets the data in the underlying ListModel.

Parameters:
data - the Vector containing data for the model

setListData

public void setListData(java.io.File[] data)
Sets the data in the underlying ListModel.

Parameters:
data - array of File instances containing the data for the model

setListData

public void setListData(java.lang.String[] data)
Sets the data in the underlying ListModel.

Parameters:
data - array of String instances containing the data for the model

clearSelection

public void clearSelection()
Clears the selections in the list.


getDataAsStringArray

public java.lang.String[] getDataAsStringArray()
Returns an array of the underlying data represented as strings by calling toString() on each element.

Returns:
the list data as an array of strings.

getDataAsFileArray

public java.io.File[] getDataAsFileArray()
Returns an array of the underlying data represented as File instances.

Returns:
the list data as an array of File instances.

getDataAsObjectArray

public java.lang.Object[] getDataAsObjectArray()
Returns an array of the underlying data represented as objects.

Returns:
the list data as an array of objects.

getListChanged

public boolean getListChanged()
Returns whether or not the list has changed since the last call to reset the list. Note that this will not be accurate if you use your own ActionListener for the add button. In this case, this will return whether or not elements have been removed from the list.

Returns:
true if the list has changed since the last call to reset the list, false otherwise

resetList

public void resetList()
Resets the value for whether or not the list has changed to false.