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


Ignore:
Timestamp:
2017-05-28T03:43:59+02:00 (7 years ago)
Author:
Don-vip
Message:

sonar - fix various recent violations

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r12220 r12267  
    44import java.io.File;
    55import java.text.MessageFormat;
    6 import java.util.AbstractCollection;
    76import java.util.ArrayList;
    87import java.util.Collection;
     
    2423import org.openstreetmap.josm.data.gpx.GpxTrack.GpxTrackChangeListener;
    2524import org.openstreetmap.josm.tools.ListenerList;
     25import org.openstreetmap.josm.tools.ListeningCollection;
    2626
    2727/**
     
    668668
    669669    /**
    670      * This is a proxy of a collection that notifies a listener on every collection change
    671      * @author Michael Zangl
    672      *
    673      * @param <T> The entry type
    674      * @since 12156
    675      */
    676     private static class ListeningCollection<T> extends AbstractCollection<T> {
    677         private final ArrayList<T> base;
    678         private final Runnable runOnModification;
    679 
    680         ListeningCollection(ArrayList<T> base, Runnable runOnModification) {
    681             this.base = base;
    682             this.runOnModification = runOnModification;
    683         }
    684 
    685         @Override
    686         public Iterator<T> iterator() {
    687             Iterator<T> it = base.iterator();
    688             return new Iterator<T>() {
    689                 private T cursor;
    690 
    691                 @Override
    692                 public boolean hasNext() {
    693                     return it.hasNext();
    694                 }
    695 
    696                 @Override
    697                 public T next() {
    698                     cursor = it.next();
    699                     return cursor;
    700                 }
    701 
    702                 @Override
    703                 public void remove() {
    704                     if (cursor != null) {
    705                         removed(cursor);
    706                         cursor = null;
    707                     }
    708                     it.remove();
    709                 }
    710             };
    711         }
    712 
    713         @Override
    714         public int size() {
    715             return base.size();
    716         }
    717 
    718         @Override
    719         @SuppressWarnings("unchecked")
    720         public boolean remove(Object o) {
    721             boolean remove = base.remove(o);
    722             if (remove) {
    723                 removed((T) o);
    724             }
    725             return remove;
    726         }
    727 
    728         @Override
    729         public boolean add(T e) {
    730             boolean add = base.add(e);
    731             added(e);
    732             return add;
    733         }
    734 
    735         protected void removed(T cursor) {
    736             runOnModification.run();
    737         }
    738 
    739         protected void added(T cursor) {
    740             runOnModification.run();
    741         }
    742     }
    743 
    744     /**
    745670     * A listener that listens to GPX data changes.
    746671     * @author Michael Zangl
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r12177 r12267  
    784784        }
    785785        // if this is really a change (and not the first active layer)
    786         if (e.getPreviousActiveLayer() != null) {
    787             if (!modeChanged && mapMode != null) {
    788                 // Let mapmodes know about new active layer
    789                 mapMode.exitMode();
    790                 mapMode.enterMode();
    791             }
     786        if (e.getPreviousActiveLayer() != null && !modeChanged && mapMode != null) {
     787            // Let mapmodes know about new active layer
     788            mapMode.exitMode();
     789            mapMode.enterMode();
    792790        }
    793791
  • trunk/src/org/openstreetmap/josm/io/session/ImagerySessionExporter.java

    r12134 r12267  
    9898    }
    9999
    100     private void addAttributes(Element element, Map<String, String> props, ExportSupport support) {
     100    private static void addAttributes(Element element, Map<String, String> props, ExportSupport support) {
    101101        for (Map.Entry<String, String> entry : props.entrySet()) {
    102102            Element attrElem = support.createElement(entry.getKey());
  • trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java

    r12134 r12267  
    5959    }
    6060
    61     private Map<String, String> readProperties(Element elem) {
     61    private static Map<String, String> readProperties(Element elem) {
    6262        Map<String, String> attributes = new HashMap<>();
    6363        NodeList nodes = elem.getChildNodes();
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r12219 r12267  
    174174                        || (javaVersion == 9 && javaUpdate == 0 && javaBuild < 171))) {
    175175                    // Workaround from https://bugs.openjdk.java.net/browse/JDK-8179014
    176                     UIManager.put("FileChooser.useSystemExtensionHiding", false);
     176                    UIManager.put("FileChooser.useSystemExtensionHiding", Boolean.FALSE);
    177177                }
    178178            } catch (NumberFormatException | ReflectiveOperationException e) {
Note: See TracChangeset for help on using the changeset viewer.