Class ComboHistoryHelper

java.lang.Object
org.csstudio.ui.util.helpers.ComboHistoryHelper

public class ComboHistoryHelper extends Object
Decorates a Combo box to maintain the history.

Newly entered items are added to the top of the combo list, dropping last items off the list when reaching a configurable maximum list size. If an item is selected/entered again, it will pop at the beginning of the list (so that continuously used items are not lost).

You must

  • either implement itemSelected() or newSelection() to handle entered/selected values.
  • decide if you want to call loadSettings() to restore the saved values
  • save values via saveSettings, or use the save_on_dispose option of the constructor.
  • Constructor Details

    • ComboHistoryHelper

      public ComboHistoryHelper(IDialogSettings settings, String tag, Combo combo)
      Attach helper to given combo box, using max list length.
      Parameters:
      settings - where to persist the combo box list
      tag - tag used for persistence
      combo - the combo box
    • ComboHistoryHelper

      public ComboHistoryHelper(IDialogSettings settings, String tag, Combo combo, int max, boolean saveOnDispose)
      Attach helper to given combo box, using max list length.
      Parameters:
      settings - where to persist the combo box list
      tag - tag used for persistence
      combo - the combo box
      max - number of elements to keep in history
      saveOnDispose - whether current values should be saved at widget disposal
  • Method Details

    • changeSelection

      public void changeSelection(String entry)
    • addEntry

      public void addEntry(String newEntry)
      Adds a new entry to the list. If entry already there, do nothing.
      Parameters:
      newEntry - the new value
    • itemSelected

      public void itemSelected(String selection)
      Invoked whenever an item is selected.

      Default implementation will compare with previous selection, and only invoke newSelection when the selection changed.

      Override this method to be notified of any selection, including the case where the user re-selects the same entry, or presses 'Return' in the combo's text field without changing its content.

      Parameters:
      selection - Selected item, may be null
    • newSelection

      public void newSelection(String selection)
      Invoked whenever a new entry was entered or selected.

      Override this method to be notified only when the user selects a different item. Re-selection of the same item will be ignored.

      Parameters:
      selection - Selected item, may be null
    • loadSettings

      public void loadSettings()
      Load persisted list values.
    • saveSettings

      public void saveSettings()
      Save list values to persistent storage.