X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FAddMapSourceDialog.java;h=ec13bb1132dc52d64d3059c0d71b147a58890233;hp=d7126ea39d702961423868708322a9c2fab6266c;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hpb=3745d70b1427bb8ac1a085e47cbdc566936784e1 diff --git a/tim/prune/function/AddMapSourceDialog.java b/tim/prune/function/AddMapSourceDialog.java index d7126ea..ec13bb1 100644 --- a/tim/prune/function/AddMapSourceDialog.java +++ b/tim/prune/function/AddMapSourceDialog.java @@ -9,8 +9,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.net.MalformedURLException; -import java.net.URL; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -216,23 +214,15 @@ public class AddMapSourceDialog private boolean isOsmPanelOk() { boolean ok = _oNameField.getText().trim().length() > 1; - URL baseUrl = null, topUrl = null; - try { - // Try to parse base url if given - String baseText = _baseUrlField.getText().trim(); - if (baseText.length() > 10) { - baseUrl = new URL(baseText); - } - else if (baseText.length() > 0) {ok = false;} - // Same again for top url if given - String topText = _topUrlField.getText().trim(); - if (topText.length() > 10) { - topUrl = new URL(topText); - } - else if (topText.length() > 0) {ok = false;} - } catch (MalformedURLException e) { - ok = false; - } + String baseUrl = null, topUrl = null; + // Try to parse base url if given + String baseText = _baseUrlField.getText().trim(); + baseUrl = MapSource.fixBaseUrl(baseText); + if (baseText.length() > 0 && baseUrl == null) {ok = false;} + // Same again for top url if given + String topText = _topUrlField.getText().trim(); + topUrl = MapSource.fixBaseUrl(topText); + if (topText.length() > 0 && topUrl == null) {ok = false;} // looks ok if at least one url given return (ok && (baseUrl != null || topUrl != null)); }