edu.rice.cs.drjava.ui.config
Class ToolbarOptionComponent

java.lang.Object
  extended by edu.rice.cs.drjava.ui.config.OptionComponent<java.lang.Boolean,javax.swing.JComponent>
      extended by edu.rice.cs.drjava.ui.config.ToolbarOptionComponent
All Implemented Interfaces:
java.io.Serializable

public class ToolbarOptionComponent
extends OptionComponent<java.lang.Boolean,javax.swing.JComponent>

The special option component for the toolbar text and toolbar icon options. Not a true OptionComponent, in that it actually represents and governs the configuration of two BooleanOptions (i.e. those corresponding to TOOLBAR_TEXT_ENABLED and TOOLBAR_ICONS_ENABLED) bypassing the the normal graphical representation with JRadioButtons, in order to comply with the special circumstances regarding their setting.

Version:
$Id: ToolbarOptionComponent.java 5232 2010-04-24 00:14:05Z mgricken $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.rice.cs.drjava.ui.config.OptionComponent
OptionComponent.ChangeListener
 
Field Summary
private  javax.swing.JPanel _buttonPanel
           
private  javax.swing.ButtonGroup _group
           
private  javax.swing.JRadioButton _iconsButton
           
private  javax.swing.JRadioButton _noneButton
           
private  javax.swing.JRadioButton _textAndIconsButton
           
private  javax.swing.JRadioButton _textButton
           
static java.lang.String ICONS_ONLY
           
static java.lang.String NONE
           
static java.lang.String TEXT_AND_ICONS
           
static java.lang.String TEXT_ONLY
           
 
Fields inherited from class edu.rice.cs.drjava.ui.config.OptionComponent
_entireColumn, _guiComponent, _label, _labelText, _option, _parent
 
Constructor Summary
ToolbarOptionComponent(java.lang.String title, SwingFrame parent)
          The constructor does not take an option since we have specific knowledge of the two options we'll need for this component.
ToolbarOptionComponent(java.lang.String title, SwingFrame parent, java.lang.String description)
          Constructor that allows for a tooltip description.
 
Method Summary
private  void _setSelected(boolean textEnabled, boolean iconsEnabled, boolean isEnabled)
          Selects the radio button corresponding to the specified configuration.
 void resetToCurrent()
          Selects the radio button corresponding to the current config options.
 void resetToDefault()
          Selects the radio button corresponding to the default values.
 void setComponent(javax.swing.JComponent component)
          Set the JComponent to display for this OptionComponent.
 void setDescription(java.lang.String description)
          Sets the tooltip description text for this option.
 void setValue(java.lang.Boolean value)
          Displays the given value.
 boolean updateConfig()
          Updates the config object with the new setting.
 
Methods inherited from class edu.rice.cs.drjava.ui.config.OptionComponent
addChangeListener, getComponent, getEntireColumn, getLabel, getLabelText, getOption, notifyChangeListeners, removeChangeListener, setEntireColumn, showErrorMessage, showErrorMessage, useEntireColumn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_noneButton

private javax.swing.JRadioButton _noneButton

_textButton

private javax.swing.JRadioButton _textButton

_iconsButton

private javax.swing.JRadioButton _iconsButton

_textAndIconsButton

private javax.swing.JRadioButton _textAndIconsButton

_group

private javax.swing.ButtonGroup _group

_buttonPanel

private javax.swing.JPanel _buttonPanel

NONE

public static final java.lang.String NONE
See Also:
Constant Field Values

TEXT_ONLY

public static final java.lang.String TEXT_ONLY
See Also:
Constant Field Values

ICONS_ONLY

public static final java.lang.String ICONS_ONLY
See Also:
Constant Field Values

TEXT_AND_ICONS

public static final java.lang.String TEXT_AND_ICONS
See Also:
Constant Field Values
Constructor Detail

ToolbarOptionComponent

public ToolbarOptionComponent(java.lang.String title,
                              SwingFrame parent)
The constructor does not take an option since we have specific knowledge of the two options we'll need for this component. We simpy access them as needed, and use OptionComponent's degenerate constructor.

Parameters:
title - the title for this panel
parent - the parent frame

ToolbarOptionComponent

public ToolbarOptionComponent(java.lang.String title,
                              SwingFrame parent,
                              java.lang.String description)
Constructor that allows for a tooltip description.

Method Detail

setDescription

public void setDescription(java.lang.String description)
Sets the tooltip description text for this option.

Specified by:
setDescription in class OptionComponent<java.lang.Boolean,javax.swing.JComponent>
Parameters:
description - the tooltip text

resetToCurrent

public void resetToCurrent()
Selects the radio button corresponding to the current config options.

Overrides:
resetToCurrent in class OptionComponent<java.lang.Boolean,javax.swing.JComponent>

resetToDefault

public void resetToDefault()
Selects the radio button corresponding to the default values.

Overrides:
resetToDefault in class OptionComponent<java.lang.Boolean,javax.swing.JComponent>

_setSelected

private void _setSelected(boolean textEnabled,
                          boolean iconsEnabled,
                          boolean isEnabled)
Selects the radio button corresponding to the specified configuration.

Parameters:
textEnabled - Whether toolbar text is enabled
iconsEnabled - Whether toolbar icons are enabled

updateConfig

public boolean updateConfig()
Updates the config object with the new setting. Should run in event thread.

Specified by:
updateConfig in class OptionComponent<java.lang.Boolean,javax.swing.JComponent>
Returns:
true if the new value is set successfully

setValue

public void setValue(java.lang.Boolean value)
Displays the given value.

Specified by:
setValue in class OptionComponent<java.lang.Boolean,javax.swing.JComponent>

setComponent

public void setComponent(javax.swing.JComponent component)
Set the JComponent to display for this OptionComponent.

Overrides:
setComponent in class OptionComponent<java.lang.Boolean,javax.swing.JComponent>
Parameters:
component - GUI component