- Timestamp:
- 2018-06-14T09:52:42+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/download
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/OverpassDownloadSource.java
r13927 r13930 11 11 import java.awt.event.FocusEvent; 12 12 import java.util.Collection; 13 import java.util.Objects; 13 14 import java.util.concurrent.Future; 14 15 import java.util.function.Consumer; … … 36 37 import org.openstreetmap.josm.gui.MainApplication; 37 38 import org.openstreetmap.josm.gui.download.DownloadSourceSizingPolicy.AdjustableDownloadSizePolicy; 39 import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration; 40 import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration.OverpassQueryWizard; 41 import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration.OverpassWizardCallbacks; 38 42 import org.openstreetmap.josm.gui.util.GuiHelper; 39 43 import org.openstreetmap.josm.gui.widgets.JosmTextArea; … … 82 86 * @since 12652 83 87 */ 84 public static class OverpassDownloadSourcePanel extends AbstractDownloadSourcePanel<OverpassDownloadData> { 88 public static class OverpassDownloadSourcePanel extends AbstractDownloadSourcePanel<OverpassDownloadData> 89 implements OverpassWizardCallbacks { 85 90 86 91 private static final String SIMPLE_NAME = "overpassdownloadpanel"; … … 104 109 super(ds); 105 110 setLayout(new BorderLayout()); 106 107 String tooltip = tr("Build an Overpass query using the Overpass Turbo Query Wizard tool");108 109 JButton openQueryWizard = new JButton(tr("Query Wizard"));110 openQueryWizard.setToolTipText(tooltip);111 openQueryWizard.addActionListener(new AbstractAction() {112 @Override113 public void actionPerformed(ActionEvent e) {114 new OverpassQueryWizardDialog(OverpassDownloadSourcePanel.this).showDialog();115 }116 });117 111 118 112 this.overpassQuery = new JosmTextArea(DOWNLOAD_QUERY.get(), 8, 80); … … 165 159 leftPanel.add(new JLabel(tr("Overpass query:")), GBC.eol().insets(5, 1, 5, 1).anchor(GBC.NORTHWEST)); 166 160 leftPanel.add(new JLabel(), GBC.eol().fill(GBC.VERTICAL)); 167 leftPanel.add(openQueryWizard, GBC.eol().anchor(GBC.CENTER)); 161 OverpassWizardRegistration.getWizards() 162 .stream() 163 .map(this::generateWizardButton) 164 .forEach(button -> leftPanel.add(button, GBC.eol().anchor(GBC.CENTER))); 168 165 leftPanel.add(new JLabel(), GBC.eol().fill(GBC.VERTICAL)); 169 166 … … 173 170 174 171 setMinimumSize(new Dimension(450, 240)); 172 } 173 174 private JButton generateWizardButton(OverpassQueryWizard wizard) { 175 JButton openQueryWizard = new JButton(wizard.getWizardName()); 176 openQueryWizard.setToolTipText(wizard.getWizardTooltip().orElse(null)); 177 openQueryWizard.addActionListener(new AbstractAction() { 178 @Override 179 public void actionPerformed(ActionEvent e) { 180 wizard.startWizard(OverpassDownloadSourcePanel.this); 181 } 182 }); 183 return openQueryWizard; 175 184 } 176 185 … … 260 269 */ 261 270 public void setOverpassQuery(String query) { 271 Objects.requireNonNull(query, "query"); 262 272 this.overpassQuery.setText(query); 263 273 } … … 360 370 checkEnabled(); 361 371 } 372 } 373 374 @Override 375 public void submitWizardResult(String resultingQuery) { 376 setOverpassQuery(resultingQuery); 362 377 } 363 378 } … … 383 398 } 384 399 } 400 385 401 } -
trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java
r13761 r13930 23 23 import org.openstreetmap.josm.data.preferences.ListProperty; 24 24 import org.openstreetmap.josm.gui.ExtendedDialog; 25 import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration.OverpassWizardCallbacks; 25 26 import org.openstreetmap.josm.gui.util.GuiHelper; 26 27 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; … … 65 66 + "</style>\n"; 66 67 67 private final Overpass DownloadSource.OverpassDownloadSourcePaneldsPanel;68 private final OverpassWizardCallbacks dsPanel; 68 69 69 70 /** 70 71 * Create a new {@link OverpassQueryWizardDialog} 71 * @param dsPanelThe Overpass download source panel.72 */ 73 public OverpassQueryWizardDialog(Overpass DownloadSource.OverpassDownloadSourcePanel dsPanel) {74 super( dsPanel.getParent(), tr("Overpass Turbo Query Wizard"),72 * @param callbacks The Overpass download source panel. 73 */ 74 public OverpassQueryWizardDialog(OverpassWizardCallbacks callbacks) { 75 super(callbacks.getParent(), tr("Overpass Turbo Query Wizard"), 75 76 tr("Build query"), tr("Build query and execute"), tr("Cancel")); 76 this.dsPanel = dsPanel;77 this.dsPanel = callbacks; 77 78 78 79 this.queryWizard = new HistoryComboBox(); … … 168 169 169 170 Optional<String> q = this.tryParseSearchTerm(wizardSearchTerm); 170 if (q.isPresent()) { 171 String query = q.get(); 172 dsPanel.setOverpassQuery(query); 173 174 return true; 175 } 176 177 return false; 171 q.ifPresent(dsPanel::submitWizardResult); 172 return q.isPresent(); 178 173 } 179 174
Note:
See TracChangeset
for help on using the changeset viewer.