Revision: 5297 http://sourceforge.net/p/jump-pilot/code/5297 Author: edso Date: 2016-12-29 18:16:49 +0000 (Thu, 29 Dec 2016) Log Message: ----------- enhance and i18n error handling
Modified Paths: -------------- core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java core/trunk/src/language/jump.properties core/trunk/src/language/jump_cz.properties core/trunk/src/language/jump_de.properties core/trunk/src/language/jump_es.properties core/trunk/src/language/jump_fi.properties core/trunk/src/language/jump_fr.properties core/trunk/src/language/jump_hu.properties core/trunk/src/language/jump_it.properties core/trunk/src/language/jump_ja_JP.properties core/trunk/src/language/jump_ml.properties core/trunk/src/language/jump_pt.properties core/trunk/src/language/jump_pt_BR.properties core/trunk/src/language/jump_ta_IN.properties core/trunk/src/language/jump_te.properties core/trunk/src/language/jump_zh_CN.properties core/trunk/src/language/jump_zh_HK.properties Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java 2016-12-29 18:16:49 UTC (rev 5297) @@ -10,6 +10,7 @@ import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.JUMPException; import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.geom.EnvelopeUtil; import com.vividsolutions.jump.util.CoordinateArrays; @@ -27,10 +28,29 @@ private Coordinate lastCoordinate = new Coordinate(0, 0); public boolean execute(PlugInContext context) throws Exception { - Coordinate coordinate = prompt(context); + Coordinate coordinate = null; + boolean retry = true; + while (retry) { + try { + String value = JOptionPane + .showInputDialog( + context.getWorkbenchFrame(), + I18N.get("ui.zoom.ZoomToCoordinatePlugIn.enter-coordinate-to-zoom-to"), + lastCoordinate.x + ", " + lastCoordinate.y); + if (value == null) { + retry = false; + } else { + coordinate = toCoordinate(value); + } + } catch (Exception e) { + context.getWorkbenchContext().getErrorHandler().handleThrowable(e); + } + } + if (coordinate == null) { return false; } + lastCoordinate = coordinate; context.getLayerViewPanel().getViewport() .zoom(toEnvelope(coordinate, context.getLayerManager())); @@ -41,22 +61,6 @@ return true; } - private Coordinate prompt(PlugInContext context) { - while (true) { - try { - return toCoordinate(JOptionPane.showInputDialog(context - .getWorkbenchFrame(), I18N - .get("ui.zoom.ZoomToCoordinatePlugIn.enter-coordinate-to-zoom-to"), - lastCoordinate.x + ", " + lastCoordinate.y)); - } catch (Exception e) { - JOptionPane.showMessageDialog(context.getWorkbenchFrame(), - e.getMessage(), context.getWorkbenchFrame().getTitle(), - JOptionPane.ERROR_MESSAGE); - } - } - - } - private Envelope toEnvelope(Coordinate coordinate, LayerManager layerManager) { int segments = 0; int segmentSum = 0; @@ -90,22 +94,21 @@ } private Coordinate toCoordinate(String s) throws Exception { - if (s == null) { - return null; - } - if (s.trim().length() == 0) { - return null; - } s = StringUtil.replaceAll(s, ",", " "); StringTokenizer tokenizer = new StringTokenizer(s); + if (tokenizer.countTokens() < 2) { + throw new JUMPException( + I18N.get("ui.zoom.ZoomToCoordinatePlugIn.enter-two-values")); + } + String x = tokenizer.nextToken(); - if (!StringUtil.isNumber(x)) { - throw new Exception("Not a number: " + x); - } + if (!StringUtil.isNumber(x)) + throw new JUMPException(I18N.getMessage("ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number", x)); + String y = tokenizer.nextToken(); - if (!StringUtil.isNumber(y)) { - throw new Exception("Not a number: " + y); - } + if (!StringUtil.isNumber(y)) + throw new JUMPException(I18N.getMessage("ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number", y)); + return new Coordinate(Double.parseDouble(x), Double.parseDouble(y)); } Modified: core/trunk/src/language/jump.properties =================================================================== --- core/trunk/src/language/jump.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2794,4 +2794,6 @@ org.openjump.core.ui.plugin.layer.ExtractLayersByGeometry.empty=empty org.openjump.core.ui.plugin.layer.ExtractLayersByGeometry.line=Line GeoJSONWriter.writing-features=Writing features... -Reader.parsed-{0}-features=Parsed {0} features. \ No newline at end of file +Reader.parsed-{0}-features=Parsed {0} features. +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_cz.properties =================================================================== --- core/trunk/src/language/jump_cz.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_cz.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2775,4 +2775,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_de.properties =================================================================== --- core/trunk/src/language/jump_de.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_de.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2771,4 +2771,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_es.properties =================================================================== --- core/trunk/src/language/jump_es.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_es.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2754,4 +2754,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_fi.properties =================================================================== --- core/trunk/src/language/jump_fi.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_fi.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2748,4 +2748,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_fr.properties =================================================================== --- core/trunk/src/language/jump_fr.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_fr.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2778,4 +2778,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=Identifiant externe org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=Couche de r\xE9f\xE9rence \xE0 mettre \xE0 jour org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=Jointure droite -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=La jointure droite ajoute au r\xE9sultat les objets non-joints de la couche jointes \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=La jointure droite ajoute au r\xE9sultat les objets non-joints de la couche jointes +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_hu.properties =================================================================== --- core/trunk/src/language/jump_hu.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_hu.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2767,4 +2767,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_it.properties =================================================================== --- core/trunk/src/language/jump_it.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_it.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2755,3 +2755,5 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_ja_JP.properties =================================================================== --- core/trunk/src/language/jump_ja_JP.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_ja_JP.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2769,4 +2769,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_ml.properties =================================================================== --- core/trunk/src/language/jump_ml.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_ml.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -4042,4 +4042,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_pt.properties =================================================================== --- core/trunk/src/language/jump_pt.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_pt.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2768,4 +2768,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_pt_BR.properties =================================================================== --- core/trunk/src/language/jump_pt_BR.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_pt_BR.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2768,4 +2768,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_ta_IN.properties =================================================================== --- core/trunk/src/language/jump_ta_IN.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_ta_IN.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2767,4 +2767,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_te.properties =================================================================== --- core/trunk/src/language/jump_te.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_te.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -3274,4 +3274,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_zh_CN.properties =================================================================== --- core/trunk/src/language/jump_zh_CN.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_zh_CN.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2931,4 +2931,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file Modified: core/trunk/src/language/jump_zh_HK.properties =================================================================== --- core/trunk/src/language/jump_zh_HK.properties 2016-12-29 17:33:41 UTC (rev 5296) +++ core/trunk/src/language/jump_zh_HK.properties 2016-12-29 18:16:49 UTC (rev 5297) @@ -2931,4 +2931,6 @@ org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-ext-id=#T:Reference layer external id org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Reference-layer-to-update=#T:Reference layer to update org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join=#T:Right join -org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer \ No newline at end of file +org.openjump.core.ui.plugin.tools.UpdateWithJoinPlugIn.Right-join-tooltip=#T:Check right join to add un-joined features from join layer +ui.zoom.ZoomToCoordinatePlugIn.enter-two-values=#T:Enter two values! +ui.zoom.ZoomToCoordinatePlugIn.{0}-is-not-a-number=#T:''{0}'' is not a number! \ No newline at end of file ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel