Changeset 12575 in josm for trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryList.java
- Timestamp:
- 2017-08-06T20:24:40+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryList.java
r12574 r12575 56 56 public final class OverpassQueryList extends SearchTextResultListPanel<OverpassQueryList.SelectorItem> { 57 57 58 private final DateTimeFormatter format= DateTimeFormatter.ofPattern("HH:mm:ss, dd-MM-yyyy");58 private static final DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss, dd-MM-yyyy"); 59 59 60 60 /* … … 85 85 this.target = target; 86 86 this.componentParent = parent; 87 this.items = this.restorePreferences();87 this.items = restorePreferences(); 88 88 89 89 OverpassQueryListMouseAdapter mouseHandler = new OverpassQueryListMouseAdapter(lsResult, lsResultModel); … … 134 134 if (!historicExist) { 135 135 SelectorItem item = new SelectorItem( 136 "history " + LocalDateTime.now().format( this.format),136 "history " + LocalDateTime.now().format(FORMAT), 137 137 query); 138 138 … … 261 261 * @return A set of the user saved items. 262 262 */ 263 private Map<String, SelectorItem> restorePreferences() {263 private static Map<String, SelectorItem> restorePreferences() { 264 264 Collection<Map<String, String>> toRetrieve = 265 265 Main.pref.getListOfStructs(PREFERENCE_ITEMS, Collections.emptyList()); … … 279 279 private class OverpassQueryListMouseAdapter extends MouseAdapter { 280 280 281 private final JList list;282 private final ResultListModel model;281 private final JList<SelectorItem> list; 282 private final ResultListModel<SelectorItem> model; 283 283 private final JPopupMenu emptySelectionPopup = new JPopupMenu(); 284 284 private final JPopupMenu elementPopup = new JPopupMenu(); 285 private final JPopupMenu queryLookup = new JPopupMenu(); 286 287 OverpassQueryListMouseAdapter(JList list, ResultListModel listModel) { 285 286 OverpassQueryListMouseAdapter(JList<SelectorItem> list, ResultListModel<SelectorItem> listModel) { 288 287 this.list = list; 289 288 this.model = listModel; … … 331 330 } 332 331 333 SelectorItem item = (SelectorItem)model.getElementAt(idx);332 SelectorItem item = model.getElementAt(idx); 334 333 list.setToolTipText("<html><pre style='width:300px;'>" + 335 334 Utils.escapeReservedCharactersHTML(Utils.restrictStringLines(item.getQuery(), 9))); … … 607 606 608 607 @Override 609 public boolean equals(Object o) { 610 if (this == o) return true; 611 if (!(o instanceof SelectorItem)) return false; 612 613 SelectorItem that = (SelectorItem) o; 614 615 return itemKey.equals(that.itemKey) && 616 query.equals(that.getKey()); 608 public int hashCode() { 609 final int prime = 31; 610 int result = 1; 611 result = prime * result + ((itemKey == null) ? 0 : itemKey.hashCode()); 612 result = prime * result + ((query == null) ? 0 : query.hashCode()); 613 return result; 617 614 } 618 615 619 616 @Override 620 public int hashCode() { 621 return itemKey.hashCode(); 617 public boolean equals(Object obj) { 618 if (this == obj) { 619 return true; 620 } 621 if (obj == null) { 622 return false; 623 } 624 if (getClass() != obj.getClass()) { 625 return false; 626 } 627 SelectorItem other = (SelectorItem) obj; 628 if (itemKey == null) { 629 if (other.itemKey != null) { 630 return false; 631 } 632 } else if (!itemKey.equals(other.itemKey)) { 633 return false; 634 } 635 if (query == null) { 636 if (other.query != null) { 637 return false; 638 } 639 } else if (!query.equals(other.query)) { 640 return false; 641 } 642 return true; 622 643 } 623 644 }
Note:
See TracChangeset
for help on using the changeset viewer.