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


Ignore:
Timestamp:
2018-12-31T19:36:59+01:00 (6 years ago)
Author:
Don-vip
Message:

fix various SonarQube issues

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

Legend:

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

    r14153 r14624  
    237237        oldMapMode = map.mapMode;
    238238        super.actionPerformed(e);
     239    }
     240
     241    private static final class ConfirmOverwriteBookmarkDialog extends ExtendedDialog {
     242        ConfirmOverwriteBookmarkDialog() {
     243            super(MainApplication.getMainFrame(), tr("Overwrite"), new String[] {tr("Overwrite"), tr("Cancel")});
     244            contentInsets = new Insets(10, 15, 10, 15);
     245            setContent(tr("Offset bookmark already exists. Overwrite?"));
     246            setButtonIcons("ok", "cancel");
     247        }
    239248    }
    240249
     
    326335
    327336        private boolean confirmOverwriteBookmark() {
    328             ExtendedDialog dialog = new ExtendedDialog(
    329                     MainApplication.getMainFrame(),
    330                     tr("Overwrite"),
    331                     tr("Overwrite"), tr("Cancel")
    332             ) { {
    333                 contentInsets = new Insets(10, 15, 10, 15);
    334             } };
    335             dialog.setContent(tr("Offset bookmark already exists. Overwrite?"));
    336             dialog.setButtonIcons("ok", "cancel");
    337             dialog.setupDialog();
    338             dialog.setVisible(true);
    339             return dialog.getValue() == 1;
     337            return new ConfirmOverwriteBookmarkDialog().showDialog().getValue() == 1;
    340338        }
    341339
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r14374 r14624  
    327327        }
    328328
    329         /**
    330          * @param layerName the name of the new layer
    331          * @deprecated Use {@link #createNewLayer(DataSet, Optional)}
    332          * @return a newly constructed layer
    333          */
    334         @Deprecated
    335         protected OsmDataLayer createNewLayer(final String layerName) {
    336             return createNewLayer(Optional.ofNullable(layerName).filter(it -> !Utils.isStripEmpty(it)));
    337         }
    338 
    339         /**
    340          * @deprecated Use {@link #createNewLayer(Optional)}
    341          * @return a newly constructed layer
    342          */
    343         @Deprecated
    344         protected OsmDataLayer createNewLayer() {
    345             return createNewLayer(Optional.empty());
    346         }
    347 
    348329        protected Optional<ProjectionBounds> computeBbox(Bounds bounds) {
    349330            BoundingXYVisitor v = new BoundingXYVisitor();
     
    361342                // the user explicitly wants a new layer, we don't have any layer at all
    362343                // or it is not clear which layer to merge to
    363                 final OsmDataLayer layer = createNewLayer(newLayerName);
     344                final OsmDataLayer layer = createNewLayer(Optional.ofNullable(newLayerName).filter(it -> !Utils.isStripEmpty(it)));
    364345                MainApplication.getLayerManager().addLayer(layer, zoomAfterDownload);
    365346                return layer;
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r14460 r14624  
    489489                GpxData d = new GpxData();
    490490                d.addTrack(trk);
    491                 return new GpxLayer(d, ensureUniqueName(attrs, counts)); })
     491                return new GpxLayer(d, ensureUniqueName(attrs, counts));
     492            })
    492493            .forEachOrdered(layer -> MainApplication.getLayerManager().addLayer(layer));
    493494    }
     
    509510     */
    510511    public synchronized int getTrackSegsCount() {
    511         return privateTracks.stream().collect(Collectors.summingInt(t -> t.getSegments().size()));
     512        return privateTracks.stream().mapToInt(t -> t.getSegments().size()).sum();
    512513    }
    513514
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java

    r14210 r14624  
    2727 * @since 14205 (extracted from gui.layer.geoimage.ImageEntry)
    2828 */
    29 public class GpxImageEntry implements Comparable<GpxImageEntry>, Cloneable {
     29public class GpxImageEntry implements Comparable<GpxImageEntry> {
    3030    private File file;
    3131    private Integer exifOrientation;
     
    7373
    7474    /**
     75     * Constructs a new {@code GpxImageEntry} from an existing instance.
     76     * @param other existing instance
     77     * @since 14624
     78     */
     79    public GpxImageEntry(GpxImageEntry other) {
     80        file = other.file;
     81        exifOrientation = other.exifOrientation;
     82        exifCoor = other.exifCoor;
     83        exifImgDir = other.exifImgDir;
     84        exifTime = other.exifTime;
     85        isNewGpsData = other.isNewGpsData;
     86        exifGpsTime = other.exifGpsTime;
     87        pos = other.pos;
     88        speed = other.speed;
     89        elevation = other.elevation;
     90        gpsTime = other.gpsTime;
     91        width = other.width;
     92        height = other.height;
     93        tmp = other.tmp;
     94    }
     95
     96    /**
    7597     * Constructs a new {@code GpxImageEntry}.
    7698     * @param file Path to image file on disk
     
    311333    public void setExifImgDir(Double exifDir) {
    312334        this.exifImgDir = exifDir;
    313     }
    314 
    315     @Override
    316     public GpxImageEntry clone() {
    317         try {
    318             return (GpxImageEntry) super.clone();
    319         } catch (CloneNotSupportedException e) {
    320             throw new IllegalStateException(e);
    321         }
    322335    }
    323336
     
    370383     */
    371384    public void createTmp() {
    372         tmp = clone();
     385        tmp = new GpxImageEntry(this);
    373386        tmp.tmp = null;
    374387    }
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java

    r14261 r14624  
    7878     */
    7979    public static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers, int hostLimit) {
    80         ThreadPoolExecutor executor = new ThreadPoolExecutor(
     80        return new ThreadPoolExecutor(
    8181                workers, // keep core pool the same size as max, as we use unbounded queue so there will
    8282                workers, // be never more threads than corePoolSize
     
    8686                Utils.newThreadFactory(nameFormat, Thread.NORM_PRIORITY)
    8787                );
    88         return executor;
    8988    }
    9089
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java

    r13647 r14624  
    1010import java.util.Collections;
    1111import java.util.List;
     12import java.util.stream.Collectors;
    1213
     14import org.openstreetmap.josm.spi.preferences.Config;
    1315import org.openstreetmap.josm.tools.Logging;
    1416import org.openstreetmap.josm.tools.Platform;
     
    7476    }
    7577
     78    private static List<File> visit(String prefSuffix, String... defaults) {
     79        return Config.getPref().getList("ntv2.proj4.grid.dir." + prefSuffix, Arrays.asList(defaults))
     80                               .stream().map(File::new).collect(Collectors.toList());
     81    }
     82
    7683    @Override
    7784    public List<File> visitUnixoid() {
    78         return Arrays.asList(new File("/usr/local/share/proj"), new File("/usr/share/proj"));
     85        return visit("unix", "/usr/local/share/proj", "/usr/share/proj");
    7986    }
    8087
    8188    @Override
    8289    public List<File> visitWindows() {
    83         return Arrays.asList(new File("C:\\PROJ\\NAD"));
     90        return visit("windows", "C:\\PROJ\\NAD");
    8491    }
    8592
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r14468 r14624  
    230230                    continue;
    231231                }
    232                 if (!s.highway && endnodesHighway.contains(en) && !s.w.concernsArea()) {
    233                     map.put(en, s.w);
    234                 } else if (endnodes.contains(en) && !s.w.concernsArea()) {
     232                if (((!s.highway && endnodesHighway.contains(en)) || endnodes.contains(en)) && !s.w.concernsArea()) {
    235233                    map.put(en, s.w);
    236234                }
  • trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java

    r14153 r14624  
    358358                    for (PluginInformation pi4: toDeletePlugins) {
    359359                        pls.remove(pi4.name);
    360                         new File(Preferences.main().getPluginsDirectory(), pi4.name+".jar").deleteOnExit();
     360                        Utils.deleteFile(new File(Preferences.main().getPluginsDirectory(), pi4.name+".jar"));
    361361                    }
    362362                    Config.getPref().putList("plugins", pls);
  • trunk/src/org/openstreetmap/josm/io/OnlineResource.java

    r14121 r14624  
    4141     */
    4242    public final void checkOfflineAccess(String downloadString, String resourceString) {
    43         if (NetworkManager.isOffline(this) && downloadString.substring(downloadString.indexOf("://"))
    44                 .startsWith(resourceString.substring(resourceString.indexOf("://")))) {
     43        if (NetworkManager.isOffline(this) && downloadString
     44                .startsWith(resourceString.substring(resourceString.indexOf("://")), downloadString.indexOf("://"))) {
    4545            throw new OfflineAccessException(tr("Unable to access ''{0}'': {1} not available (offline mode)", downloadString, getLocName()));
    4646        }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r14377 r14624  
    1010import java.util.Collections;
    1111import java.util.HashSet;
    12 import java.util.Locale;
    1312import java.util.Set;
    1413import java.util.concurrent.Future;
     
    318317            for (String item : args.get("select").split(",")) {
    319318                if (!item.isEmpty()) {
    320                     if (CURRENT_SELECTION.equals(item.toLowerCase(Locale.ENGLISH))) {
     319                    if (CURRENT_SELECTION.equalsIgnoreCase(item)) {
    321320                        isKeepingCurrentSelection = true;
    322321                        continue;
Note: See TracChangeset for help on using the changeset viewer.