edu.rice.cs.drjava.ui.config
Class OptionComponent<T>

java.lang.Object
  extended by edu.rice.cs.drjava.ui.config.OptionComponent<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BooleanOptionComponent, ButtonComponent, ColorOptionComponent, DirectoryOptionComponent, FileOptionComponent, FontOptionComponent, ForcedChoiceOptionComponent, IntegerOptionComponent, KeyStrokeOptionComponent, LabelComponent, StringOptionComponent, ToolbarOptionComponent, VectorOptionComponent

public abstract class OptionComponent<T>
extends Object
implements Serializable

The graphical form of an Option. Provides a way to see the values of Option while running DrJava and perform live updating of Options.

Version:
$Id: OptionComponent.java 4691 2008-12-02 23:33:27Z dlsmith $
See Also:
Serialized Form

Nested Class Summary
static interface OptionComponent.ChangeListener
          Interface for change listener.
 
Field Summary
protected  boolean _entireColumn
           
protected  JLabel _label
           
protected  String _labelText
           
protected  Option<T> _option
           
protected  SwingFrame _parent
           
 
Constructor Summary
OptionComponent(Option<T> option, String labelText, SwingFrame parent)
           
OptionComponent(String labelText, SwingFrame parent)
          Special constructor for degenerate option components does not take an option.
 
Method Summary
 void addChangeListener(OptionComponent.ChangeListener listener)
          Adds a change listener to this component.
abstract  JComponent getComponent()
          Returns the JComponent to display for this OptionComponent.
 boolean getEntireColumn()
          Whether the component should occupy the entire column.
 JLabel getLabel()
           
 String getLabelText()
           
 Option<T> getOption()
           
protected  void notifyChangeListeners()
          Notify all change listeners of a change.
 void removeChangeListener(OptionComponent.ChangeListener listener)
          Removes a change listener to this component.
 void resetToCurrent()
          Resets the entry field to reflect the actual stored value for the option.
 void resetToDefault()
          Resets the actual value of the component to the original default.
abstract  void setDescription(String description)
          Sets the detailed description text for all components in this OptionComponent.
 OptionComponent<T> setEntireColumn(boolean entireColumn)
          Whether the component should occupy the entire column.
abstract  void setValue(T value)
          Sets the value that is currently displayed by this component.
 void showErrorMessage(String title, OptionParseException e)
           
 void showErrorMessage(String title, String value, String message)
           
abstract  boolean updateConfig()
          Updates the appropriate configuration option with the new value if different from the old one and legal.
 boolean useEntireColumn()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_option

protected final Option<T> _option

_label

protected final JLabel _label

_parent

protected final SwingFrame _parent

_entireColumn

protected volatile boolean _entireColumn

_labelText

protected volatile String _labelText
Constructor Detail

OptionComponent

public OptionComponent(Option<T> option,
                       String labelText,
                       SwingFrame parent)

OptionComponent

public OptionComponent(String labelText,
                       SwingFrame parent)
Special constructor for degenerate option components does not take an option.

Parameters:
labelText - Text for descriptive label of this option.
parent - The parent frame.
Method Detail

getOption

public Option<T> getOption()

getLabelText

public String getLabelText()

getLabel

public JLabel getLabel()

useEntireColumn

public boolean useEntireColumn()

getComponent

public abstract JComponent getComponent()
Returns the JComponent to display for this OptionComponent.


setDescription

public abstract void setDescription(String description)
Sets the detailed description text for all components in this OptionComponent. Should be called by subclasses that wish to display a description.

Parameters:
description - the description of the component

setEntireColumn

public OptionComponent<T> setEntireColumn(boolean entireColumn)
Whether the component should occupy the entire column.


getEntireColumn

public boolean getEntireColumn()
Whether the component should occupy the entire column.


updateConfig

public abstract boolean updateConfig()
Updates the appropriate configuration option with the new value if different from the old one and legal. Any changes should be done immediately so that current and future references to the Option should reflect the changes.

Returns:
false, if value is invalid; otherwise true. This method may spawn asynchronous event thread tasks via firing OptionListeners and textField DocumentListeners.

resetToCurrent

public void resetToCurrent()
Resets the entry field to reflect the actual stored value for the option.


resetToDefault

public void resetToDefault()
Resets the actual value of the component to the original default.


setValue

public abstract void setValue(T value)
Sets the value that is currently displayed by this component.


showErrorMessage

public void showErrorMessage(String title,
                             OptionParseException e)

showErrorMessage

public void showErrorMessage(String title,
                             String value,
                             String message)

addChangeListener

public void addChangeListener(OptionComponent.ChangeListener listener)
Adds a change listener to this component.

Parameters:
listener - listener to add

removeChangeListener

public void removeChangeListener(OptionComponent.ChangeListener listener)
Removes a change listener to this component.

Parameters:
listener - listener to remove

notifyChangeListeners

protected void notifyChangeListeners()
Notify all change listeners of a change. Notification performed in the event thread.