Changeset 7966 in josm


Ignore:
Timestamp:
2015-01-13T23:35:32+01:00 (10 years ago)
Author:
bastiK
Message:

fixed #10934 - JOSM>Imagery menu order and contents - Don't use hidden country grouping in menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r7937 r7966  
    1111import java.util.ArrayList;
    1212import java.util.Collection;
     13import java.util.Collections;
     14import java.util.Comparator;
    1315import java.util.Iterator;
    1416import java.util.List;
    15 import java.util.Set;
    16 import java.util.TreeSet;
    17 
    1817import javax.swing.Action;
    1918import javax.swing.JComponent;
     
    2120import javax.swing.JMenuItem;
    2221import javax.swing.JPopupMenu;
    23 import javax.swing.MenuElement;
    2422import javax.swing.event.MenuEvent;
    2523import javax.swing.event.MenuListener;
    26 
    2724import org.openstreetmap.josm.Main;
    2825import org.openstreetmap.josm.actions.AddImageryLayerAction;
     
    4643public class ImageryMenu extends JMenu implements LayerChangeListener {
    4744
     45    /**
     46     * Compare ImageryInfo objects alphabetically by name.
     47     *
     48     * ImageryInfo objects are normally sorted by country code first
     49     * (for the preferences). We don't want this in the imagery menu.
     50     */
     51    public static Comparator<ImageryInfo> alphabeticImageryComparator = new Comparator<ImageryInfo>() {
     52        @Override
     53        public int compare(ImageryInfo ii1, ImageryInfo ii2) {
     54            return ii1.getName().toLowerCase().compareTo(ii2.getName().toLowerCase());
     55        }
     56    };
     57
    4858    private Action offsetAction = new JosmAction(
    4959            tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false) {
     
    134144
    135145        // for each configured ImageryInfo, add a menu entry.
    136         for (final ImageryInfo u : ImageryLayerInfo.instance.getLayers()) {
     146        final List<ImageryInfo> savedLayers = new ArrayList<>(ImageryLayerInfo.instance.getLayers());
     147        Collections.sort(savedLayers, alphabeticImageryComparator);
     148        for (final ImageryInfo u : savedLayers) {
    137149            addDynamic(new AddImageryLayerAction(u));
    138150        }
     
    143155            MapView mv = Main.map.mapView;
    144156            LatLon pos = mv.getProjection().eastNorth2latlon(mv.getCenter());
    145             final Set<ImageryInfo> inViewLayers = new TreeSet<>();
     157            final List<ImageryInfo> inViewLayers = new ArrayList<>();
    146158
    147159            for (ImageryInfo i : ImageryLayerInfo.instance.getDefaultLayers()) {
     
    167179            }
    168180            if (!inViewLayers.isEmpty()) {
     181                Collections.sort(inViewLayers, alphabeticImageryComparator);
    169182                addDynamicSeparator();
    170183                for (ImageryInfo i : inViewLayers) {
Note: See TracChangeset for help on using the changeset viewer.