Changeset 12880 in josm for trunk/src/org
- Timestamp:
- 2017-09-20T21:33:06+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/download
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/OverpassDownloadSource.java
r12816 r12880 91 91 92 92 private final JosmTextArea overpassQuery; 93 private final OverpassQueryList overpassQueryList;93 private final UserQueryList overpassQueryList; 94 94 95 95 /** … … 134 134 135 135 136 this.overpassQueryList = new OverpassQueryList(this, this.overpassQuery);136 this.overpassQueryList = new UserQueryList(this, this.overpassQuery, "download.overpass.query"); 137 137 this.overpassQueryList.setPreferredSize(new Dimension(350, 300)); 138 138 … … 288 288 289 289 /** 290 * Action that delegates snippet creation to {@link OverpassQueryList#createNewItem()}.290 * Action that delegates snippet creation to {@link UserQueryList#createNewItem()}. 291 291 */ 292 292 private class AddSnippetAction extends AbstractAction { … … 308 308 309 309 /** 310 * Action that delegates snippet removal to {@link OverpassQueryList#removeSelectedItem()}.310 * Action that delegates snippet removal to {@link UserQueryList#removeSelectedItem()}. 311 311 */ 312 312 private class RemoveSnippetAction extends AbstractAction implements ListSelectionListener { … … 341 341 342 342 /** 343 * Action that delegates snippet edit to {@link OverpassQueryList#editSelectedItem()}.343 * Action that delegates snippet edit to {@link UserQueryList#editSelectedItem()}. 344 344 */ 345 345 private class EditSnippetAction extends AbstractAction implements ListSelectionListener { -
trunk/src/org/openstreetmap/josm/gui/download/UserQueryList.java
r12879 r12880 55 55 56 56 /** 57 * A component to select user saved Overpass queries. 58 * @since 12574 57 * A component to select user saved queries. 58 * @since 12880 59 * @since 12574 as OverpassQueryList 59 60 */ 60 public final class OverpassQueryList extends SearchTextResultListPanel<OverpassQueryList.SelectorItem> {61 public final class UserQueryList extends SearchTextResultListPanel<UserQueryList.SelectorItem> { 61 62 62 63 private static final DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss, dd-MM-yyyy"); … … 79 80 private static final String QUERY_KEY = "query"; 80 81 private static final String LAST_EDIT_KEY = "lastEdit"; 81 private static final String PREFERENCE_ITEMS = "download.overpass.query";82 private final String preferenceKey; 82 83 83 84 private static final String TRANSLATED_HISTORY = tr("history"); … … 87 88 * @param parent The parent of this component. 88 89 * @param target The text component to which the queries must be added. 89 */ 90 public OverpassQueryList(Component parent, JTextComponent target) { 90 * @param preferenceKey The {@linkplain org.openstreetmap.josm.spi.preferences.IPreferences preference} key to store the user queries 91 */ 92 public UserQueryList(Component parent, JTextComponent target, String preferenceKey) { 91 93 this.target = target; 92 94 this.componentParent = parent; 95 this.preferenceKey = preferenceKey; 93 96 this.items = restorePreferences(); 94 97 95 OverpassQueryListMouseAdapter mouseHandler = new OverpassQueryListMouseAdapter(lsResult, lsResultModel);96 super.lsResult.setCellRenderer(new OverpassQueryCellRendered());98 QueryListMouseAdapter mouseHandler = new QueryListMouseAdapter(lsResult, lsResultModel); 99 super.lsResult.setCellRenderer(new QueryCellRendered()); 97 100 super.setDblClickListener(e -> doubleClickEvent()); 98 101 super.lsResult.addMouseListener(mouseHandler); … … 255 258 } 256 259 257 Config.getPref().putListOfMaps( PREFERENCE_ITEMS, toSave);260 Config.getPref().putListOfMaps(preferenceKey, toSave); 258 261 } 259 262 … … 262 265 * @return A set of the user saved items. 263 266 */ 264 private staticMap<String, SelectorItem> restorePreferences() {267 private Map<String, SelectorItem> restorePreferences() { 265 268 Collection<Map<String, String>> toRetrieve = 266 Config.getPref().getListOfMaps( PREFERENCE_ITEMS, Collections.emptyList());269 Config.getPref().getListOfMaps(preferenceKey, Collections.emptyList()); 267 270 Map<String, SelectorItem> result = new HashMap<>(); 268 271 … … 285 288 } 286 289 287 private class OverpassQueryListMouseAdapter extends MouseAdapter {290 private class QueryListMouseAdapter extends MouseAdapter { 288 291 289 292 private final JList<SelectorItem> list; … … 292 295 private final JPopupMenu elementPopup = new JPopupMenu(); 293 296 294 OverpassQueryListMouseAdapter(JList<SelectorItem> list, ResultListModel<SelectorItem> listModel) {297 QueryListMouseAdapter(JList<SelectorItem> list, ResultListModel<SelectorItem> listModel) { 295 298 this.list = list; 296 299 this.model = listModel; … … 372 375 * This class defines the way each element is rendered in the list. 373 376 */ 374 private static class OverpassQueryCellRendered extends JLabel implements ListCellRenderer<SelectorItem> {375 376 OverpassQueryCellRendered() {377 private static class QueryCellRendered extends JLabel implements ListCellRenderer<SelectorItem> { 378 379 QueryCellRendered() { 377 380 setOpaque(true); 378 381 } … … 550 553 /** 551 554 * This class represents an Overpass query used by the user that can be 552 * shown within {@link OverpassQueryList}.555 * shown within {@link UserQueryList}. 553 556 */ 554 557 public static class SelectorItem { … … 602 605 603 606 /** 604 * Gets the overpassquery of this item.605 * @return A string representing the overpassquery of this item.607 * Gets the query of this item. 608 * @return A string representing the query of this item. 606 609 */ 607 610 public String getQuery() {
Note:
See TracChangeset
for help on using the changeset viewer.