Package org.csstudio.ui.util.helpers
Class ComboHistoryHelper
java.lang.Object
org.csstudio.ui.util.helpers.ComboHistoryHelper
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()
ornewSelection()
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 Summary
ConstructorDescriptionComboHistoryHelper
(IDialogSettings settings, String tag, Combo combo) Attach helper to given combo box, using max list length.ComboHistoryHelper
(IDialogSettings settings, String tag, Combo combo, int max, boolean saveOnDispose) Attach helper to given combo box, using max list length. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new entry to the list.void
changeSelection
(String entry) void
itemSelected
(String selection) Invoked whenever an item is selected.void
Load persisted list values.void
newSelection
(String selection) Invoked whenever a new entry was entered or selected.void
Save list values to persistent storage.
-
Constructor Details
-
ComboHistoryHelper
Attach helper to given combo box, using max list length.- Parameters:
settings
- where to persist the combo box listtag
- tag used for persistencecombo
- 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 listtag
- tag used for persistencecombo
- the combo boxmax
- number of elements to keep in historysaveOnDispose
- whether current values should be saved at widget disposal
-
-
Method Details
-
changeSelection
-
addEntry
Adds a new entry to the list. If entry already there, do nothing.- Parameters:
newEntry
- the new value
-
itemSelected
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 benull
-
newSelection
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 benull
-
loadSettings
public void loadSettings()Load persisted list values. -
saveSettings
public void saveSettings()Save list values to persistent storage.
-