### Eclipse Workspace Patch 1.0
#P josm
diff --git src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java
index 5b99e82..7b93c01 100644
|
|
|
|
| 9 | 9 | import java.awt.Insets; |
| 10 | 10 | import java.awt.event.FocusAdapter; |
| 11 | 11 | import java.awt.event.FocusEvent; |
| 12 | | import java.net.MalformedURLException; |
| 13 | | import java.net.URL; |
| | 12 | import java.net.URI; |
| | 13 | import java.net.URISyntaxException; |
| 14 | 14 | import java.util.Arrays; |
| 15 | 15 | import java.util.List; |
| 16 | 16 | import java.util.stream.Collectors; |
| … |
… |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | protected JPanel buildURLPanel() { |
| 51 | | JPanel pnl = new JPanel(new GridBagLayout()); |
| 52 | | GridBagConstraints gc = new GridBagConstraints(); |
| | 51 | final JPanel pnl = new JPanel(new GridBagLayout()); |
| | 52 | final GridBagConstraints gc = new GridBagConstraints(); |
| 53 | 53 | gc.weightx = 0.0; |
| 54 | 54 | gc.fill = GridBagConstraints.HORIZONTAL; |
| 55 | 55 | gc.insets = new Insets(0, 0, 0, 5); |
| … |
… |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | protected JPanel buildHelpPanel() { |
| 87 | | String apiUrl = OsmApi.getOsmApi().getBaseUrl(); |
| 88 | | HtmlPanel pnl = new HtmlPanel(); |
| | 87 | final String apiUrl = OsmApi.getOsmApi().getBaseUrl(); |
| | 88 | final HtmlPanel pnl = new HtmlPanel(); |
| 89 | 89 | pnl.setText( |
| 90 | 90 | "<html><body>" |
| 91 | 91 | + tr("Please enter or paste an URL to retrieve changesets from the OSM API.") |
| … |
… |
|
| 112 | 112 | setLayout(new GridBagLayout()); |
| 113 | 113 | setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
| 114 | 114 | |
| 115 | | GridBagConstraints gc = new GridBagConstraints(); |
| | 115 | final GridBagConstraints gc = new GridBagConstraints(); |
| 116 | 116 | gc.weightx = 1.0; |
| 117 | 117 | gc.fill = GridBagConstraints.HORIZONTAL; |
| 118 | 118 | gc.insets = new Insets(0, 0, 10, 0); |
| … |
… |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | protected static ChangesetQuery buildChangesetQuery(String text) { |
| 138 | | URL url = null; |
| 139 | | try { |
| 140 | | url = new URL(text); |
| 141 | | } catch (MalformedURLException e) { |
| | 138 | if (text == null || text.isBlank()) { |
| 142 | 139 | return null; |
| 143 | 140 | } |
| 144 | | String path = url.getPath(); |
| 145 | | if (path == null || (!path.endsWith("/changesets") && !path.endsWith("/history"))) |
| 146 | | return null; |
| 147 | | |
| | 141 | |
| 148 | 142 | try { |
| 149 | | return ChangesetQuery.buildFromUrlQuery(url.getQuery()); |
| | 143 | final URI uri = new URI(text); |
| | 144 | final String path = uri.getPath(); |
| | 145 | |
| | 146 | if (path == null || (!path.endsWith("/changesets") && !path.endsWith("/history"))) { |
| | 147 | return null; |
| | 148 | } |
| | 149 | |
| | 150 | return ChangesetQuery.buildFromUrlQuery(uri.getQuery()); |
| | 151 | |
| | 152 | } catch (URISyntaxException e) { |
| | 153 | // Ungültiges URL/URI-Format -> laut Methode als null behandeln |
| | 154 | return null; |
| 150 | 155 | } catch (ChangesetQueryUrlException e) { |
| 151 | 156 | Logging.warn(e); |
| 152 | 157 | return null; |
| … |
… |
|
| 160 | 165 | * @return the changeset query |
| 161 | 166 | */ |
| 162 | 167 | public ChangesetQuery buildChangesetQuery() { |
| 163 | | String value = tfUrl.getText().trim(); |
| | 168 | final String value = tfUrl.getText().trim(); |
| 164 | 169 | return buildChangesetQuery(value); |
| 165 | 170 | } |
| 166 | 171 | |
| … |
… |
|
| 176 | 181 | */ |
| 177 | 182 | class ChangetQueryUrlValidator implements DocumentListener { |
| 178 | 183 | protected String getCurrentFeedback() { |
| 179 | | String fb = (String) lblValid.getClientProperty("valid"); |
| | 184 | final String fb = (String) lblValid.getClientProperty("valid"); |
| 180 | 185 | return fb == null ? "none" : fb; |
| 181 | 186 | } |
| 182 | 187 | |
| 183 | 188 | protected void feedbackValid() { |
| 184 | | if ("valid".equals(getCurrentFeedback())) |
| 185 | | return; |
| | 189 | if ("valid".equals(getCurrentFeedback())) { |
| | 190 | return; |
| | 191 | } |
| 186 | 192 | lblValid.setIcon(ImageProvider.get("misc", "green_check")); |
| 187 | 193 | lblValid.setToolTipText(null); |
| 188 | 194 | lblValid.putClientProperty("valid", "valid"); |
| 189 | 195 | } |
| 190 | 196 | |
| 191 | 197 | protected void feedbackInvalid() { |
| 192 | | if ("invalid".equals(getCurrentFeedback())) |
| 193 | | return; |
| | 198 | if ("invalid".equals(getCurrentFeedback())) { |
| | 199 | return; |
| | 200 | } |
| 194 | 201 | lblValid.setIcon(ImageProvider.get("warning-small")); |
| 195 | 202 | lblValid.setToolTipText(tr("This changeset query URL is invalid")); |
| 196 | 203 | lblValid.putClientProperty("valid", "invalid"); |