de.cau.cs.kieler.core.ui.util
Class ComboHistoryHandler

java.lang.Object
  extended by de.cau.cs.kieler.core.ui.util.ComboHistoryHandler

public class ComboHistoryHandler
extends Object

This class can be used to manage the items in a combo box as a history. The history has a certain size. New items are added to the top, while keeping the history at the given size. Existing items are just moved to the top. The combo history manager provides ways to load and restore the combo box's settings using a DialogSettings instance.

Rating yellow
2010-03-14 reviewed by msp, pkl

Constructor Summary
ComboHistoryHandler(Combo combo, int historySize)
          Constructs a new instance for the given combo box with the given history size.
 
Method Summary
 void recordAndDisplay(String item)
          Adds the given item to the history and sets it as the combo box's text.
 void restoreHistory(IDialogSettings settings, String key)
          Loads the history from the given dialog settings.
 void saveHistory(IDialogSettings settings, String key)
          Saves the history in the given dialog settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComboHistoryHandler

public ComboHistoryHandler(Combo combo,
                           int historySize)
Constructs a new instance for the given combo box with the given history size.

Parameters:
combo - the combo box whose history to manage.
historySize - size of the history.
Method Detail

recordAndDisplay

public void recordAndDisplay(String item)
Adds the given item to the history and sets it as the combo box's text. Empty items or null items are ignored history-wise, but set as the combo box's new text.

Parameters:
item - the item to add.

saveHistory

public void saveHistory(IDialogSettings settings,
                        String key)
Saves the history in the given dialog settings.

Parameters:
settings - the settings to store the history in.
key - the key to use.

restoreHistory

public void restoreHistory(IDialogSettings settings,
                           String key)
Loads the history from the given dialog settings.

Parameters:
settings - the settings to load the history from.
key - the key to use.