Changeset 6798 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2014-02-01T03:18:43+01:00 (10 years ago)
Author:
Don-vip
Message:

fix some Sonar issues

Location:
trunk/src/org/openstreetmap/josm
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/MoveAction.java

    r6380 r6798  
    5555        } else if (dir == Direction.LEFT)  {
    5656            sc = Shortcut.registerShortcut("core:moveleft",  tr("Move objects {0}", tr("left")), KeyEvent.VK_LEFT,  Shortcut.SHIFT);
    57         } else { //dir == Direction.RIGHT) {
     57        } else { //dir == Direction.RIGHT
    5858            sc = Shortcut.registerShortcut("core:moveright", tr("Move objects {0}", tr("right")), KeyEvent.VK_RIGHT, Shortcut.SHIFT);
    5959        }
     
    7373        } else if (dir == Direction.LEFT)  {
    7474            putValue("toolbar", "action/move/left");
    75         } else { //dir == Direction.RIGHT) {
     75        } else { //dir == Direction.RIGHT
    7676            putValue("toolbar", "action/move/right");
    7777        }
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r6317 r6798  
    4141 */
    4242public final class OrthogonalizeAction extends JosmAction {
    43     private String USAGE = tr(
     43    private static final String USAGE = tr(
    4444            "<h3>When one or more ways are selected, the shape is adjusted such, that all angles are 90 or 180 degrees.</h3>"+
    4545            "You can add two nodes to the selection. Then, the direction is fixed by these two reference nodes. "+
     
    279279            throw new InvalidUserInputException(
    280280                    tr("<html>Please make sure all selected ways head in a similar direction<br>"+
    281                     "or orthogonalize them one by one.</html>"));
     281                    "or orthogonalize them one by one.</html>"), ex);
    282282        }
    283283
     
    439439                    direction = direction.changeBy(angleToDirectionChange(h2 - h1, TOLERANCE1));
    440440                } catch (RejectedAngleException ex) {
    441                     throw new InvalidUserInputException(tr("Please select ways with angles of approximately 90 or 180 degrees."));
     441                    throw new InvalidUserInputException(tr("Please select ways with angles of approximately 90 or 180 degrees."), ex);
    442442                }
    443443                segDirections[i+1] = direction;
     
    574574            super(message);
    575575        }
     576        InvalidUserInputException(String message, Throwable cause) {
     577            super(message, cause);
     578        }
    576579        InvalidUserInputException() {
    577580            super();
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmCompressedTask.java

    r6380 r6798  
    1919public class DownloadOsmCompressedTask extends DownloadOsmTask {
    2020
    21     String PATTERN_GZ =  "https?://.*/.*\\.osm.(gz|bz2?)";
     21    static final String PATTERN_GZ =  "https?://.*/.*\\.osm.(gz|bz2?)";
    2222
    2323    @Override
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r6792 r6798  
    8686
    8787    private Node lastUsedNode = null;
    88     private double PHI=Math.toRadians(90);
     88    private static final double PHI = Math.toRadians(90);
    8989    private double toleranceMultiplier;
    9090
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r6792 r6798  
    445445                    this.keyPattern = Pattern.compile(key, searchFlags);
    446446                } catch (PatternSyntaxException e) {
    447                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()));
     447                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    448448                } catch (Exception e) {
    449                     throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()));
     449                    throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
    450450                }
    451451                try {
    452452                    this.valuePattern = Pattern.compile(value, searchFlags);
    453453                } catch (PatternSyntaxException e) {
    454                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()));
     454                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    455455                } catch (Exception e) {
    456                     throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()));
     456                    throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
    457457                }
    458458                this.key = key;
     
    696696                    this.searchRegex = Pattern.compile(s, regexFlags(caseSensitive));
    697697                } catch (PatternSyntaxException e) {
    698                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()));
     698                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    699699                } catch (Exception e) {
    700                     throw new ParseError(tr(rxErrorMsgNoPos, s, e.getMessage()));
     700                    throw new ParseError(tr(rxErrorMsgNoPos, s, e.getMessage()), e);
    701701                }
    702702                this.search = s;
     
    11711171        public ParseError(String msg) {
    11721172            super(msg);
     1173        }
     1174        public ParseError(String msg, Throwable cause) {
     1175            super(msg, cause);
    11731176        }
    11741177        public ParseError(Token expected, Token found) {
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r6509 r6798  
    182182                values[i] = Double.parseDouble(components[i]);
    183183            } catch(NumberFormatException e) {
    184                 throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", components[i]));
     184                throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", components[i]), e);
    185185            }
    186186        }
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r6792 r6798  
    11891189                }
    11901190            } catch (IllegalArgumentException ex) {
    1191                 throw new RuntimeException();
     1191                throw new RuntimeException(ex);
    11921192            } catch (IllegalAccessException ex) {
    1193                 throw new RuntimeException();
     1193                throw new RuntimeException(ex);
    11941194            }
    11951195        }
     
    12021202            struct = klass.newInstance();
    12031203        } catch (InstantiationException ex) {
    1204             throw new RuntimeException();
     1204            throw new RuntimeException(ex);
    12051205        } catch (IllegalAccessException ex) {
    1206             throw new RuntimeException();
     1206            throw new RuntimeException(ex);
    12071207        }
    12081208        for (Entry<String,String> key_value : hash.entrySet()) {
     
    12141214                continue;
    12151215            } catch (SecurityException ex) {
    1216                 throw new RuntimeException();
     1216                throw new RuntimeException(ex);
    12171217            }
    12181218            if (f.getAnnotation(pref.class) == null) {
     
    12421242                f.set(struct, value);
    12431243            } catch (IllegalArgumentException ex) {
    1244                 throw new AssertionError();
     1244                throw new AssertionError(ex);
    12451245            } catch (IllegalAccessException ex) {
    1246                 throw new RuntimeException();
     1246                throw new RuntimeException(ex);
    12471247            }
    12481248        }
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r6388 r6798  
    113113                update(null);
    114114            } catch (ProjectionConfigurationException ex1) {
    115                 throw new RuntimeException();
     115                throw new RuntimeException(ex1);
    116116            }
    117117        }
     
    201201                initp = parseParameterList(init);
    202202            } catch (ProjectionConfigurationException ex) {
    203                 throw new ProjectionConfigurationException(tr(initKey+": "+ex.getMessage()));
     203                throw new ProjectionConfigurationException(tr(initKey+": "+ex.getMessage()), ex);
    204204            }
    205205            for (Map.Entry<String, String> e : parameters.entrySet()) {
     
    292292                towgs84Param.add(Double.parseDouble(str));
    293293            } catch (NumberFormatException e) {
    294                 throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", str));
     294                throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", str), e);
    295295            }
    296296        }
     
    380380        } catch (NumberFormatException e) {
    381381            throw new ProjectionConfigurationException(
    382                     tr("Unable to parse value ''{1}'' of parameter ''{0}'' as number.", parameterName, doubleStr));
     382                    tr("Unable to parse value ''{1}'' of parameter ''{0}'' as number.", parameterName, doubleStr), e);
    383383        }
    384384    }
  • trunk/src/org/openstreetmap/josm/gui/FileDrop.java

    r6730 r6798  
    297297
    298298    // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
    299     private static String ZERO_CHAR_STRING = "" + (char)0;
     299    private static final String ZERO_CHAR_STRING = "" + (char)0;
    300300    private static File[] createFileArray(BufferedReader bReader)
    301301    {
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r6789 r6798  
    784784        lonText.setInheritsPopupMenu(true);
    785785        headingText.setInheritsPopupMenu(true);
    786         //angleText.setInheritsPopupMenu(true);
    787786        distText.setInheritsPopupMenu(true);
    788787        nameText.setInheritsPopupMenu(true);
    789         //helpText.setInheritsPopupMenu(true);
    790         //progressBar.setInheritsPopupMenu(true);
    791788
    792789        add(latText, GBC.std());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r6732 r6798  
    16281628            putValue(SHORT_DESCRIPTION, tr("Edit the relation the currently selected relation member refers to"));
    16291629            putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));
    1630             //putValue(NAME, tr("Edit"));
    16311630            refreshEnabled();
    16321631        }
  • trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java

    r6643 r6798  
    5555import org.openstreetmap.josm.tools.WindowGeometry;
    5656
     57/**
     58 * Help browser displaying HTML pages fetched from JOSM wiki.
     59 */
    5760public class HelpBrowser extends JDialog {
    5861    /** the unique instance */
     
    425428    class OpenInBrowserAction extends AbstractAction {
    426429        public OpenInBrowserAction() {
    427             //putValue(NAME, tr("Open in Browser"));
    428430            putValue(SHORT_DESCRIPTION, tr("Open the current help page in an external browser"));
    429431            putValue(SMALL_ICON, ImageProvider.get("help", "internet"));
     
    438440    class EditAction extends AbstractAction {
    439441        public EditAction() {
    440             // putValue(NAME, tr("Edit"));
    441442            putValue(SHORT_DESCRIPTION, tr("Edit the current help page"));
    442443            putValue(SMALL_ICON,ImageProvider.get("dialogs", "edit"));
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r6792 r6798  
    272272    static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts) {
    273273        if(maxZoomLvl > MAX_ZOOM) {
    274             /*Main.debug("Max. zoom level should not be more than 30! Setting to 30.");*/
    275274            maxZoomLvl = MAX_ZOOM;
    276275        }
    277276        if(maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) {
    278             /*Main.debug("Max. zoom level should not be more than min. zoom level! Setting to min.");*/
    279277            maxZoomLvl = PROP_MIN_ZOOM_LVL.get();
    280278        }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r6792 r6798  
    919919                        timezone = parseTimezone(zone);
    920920                    } catch (ParseException pe) {
    921                         throw new RuntimeException();
     921                        throw new RuntimeException(pe);
    922922                    }
    923923                    delta = sldMinutes.getValue()*60 + sldSeconds.getValue();
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r6450 r6798  
    191191            c = super.clone();
    192192        } catch (CloneNotSupportedException e) {
    193             throw new RuntimeException();
     193            throw new RuntimeException(e);
    194194        }
    195195        return (ImageEntry) c;
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r6643 r6798  
    11071107    }
    11081108
    1109     private static DataFlavor ACTION_FLAVOR = new DataFlavor(
    1110             ActionDefinition.class, "ActionItem");
    1111 
     1109    private static final DataFlavor ACTION_FLAVOR = new DataFlavor(ActionDefinition.class, "ActionItem");
    11121110}
  • trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java

    r6792 r6798  
    6161    // independent from the keyboard's labelling. But the operation system's locale
    6262    // usually matches the keyboard. This even works with my English Windows and my German keyboard.
    63     private static String SHIFT = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.SHIFT_DOWN_MASK).getModifiers());
    64     private static String CTRL  = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK).getModifiers());
    65     private static String ALT   = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK).getModifiers());
    66     private static String META  = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK).getModifiers());
     63    private static final String SHIFT = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.SHIFT_DOWN_MASK).getModifiers());
     64    private static final String CTRL  = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK).getModifiers());
     65    private static final String ALT   = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK).getModifiers());
     66    private static final String META  = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK).getModifiers());
    6767
    6868    // A list of keys to present the user. Sadly this really is a list of keys Java knows about,
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java

    r6795 r6798  
    13621362                result.add(presetType);
    13631363            } catch (IllegalArgumentException e) {
    1364                 throw new SAXException(tr("Unknown type: {0}", type));
     1364                throw new SAXException(tr("Unknown type: {0}", type), e);
    13651365            }
    13661366        }
  • trunk/src/org/openstreetmap/josm/io/GpxImporter.java

    r6716 r6798  
    8686        } catch (SAXException e) {
    8787            Main.error(e);
    88             throw new IOException(tr("Parsing data for layer ''{0}'' failed", fileName));
     88            throw new IOException(tr("Parsing data for layer ''{0}'' failed", fileName), e);
    8989        }
    9090    }
     
    161161        } catch (SAXException e) {
    162162            Main.error(e);
    163             throw new IOException(tr("Parsing data for layer ''{0}'' failed", gpxLayerName));
     163            throw new IOException(tr("Parsing data for layer ''{0}'' failed", gpxLayerName), e);
    164164        }
    165165    }
  • trunk/src/org/openstreetmap/josm/io/NMEAImporter.java

    r6132 r6798  
    2525            "nmea,nme,nma,log,txt", "nmea", tr("NMEA-0183 Files") + " (*.nmea *.nme *.nma *.log *.txt)");
    2626
     27    /**
     28     * Constructs a new {@code NMEAImporter}.
     29     */
    2730    public NMEAImporter() {
    2831        super(FILE_FILTER);
    2932    }
    3033
    31     @Override public void importData(File file, ProgressMonitor progressMonitor) throws IOException {
     34    @Override
     35    public void importData(File file, ProgressMonitor progressMonitor) throws IOException {
    3236        final String fn = file.getName();
    33         final NmeaReader r = new NmeaReader(new FileInputStream(file), file.getAbsoluteFile().getParentFile());
     37        final NmeaReader r = new NmeaReader(new FileInputStream(file));
    3438        if (r.getNumberOfCoordinates() > 0) {
    3539            r.data.storageFile = file;
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r6296 r6798  
    33
    44import java.io.BufferedReader;
    5 import java.io.File;
    65import java.io.InputStream;
    76import java.io.InputStreamReader;
     
    170169    }
    171170
    172     public NmeaReader(InputStream source, File relativeMarkerPath) {
     171    public NmeaReader(InputStream source) {
    173172
    174173        // create the data tree
  • trunk/src/org/openstreetmap/josm/io/OsmImporter.java

    r6716 r6798  
    4444    }
    4545
     46    /**
     47     * Constructs a new {@code OsmImporter}.
     48     */
    4649    public OsmImporter() {
    4750        super(FILE_FILTER);
     
    6568        } catch (FileNotFoundException e) {
    6669            Main.error(e);
    67             throw new IOException(tr("File ''{0}'' does not exist.", file.getName()));
     70            throw new IOException(tr("File ''{0}'' does not exist.", file.getName()), e);
    6871        } finally {
    6972            Utils.close(in);
  • trunk/src/org/openstreetmap/josm/io/imagery/HTMLGrabber.java

    r6316 r6798  
    4545            browser = builder.start();
    4646        } catch (IOException ioe) {
    47             throw new IOException( "Could not start browser. Please check that the executable path is correct.\n" + ioe.getMessage() );
     47            throw new IOException("Could not start browser. Please check that the executable path is correct.\n" + ioe.getMessage(), ioe);
    4848        }
    4949
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java

    r6316 r6798  
    301301                        tags = URLDecoder.decode(args.get("addtags"), "UTF-8").split("\\|");
    302302                    } catch (UnsupportedEncodingException e) {
    303                         throw new RuntimeException();
     303                        throw new RuntimeException(e);
    304304                    }
    305305                    Set<String> tagSet = new HashSet<String>();
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java

    r6643 r6798  
    3737            Main.warn("RemoteControl: Error parsing import remote control request:");
    3838            Main.error(ex);
    39             throw new RequestHandlerErrorException();
     39            throw new RequestHandlerErrorException(ex);
    4040        }
    4141    }
     
    118118            url = new URL(urlString);
    119119        } catch (MalformedURLException e) {
    120             throw new RequestHandlerBadRequestException("MalformedURLException: "+e.getMessage());
     120            throw new RequestHandlerBadRequestException("MalformedURLException: "+e.getMessage(), e);
    121121        }
    122122        // Find download tasks for the given URL
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r6792 r6798  
    137137            Main.warn("RemoteControl: Error parsing load_and_zoom remote control request:");
    138138            Main.error(ex);
    139             throw new RequestHandlerErrorException();
     139            throw new RequestHandlerErrorException(ex);
    140140        }
    141141
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r6782 r6798  
    276276            return URLDecoder.decode(param, "UTF-8");
    277277        } catch (UnsupportedEncodingException e) {
    278             throw new RuntimeException();
     278            throw new RuntimeException(e);
    279279        }
    280280    }
     
    289289            super(message);
    290290        }
    291 
     291        public RequestHandlerException(String message, Throwable cause) {
     292            super(message, cause);
     293        }
     294        public RequestHandlerException(Throwable cause) {
     295            super(cause);
     296        }
    292297        public RequestHandlerException() {
    293298        }
     
    295300
    296301    public static class RequestHandlerErrorException extends RequestHandlerException {
     302        public RequestHandlerErrorException(Throwable cause) {
     303            super(cause);
     304        }
    297305    }
    298306
     
    302310            super(message);
    303311        }
     312        public RequestHandlerBadRequestException(String message, Throwable cause) {
     313            super(message, cause);
     314        }
    304315    }
    305316
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6792 r6798  
    480480            md = MessageDigest.getInstance("MD5");
    481481        } catch (NoSuchAlgorithmException e) {
    482             throw new RuntimeException();
     482            throw new RuntimeException(e);
    483483        }
    484484        byte[] byteDigest = md.digest(byteData);
Note: See TracChangeset for help on using the changeset viewer.