X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fgui%2FCombinedListAndModel.java;fp=tim%2Fprune%2Fgui%2FCombinedListAndModel.java;h=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hp=4b94cebdcba23796c098696e935fe21d0465ef16;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465;p=GpsPrune.git diff --git a/tim/prune/gui/CombinedListAndModel.java b/tim/prune/gui/CombinedListAndModel.java deleted file mode 100644 index 4b94ceb..0000000 --- a/tim/prune/gui/CombinedListAndModel.java +++ /dev/null @@ -1,110 +0,0 @@ -package tim.prune.gui; - -import javax.swing.DefaultListModel; -import javax.swing.JList; -import javax.swing.ListSelectionModel; - -import tim.prune.I18nManager; - - -/** - * Listbox class which also contains its own string model. - * Also has the ability to limit its size and show a single - * text instead of a huge list - */ -public class CombinedListAndModel extends JList -{ - private DefaultListModel _model = null; - private final int _key; - private int _maxNumEntries = 0; - private boolean _tooManyEntries = false; - private boolean _unlimited = false; - - - /** - * Constructor - */ - public CombinedListAndModel(int inKey) - { - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - _model = new DefaultListModel(); - setModel(_model); - _key = inKey; - } - - /** - * @param inMaxNum maximum number of entries to allow - */ - public void setMaxNumEntries(int inMaxNum) - { - _maxNumEntries = inMaxNum; - } - - /** - * @param inUnlimited true if list is temporarily unlimited - */ - public void setUnlimited(boolean inUnlimited) - { - _unlimited = inUnlimited; - } - - /** - * @return key - */ - public int getKey() - { - return _key; - } - - /** - * @param inItem String to add to the list - */ - public void addItem(String inItem) - { - if (!_tooManyEntries) - { - _model.addElement(inItem); - if (_maxNumEntries > 0 && !_unlimited - && _model.getSize() > _maxNumEntries) - { - _tooManyEntries = true; - _model.clear(); - _model.addElement(I18nManager.getText("dialog.settimezone.list.toomany")); - } - } - } - - /** - * @return the selected String, or null - */ - public String getSelectedItem() - { - final int selectedIndex = getSelectedIndex(); - if (_tooManyEntries || selectedIndex < 0) - { - return null; - } - return _model.getElementAt(selectedIndex); - } - - /** - * Clear the list - */ - public void clear() - { - _model.clear(); - _tooManyEntries = false; - _unlimited = false; - } - - /** - * @param inItem item to select - */ - public void selectItem(String inItem) - { - if (!_tooManyEntries && inItem != null) - { - this.setSelectedValue(inItem, true); - } - } -}