source: josm/trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java@ 18173

Last change on this file since 18173 was 18173, checked in by Don-vip, 3 years ago

fix #20690 - fix #21240 - Refactoring of UploadDialog, HistoryComboBox and AutoCompletingComboBox (patch by marcello)

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.widgets;
3
4import java.util.List;
5
6import org.openstreetmap.josm.gui.tagging.ac.AutoCompComboBox;
7
8/**
9 * A History ComboBox
10 * <p>
11 * A HistoryComboBox is an {@link AutoCompComboBox} specialized in {@code String}s.
12 */
13public class HistoryComboBox extends AutoCompComboBox<String> {
14
15 /**
16 * Constructs a new {@code HistoryComboBox}.
17 */
18 public HistoryComboBox() {
19 super(new HistoryComboBoxModel());
20 setPrototypeDisplayValue("dummy");
21 }
22
23 @Override
24 public HistoryComboBoxModel getModel() {
25 return (HistoryComboBoxModel) dataModel;
26 }
27
28 /**
29 * Adds the item in the editor to the top of the history. If the item is already present, don't
30 * add another but move it to the top. The item is then selected.
31 */
32 public void addCurrentItemToHistory() {
33 String newItem = getModel().addTopElement(getEditor().getItem().toString());
34 getModel().setSelectedItem(newItem);
35 }
36
37 /**
38 * Returns the items as strings
39 * @return the items as strings
40 * @deprecated Has been moved to the model, where it belongs. Use
41 * {@link HistoryComboBoxModel#asStringList} instead. Probably you want to use
42 * {@link HistoryComboBoxModel.Preferences#load} and
43 * {@link HistoryComboBoxModel.Preferences#save}.
44 */
45 @Deprecated
46 public List<String> getHistory() {
47 return getModel().asStringList();
48 }
49}
Note: See TracBrowser for help on using the repository browser.