Changeset 7024 in josm for trunk


Ignore:
Timestamp:
2014-04-29T02:38:59+02:00 (10 years ago)
Author:
Don-vip
Message:

sonar - Variables should not be declared and then immediately returned or thrown

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r7005 r7024  
    477477                relations.size(), relations.size(), DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relations))
    478478                + "</html>"));
    479         boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
     479        return ConditionalOptionPaneUtil.showConfirmationDialog(
    480480                "delete_relations",
    481481                Main.parent,
     
    485485                JOptionPane.QUESTION_MESSAGE,
    486486                JOptionPane.YES_OPTION);
    487         return answer;
    488487    }
    489488}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r7005 r7024  
    320320        PseudoCommand c = ((CommandListMutableTreeNode) path.getLastPathComponent()).getCommand();
    321321        final OsmDataLayer currentLayer = Main.main.getEditLayer();
    322         FilteredCollection<OsmPrimitive> prims = new FilteredCollection<>(
     322        return new FilteredCollection<>(
    323323                c.getParticipatingPrimitives(),
    324324                new Predicate<OsmPrimitive>(){
     
    330330                }
    331331        );
    332         return prims;
    333332    }
    334333
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r7005 r7024  
    14201420            };
    14211421
    1422             int ret = HelpAwareOptionPane.showOptionDialog(
     1422            return HelpAwareOptionPane.showOptionDialog(
    14231423                    Main.parent,
    14241424                    tr("<html>The relation has been changed.<br>"
     
    14321432                            "/Dialog/RelationEditor#DiscardChanges"
    14331433            );
    1434             return ret;
    14351434        }
    14361435    }
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r7005 r7024  
    121121    }
    122122
    123     /*boolean debug = true;*/
    124 
    125123    public interface TileLoaderFactory {
    126124        OsmTileLoader makeTileLoader(TileLoaderListener listener);
     
    170168        Main.map.repaint(100);
    171169        tileRequestsOutstanding.remove(tile);
    172         /*if (debug) {
     170        if (Main.isDebugEnabled()) {
    173171            Main.debug("tileLoadingFinished() tile: " + tile + " success: " + success);
    174         }*/
     172        }
    175173    }
    176174
     
    639637            }
    640638        }));
    641         // end of adding menu commands
    642639
    643640        final MouseAdapter adapter = new MouseAdapter() {
     
    677674
    678675    void zoomChanged() {
    679         /*if (debug) {
     676        if (Main.isDebugEnabled()) {
    680677            Main.debug("zoomChanged(): " + currentZoomLevel);
    681         }*/
     678        }
    682679        needRedraw = true;
    683680        JobDispatcher.getInstance().cancelOutstandingJobs();
     
    703700    public boolean zoomIncreaseAllowed() {
    704701        boolean zia = currentZoomLevel < this.getMaxZoomLvl();
    705         /*if (debug) {
     702        if (Main.isDebugEnabled()) {
    706703            Main.debug("zoomIncreaseAllowed(): " + zia + " " + currentZoomLevel + " vs. " + this.getMaxZoomLvl() );
    707         }*/
     704        }
    708705        return zia;
    709706    }
     
    712709        if (zoomIncreaseAllowed()) {
    713710            currentZoomLevel++;
    714             /*if (debug) {
     711            if (Main.isDebugEnabled()) {
    715712                Main.debug("increasing zoom level to: " + currentZoomLevel);
    716             }*/
     713            }
    717714            zoomChanged();
    718715        } else {
     
    750747        //int minZoom = this.getMinZoomLvl();
    751748        if (zoomDecreaseAllowed()) {
    752             /*if (debug) {
     749            if (Main.isDebugEnabled()) {
    753750                Main.debug("decreasing zoom level to: " + currentZoomLevel);
    754             }*/
     751            }
    755752            currentZoomLevel--;
    756753            zoomChanged();
     
    847844        boolean done = ((infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0);
    848845        needRedraw = true;
    849         /*if (debug) {
     846        if (Main.isDebugEnabled()) {
    850847            Main.debug("imageUpdate() done: " + done + " calling repaint");
    851         }*/
     848        }
    852849        Main.map.repaint(done ? 0 : 100);
    853850        return !done;
     
    911908        if (border != null) {
    912909            target = source.intersection(border);
    913             /*if (debug) {
     910            if (Main.isDebugEnabled()) {
    914911                Main.debug("source: " + source + "\nborder: " + border + "\nintersection: " + target);
    915             }*/
     912            }
    916913        }
    917914
     
    938935        int img_y_end   = img_y_offset + (int)(target.getHeight() * imageYScaling);
    939936
    940         /*if (debug) {
     937        if (Main.isDebugEnabled()) {
    941938            Main.debug("drawing image into target rect: " + target);
    942         }*/
     939        }
    943940        g.drawImage(sourceImg,
    944941                target.x, target.y,
     
    980977            Image img = getLoadedTileImage(tile);
    981978            if (img == null || tile.hasError()) {
    982                 /*if (debug) {
     979                if (Main.isDebugEnabled()) {
    983980                    Main.debug("missed tile: " + tile);
    984                 }*/
     981                }
    985982                missedTiles.add(tile);
    986983                continue;
     
    991988            }
    992989            drawImageInside(g, img, sourceRect, borderRect);
    993         }// end of for
     990        }
    994991        return missedTiles;
    995992    }
     
    10171014                texty += 1 + fontHeight;
    10181015            }
    1019         }*/// end of if draw debug
     1016        }*/
    10201017
    10211018        if (tile == showMetadataTile) {
     
    13991396            missedTiles = newlyMissedTiles;
    14001397        }
    1401         /*if (debug && missedTiles.size() > 0) {
     1398        if (Main.isDebugEnabled() && missedTiles.size() > 0) {
    14021399            Main.debug("still missed "+missedTiles.size()+" in the end");
    1403         }*/
     1400        }
    14041401        g.setColor(Color.red);
    14051402        g.setFont(InfoFont);
     
    14271424            myDrawString(g, tr("No tiles at this zoom level"), 120, 120);
    14281425        }
    1429         /*if (debug) {
     1426        if (Main.isDebugEnabled()) {
    14301427            myDrawString(g, tr("Current zoom: {0}", currentZoomLevel), 50, 140);
    14311428            myDrawString(g, tr("Display zoom: {0}", displayZoomLevel), 50, 155);
    14321429            myDrawString(g, tr("Pixel scale: {0}", getScaleFactor(currentZoomLevel)), 50, 170);
    14331430            myDrawString(g, tr("Best zoom: {0}", Math.log(getScaleFactor(1))/Math.log(2)/2+1), 50, 185);
    1434         }*/
     1431        }
    14351432    }
    14361433
     
    14401437     */
    14411438    Tile getTileForPixelpos(int px, int py) {
    1442         /*if (debug) {
     1439        if (Main.isDebugEnabled()) {
    14431440            Main.debug("getTileForPixelpos("+px+", "+py+")");
    1444         }*/
     1441        }
    14451442        MapView mv = Main.map.mapView;
    14461443        Point clicked = new Point(px, py);
     
    14581455            Rectangle r = new Rectangle(pixelPos(t1));
    14591456            r.add(pixelPos(t2));
    1460             /*if (debug) {
     1457            if (Main.isDebugEnabled()) {
    14611458                Main.debug("r: " + r + " clicked: " + clicked);
    1462             }*/
     1459            }
    14631460            if (!r.contains(clicked)) {
    14641461                continue;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r6986 r7024  
    242242    @Override
    243243    public String toString() {
    244         String result = file.getName()+": "+
     244        return file.getName()+": "+
    245245        "pos = "+pos+" | "+
    246246        "exifCoor = "+exifCoor+" | "+
    247247        (tmp == null ? " tmp==null" :
    248248            " [tmp] pos = "+tmp.pos);
    249         return result;
    250249    }
    251250
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r7005 r7024  
    13631363            if (value == null)
    13641364                return this;
    1365             SourceEntry se = (SourceEntry) value;
    1366             JLabel label = (JLabel)super.getTableCellRendererComponent(table,
    1367                     fromSourceEntry(se), isSelected, hasFocus, row, column);
    1368             return label;
     1365            return super.getTableCellRendererComponent(table,
     1366                    fromSourceEntry((SourceEntry) value), isSelected, hasFocus, row, column);
    13691367        }
    13701368
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java

    r7005 r7024  
    502502        }
    503503
    504         SequenceCommand command = new SequenceCommand(
     504        return new SequenceCommand(
    505505                trn("Remove old keys from up to {0} object", "Remove old keys from up to {0} objects", primitives.size(), primitives.size()),
    506506                commands
    507507        );
    508 
    509         return command;
    510508    }
    511509
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r7005 r7024  
    5050    public static String explainOsmApiInitializationException(OsmApiInitializationException e) {
    5151        Main.error(e);
    52         String msg = tr(
     52        return tr(
    5353                "<html>Failed to initialize communication with the OSM server {0}.<br>"
    5454                + "Check the server URL in your preferences and your internet connection.",
    5555                Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
    56         return msg;
    5756    }
    5857
     
    6564    public static String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) {
    6665        Main.error(e);
    67         String msg = tr(
     66        return tr(
    6867                "<html>Failed to authenticate at the OSM server ''{0}''.<br>"
    6968                + "You are using OAuth to authenticate but currently there is no<br>"
     
    7372                Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL)
    7473        );
    75         return msg;
    7674    }
    7775
     
    411409     */
    412410    public static String explainChangesetClosedException(ChangesetClosedException e) {
    413         String msg;
    414411        SimpleDateFormat dateFormat = new SimpleDateFormat();
    415         msg = tr(
     412        Main.error(e);
     413        return tr(
    416414                "<html>Failed to upload to changeset <strong>{0}</strong><br>"
    417415                +"because it has already been closed on {1}.",
     
    419417                e.getClosedOn() == null ? "?" : dateFormat.format(e.getClosedOn())
    420418        );
    421         Main.error(e);
    422         return msg;
    423419    }
    424420
     
    454450        }
    455451
    456         String message = tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''<br>"
     452        return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''<br>"
    457453                + "for security reasons. This is most likely because you are running<br>"
    458454                + "in an applet and because you did not load your applet from ''{1}''.", apiUrl, host);
    459         return message;
    460455    }
    461456
     
    467462     * @param e the exception
    468463     */
    469 
    470464    public static String explainNestedSocketException(OsmTransferException e) {
    471         String apiUrl = e.getUrl();
    472         String message = tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
    473                 + "Please check your internet connection.", apiUrl);
    474         Main.error(e);
    475         return message;
     465        Main.error(e);
     466        return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
     467                + "Please check your internet connection.", e.getUrl());
    476468    }
    477469
     
    483475     * @param e the exception
    484476     */
    485 
    486477    public static String explainNestedIOException(OsmTransferException e) {
    487478        IOException ioe = getNestedException(e, IOException.class);
    488         String apiUrl = e.getUrl();
    489         String message = tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>"
     479        Main.error(e);
     480        return tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>"
    490481                + "due to a problem with transferring data.<br>"
    491                 + "Details (untranslated): {1}</html>", apiUrl, ioe
     482                + "Details (untranslated): {1}</html>", e.getUrl(), ioe
    492483                .getMessage());
    493         Main.error(e);
    494         return message;
    495484    }
    496485
     
    503492    public static String explainNestedIllegalDataException(OsmTransferException e) {
    504493        IllegalDataException ide = getNestedException(e, IllegalDataException.class);
    505         String message = tr("<html>Failed to download data. "
     494        Main.error(e);
     495        return tr("<html>Failed to download data. "
    506496                + "Its format is either unsupported, ill-formed, and/or inconsistent.<br>"
    507497                + "<br>Details (untranslated): {0}</html>", ide.getMessage());
    508         Main.error(e);
    509         return message;
    510498    }
    511499
     
    516504     * @param e the exception
    517505     */
    518 
    519506    public static String explainInternalServerError(OsmTransferException e) {
    520         String apiUrl = e.getUrl();
    521         String message = tr("<html>The OSM server<br>" + "''{0}''<br>" + "reported an internal server error.<br>"
    522                 + "This is most likely a temporary problem. Please try again later.", apiUrl);
    523         Main.error(e);
    524         return message;
     507        Main.error(e);
     508        return tr("<html>The OSM server<br>" + "''{0}''<br>" + "reported an internal server error.<br>"
     509                + "This is most likely a temporary problem. Please try again later.", e.getUrl());
    525510    }
    526511
     
    543528            message += tr("<br>Error message(untranslated): {0}", e.getErrorHeader());
    544529        }
    545         message = "<html>" + message + "</html>";
    546         Main.error(e);
    547         return message;
     530        Main.error(e);
     531        return "<html>" + message + "</html>";
    548532    }
    549533
     
    555539     */
    556540    public static String explainBandwidthLimitExceeded(OsmApiException e) {
     541        Main.error(e);
    557542        // TODO: Write a proper error message
    558         String message = explainGenericOsmApiException(e);
    559         Main.error(e);
    560         return message;
    561     }
    562 
     543        return explainGenericOsmApiException(e);
     544    }
    563545
    564546    /**
     
    574556                + "it. Please carefully check the server''s address ''{0}'' for typos."
    575557                , apiUrl);
    576         message = "<html>" + message + "</html>";
    577         Main.error(e);
    578         return message;
     558        Main.error(e);
     559        return "<html>" + message + "</html>";
    579560    }
    580561
     
    596577        }
    597578
    598         String message = tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
     579        Main.error(e);
     580        return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
    599581                + "Host name ''{1}'' could not be resolved. <br>"
    600582                + "Please check the API URL in your preferences and your internet connection.", apiUrl, host);
    601         Main.error(e);
    602         return message;
    603583    }
    604584
     
    669649     */
    670650    public static String explainGoneForUnknownPrimitive(OsmApiException e) {
    671         String msg = tr(
     651        return tr(
    672652                "<html>The server reports that an object is deleted.<br>"
    673653                + "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "
     
    676656                + "The error message is:<br>" + "{0}"
    677657                + "</html>", escapeReservedCharactersHTML(e.getMessage()));
    678         return msg;
    679 
    680658    }
    681659
     
    686664     */
    687665    public static String explainException(Exception e) {
    688         String msg = "";
     666        Main.error(e);
    689667        if (e instanceof OsmTransferException) {
    690             msg = explainOsmTransferException((OsmTransferException) e);
     668            return explainOsmTransferException((OsmTransferException) e);
    691669        } else {
    692             msg = explainGeneric(e);
    693         }
    694         Main.error(e);
    695         return msg;
     670            return explainGeneric(e);
     671        }
    696672    }
    697673
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7012 r7024  
    804804            img = overlay(img, ImageProvider.get("cursor/modifier/" + overlay), OverlayPosition.SOUTHEAST);
    805805        }
    806         Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
     806        return Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
    807807                "crosshair".equals(name) ? new Point(10, 10) : new Point(3, 2), "Cursor");
    808         return c;
    809808    }
    810809
Note: See TracChangeset for help on using the changeset viewer.