Changeset 12575 in josm for trunk/src/org
- Timestamp:
- 2017-08-06T20:24:40+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java
r12574 r12575 106 106 * want to save the last query in OverpassQueryList. 107 107 */ 108 Consumer<Collection> errorReporter = (errors)-> {108 Consumer<Collection<Object>> errorReporter = errors -> { 109 109 110 110 boolean onlyNoDataError = errors.size() == 1 && … … 221 221 @Override 222 222 public void focusLost(FocusEvent e) { 223 223 // ignored 224 224 } 225 225 }); … … 233 233 ? BasicArrowButton.EAST 234 234 : BasicArrowButton.WEST); 235 arrowButton.addActionListener(e -> 235 arrowButton.addActionListener(e -> { 236 236 if (overpassQueryList.isVisible()) { 237 237 overpassQueryList.setVisible(false); … … 288 288 private static final class QueryWizardDialog extends ExtendedDialog { 289 289 290 private static final String HEADLINE_START = "<h3>"; 291 private static final String HEADLINE_END = "</h3>"; 292 private static final String TR_START = "<tr>"; 293 private static final String TR_END = "</tr>"; 294 private static final String TD_START = "<td>"; 295 private static final String TD_END = "</td>"; 290 296 private static QueryWizardDialog dialog; 291 297 private final HistoryComboBox queryWizard; … … 329 335 330 336 JLabel searchLabel = new JLabel(tr("Search :")); 331 JTextComponent descPane = this.buildDescriptionSection();337 JTextComponent descPane = buildDescriptionSection(); 332 338 JScrollPane scroll = GuiHelper.embedInVerticalScrollPane(descPane); 333 339 scroll.getVerticalScrollBar().setUnitIncrement(10); // make scrolling smooth … … 422 428 } 423 429 424 private JTextComponent buildDescriptionSection() { 425 JEditorPane descriptionSection = new JEditorPane("text/html", this.getDescriptionContent());430 private static JTextComponent buildDescriptionSection() { 431 JEditorPane descriptionSection = new JEditorPane("text/html", getDescriptionContent()); 426 432 descriptionSection.setEditable(false); 427 433 descriptionSection.addHyperlinkListener(e -> { … … 434 440 } 435 441 436 private String getDescriptionContent() { 442 private static String getDescriptionContent() { 437 443 return new StringBuilder("<html>") 438 444 .append(DESCRIPTION_STYLE) 439 445 .append("<body>") 440 .append( "<h3>")446 .append(HEADLINE_START) 441 447 .append(tr("Query Wizard")) 442 .append( "</h3>")448 .append(HEADLINE_END) 443 449 .append("<p>") 444 450 .append(tr("Allows you to interact with <i>Overpass API</i> by writing declarative, human-readable terms.")) … … 447 453 .append(tr("<a href=\"{0}\">OSM Wiki</a>.", Main.getOSMWebsite() + "/wiki/Overpass_turbo/Wizard")) 448 454 .append("</p>") 449 .append( "<h3>").append(tr("Hints")).append("</h3>")450 .append("<table>").append( "<tr>").append("<td>")455 .append(HEADLINE_START).append(tr("Hints")).append(HEADLINE_END) 456 .append("<table>").append(TR_START).append(TD_START) 451 457 .append(Utils.joinAsHtmlUnorderedList(Arrays.asList("<i>type:node</i>", "<i>type:relation</i>", "<i>type:way</i>"))) 452 .append( "</td>").append("<td>")458 .append(TD_END).append(TD_START) 453 459 .append("<span>").append(tr("Download objects of a certain type.")).append("</span>") 454 .append( "</td>").append("</tr>")455 .append( "<tr>").append("<td>")460 .append(TD_END).append(TR_END) 461 .append(TR_START).append(TD_START) 456 462 .append(Utils.joinAsHtmlUnorderedList( 457 463 Arrays.asList("<i>key=value in <u>location</u></i>", 458 464 "<i>key=value around <u>location</u></i>", 459 465 "<i>key=value in bbox</i>"))) 460 .append( "</td>").append("<td>")466 .append(TD_END).append(TD_START) 461 467 .append(tr("Download object by specifying a specific location. For example,")) 462 468 .append(Utils.joinAsHtmlUnorderedList(Arrays.asList( … … 469 475 .append(tr("Instead of <i>location</i> any valid place name can be used like address, city, etc.")) 470 476 .append("</span>") 471 .append( "</td>").append("</tr>")472 .append( "<tr>").append("<td>")477 .append(TD_END).append(TR_END) 478 .append(TR_START).append(TD_START) 473 479 .append(Utils.joinAsHtmlUnorderedList(Arrays.asList("<i>key=value</i>", "<i>key=*</i>", "<i>key~regex</i>", 474 480 "<i>key!=value</i>", "<i>key!~regex</i>", "<i>key=\"combined value\"</i>"))) 475 .append( "</td>").append("<td>")481 .append(TD_END).append(TD_START) 476 482 .append(tr("<span>Download objects that have some concrete key/value pair, only the key with any contents for the value, " + 477 483 "the value matching some regular expression. 'Not equal' operators are supported as well.</span>")) 478 .append( "</td>").append("</tr>")479 .append( "<tr>").append("<td>")484 .append(TD_END).append(TR_END) 485 .append(TR_START).append(TD_START) 480 486 .append(Utils.joinAsHtmlUnorderedList(Arrays.asList( 481 487 tr("<i>expression1 {0} expression2</i>", "or"), 482 488 tr("<i>expression1 {0} expression2</i>", "and")))) 483 .append( "</td>").append("<td>")489 .append(TD_END).append(TD_START) 484 490 .append("<span>") 485 491 .append(tr("Basic logical operators can be used to create more sophisticated queries. Instead of 'or' - '|', '||' " + 486 492 "can be used, and instead of 'and' - '&', '&&'.")) 487 493 .append("</span>") 488 .append( "</td>").append("</tr>").append("</table>")494 .append(TD_END).append(TR_END).append("</table>") 489 495 .append("</body>") 490 496 .append("</html>") -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java
r12574 r12575 30 30 private final DownloadTask task; 31 31 private final Future<?> future; 32 private Consumer<Collection> errorReporter; 32 private Consumer<Collection<Object>> errorReporter; 33 33 34 34 /** 35 * constructor35 * Creates a new {@link PostDownloadHandler} 36 36 * @param task the asynchronous download task 37 37 * @param future the future on which the completion of the download task can be synchronized … … 43 43 44 44 /** 45 * constructor45 * Creates a new {@link PostDownloadHandler} using a custom error reporter 46 46 * @param task the asynchronous download task 47 47 * @param future the future on which the completion of the download task can be synchronized … … 49 49 * task 50 50 */ 51 public PostDownloadHandler(DownloadTask task, Future<?> future, Consumer<Collection> errorReporter) { 51 public PostDownloadHandler(DownloadTask task, Future<?> future, Consumer<Collection<Object>> errorReporter) { 52 52 this(task, future); 53 53 this.errorReporter = errorReporter; -
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.