/** * Add a search string as the first element. If the search string is * <code>null</code> or empty nothing will be added. If the search string * already exists, the old element will be removed. The modified list will * automatically be persisted. * * If the number of elements exceeds the maximum number of entries, the last * entry will be removed. * * @see #getMaxRecents() * @param searchString * the search string to add */ public void put(String searchString) { if (searchString == null || searchString.trim().length() == 0) { return; } int lastIndex = recentSearches.indexOf(searchString); if (lastIndex != -1) { recentSearches.remove(lastIndex); } recentSearches.add(0, searchString); if (getLength() > getMaxRecents()) { recentSearches.remove(recentSearches.size() - 1); } save(); fireChangeEvent(); }
/** * Add a search string as the first element. If the search string is * <code>null</code> or empty nothing will be added. If the search string * already exists, the old element will be removed. The modified list will * automatically be persisted. * * If the number of elements exceeds the maximum number of entries, the last * entry will be removed. * * @see #getMaxRecents() * @param searchString * the search string to add */ public void put(String searchString) { if (searchString == null || searchString.trim().length() == 0) { return; } int lastIndex = recentSearches.indexOf(searchString); if (lastIndex != -1) { recentSearches.remove(lastIndex); } recentSearches.add(0, searchString); if (getLength() > getMaxRecents()) { recentSearches.remove(recentSearches.size() - 1); } save(); fireChangeEvent(); }
/** * Add a search string as the first element. If the search string is * <code>null</code> or empty nothing will be added. If the search string * already exists, the old element will be removed. The modified list will * automatically be persisted. * * If the number of elements exceeds the maximum number of entries, the last * entry will be removed. * * @see #getMaxRecents() * @param searchString * the search string to add */ public void put(String searchString) { if (searchString == null || searchString.trim().length() == 0) { return; } int lastIndex = recentSearches.indexOf(searchString); if (lastIndex != -1) { recentSearches.remove(lastIndex); } recentSearches.add(0, searchString); if (getLength() > getMaxRecents()) { recentSearches.remove(recentSearches.size() - 1); } save(); fireChangeEvent(); }
/** * Add a search string as the first element. If the search string is * <code>null</code> or empty nothing will be added. If the search string * already exists, the old element will be removed. The modified list will * automatically be persisted. * * If the number of elements exceeds the maximum number of entries, the last * entry will be removed. * * @see #getMaxRecents() * @param searchString * the search string to add */ public void put(String searchString) { if (searchString == null || searchString.trim().length() == 0) { return; } int lastIndex = recentSearches.indexOf(searchString); if (lastIndex != -1) { recentSearches.remove(lastIndex); } recentSearches.add(0, searchString); if (getLength() > getMaxRecents()) { recentSearches.remove(recentSearches.size() - 1); } save(); fireChangeEvent(); }
/** * Rebuilds the menu according to the recent searches. */ private void buildMenu() { setVisible(false); removeAll(); if (recentSearches.getLength() == 0) { JMenuItem noRecent = new JMenuItem(UIManagerExt.getString("SearchField.noRecentsText")); noRecent.setEnabled(false); add(noRecent); } else { JMenuItem recent = new JMenuItem(UIManagerExt.getString("SearchField.recentsMenuTitle")); recent.setEnabled(false); add(recent); for (String searchString : recentSearches.getRecentSearches()) { JMenuItem mi = new JMenuItem(searchString); mi.addActionListener(this); add(mi); } addSeparator(); clear = new JMenuItem(UIManagerExt.getString("SearchField.clearRecentsText")); clear.addActionListener(this); add(clear); } }
/** * Rebuilds the menu according to the recent searches. */ private void buildMenu() { setVisible(false); removeAll(); if (recentSearches.getLength() == 0) { JMenuItem noRecent = new JMenuItem(UIManagerExt.getString("SearchField.noRecentsText")); noRecent.setEnabled(false); add(noRecent); } else { JMenuItem recent = new JMenuItem(UIManagerExt.getString("SearchField.recentsMenuTitle")); recent.setEnabled(false); add(recent); for (String searchString : recentSearches.getRecentSearches()) { JMenuItem mi = new JMenuItem(searchString); mi.addActionListener(this); add(mi); } addSeparator(); clear = new JMenuItem(UIManagerExt.getString("SearchField.clearRecentsText")); clear.addActionListener(this); add(clear); } }
/** * Rebuilds the menu according to the recent searches. */ private void buildMenu() { setVisible(false); removeAll(); if (recentSearches.getLength() == 0) { JMenuItem noRecent = new JMenuItem(UIManagerExt.getString("SearchField.noRecentsText")); noRecent.setEnabled(false); add(noRecent); } else { JMenuItem recent = new JMenuItem(UIManagerExt.getString("SearchField.recentsMenuTitle")); recent.setEnabled(false); add(recent); for (String searchString : recentSearches.getRecentSearches()) { JMenuItem mi = new JMenuItem(searchString); mi.addActionListener(this); add(mi); } addSeparator(); clear = new JMenuItem(UIManagerExt.getString("SearchField.clearRecentsText")); clear.addActionListener(this); add(clear); } }
/** * Rebuilds the menu according to the recent searches. */ private void buildMenu() { setVisible(false); removeAll(); if (recentSearches.getLength() == 0) { JMenuItem noRecent = new JMenuItem(UIManagerExt.getString("SearchField.noRecentsText")); noRecent.setEnabled(false); add(noRecent); } else { JMenuItem recent = new JMenuItem(UIManagerExt.getString("SearchField.recentsMenuTitle")); recent.setEnabled(false); add(recent); for (String searchString : recentSearches.getRecentSearches()) { JMenuItem mi = new JMenuItem(searchString); mi.addActionListener(this); add(mi); } addSeparator(); clear = new JMenuItem(UIManagerExt.getString("SearchField.clearRecentsText")); clear.addActionListener(this); add(clear); } }