Changeset 6565 in josm


Ignore:
Timestamp:
2013-12-29T21:46:27+01:00 (11 years ago)
Author:
simon04
Message:

fix #9484 - source in upload dialog: add knowledge, survey to selection, compute value from layers

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

Legend:

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

    r6546 r6565  
    827827     * @since 5519
    828828     */
    829     public static boolean saveUnsavedModifications(List<? extends Layer> selectedLayers, boolean exit) {
     829    public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, boolean exit) {
    830830        SaveLayersDialog dialog = new SaveLayersDialog(parent);
    831831        List<OsmDataLayer> layersWithUnmodifiedChanges = new ArrayList<OsmDataLayer>();
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r6380 r6565  
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
     9import java.util.HashMap;
    910import java.util.LinkedList;
    1011import java.util.List;
     
    231232            @Override
    232233            public void run() {
    233                 dialog.setDefaultChangesetTags(layer.data.getChangeSetTags());
     234                final HashMap<String, String> tags = new HashMap<String, String>(layer.data.getChangeSetTags());
     235                if (!tags.containsKey("source")) {
     236                    tags.put("source", Main.map.mapView.getLayerInformationForSourceTag());
     237                    System.out.println(tags.get("source"));
     238                }
     239                dialog.setDefaultChangesetTags(tags);
    234240            }
    235241        });
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r6336 r6565  
    1010import java.awt.event.ActionEvent;
    1111import java.util.ArrayList;
     12import java.util.Collection;
    1213import java.util.HashSet;
    1314import java.util.Iterator;
     
    4748        @Override
    4849        public void actionPerformed(ActionEvent e) {
    49             List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     50            Collection<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
    5051            if (layers.isEmpty()) {
    5152                setEnabled(false);
     
    5859            JPopupMenu popup = new JPopupMenu();
    5960            if (layers.size() == 1) {
    60                 JComponent c = layers.get(0).getOffsetMenuItem(popup);
     61                JComponent c = layers.iterator().next().getOffsetMenuItem(popup);
    6162                if (c instanceof JMenuItem) {
    6263                    ((JMenuItem) c).getAction().actionPerformed(e);
     
    183184            return singleOffset;
    184185        }
    185         List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     186        Collection<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
    186187        if (layers.isEmpty()) {
    187188            offsetAction.setEnabled(false);
     
    200201        newMenu.setAction(offsetAction);
    201202        if (layers.size() == 1)
    202             return (JMenuItem)layers.get(0).getOffsetMenuItem(newMenu);
     203            return (JMenuItem)layers.iterator().next().getOffsetMenuItem(newMenu);
    203204        for (ImageryLayer layer : layers) {
    204205            JMenuItem layerMenu = layer.getOffsetMenuItem();
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r6316 r6565  
    5252import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
    5353import org.openstreetmap.josm.gui.layer.GpxLayer;
     54import org.openstreetmap.josm.gui.layer.ImageryLayer;
    5455import org.openstreetmap.josm.gui.layer.Layer;
    5556import org.openstreetmap.josm.gui.layer.MapViewPaintable;
    5657import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     58import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    5759import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    5860import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
     
    6163import org.openstreetmap.josm.tools.BugReportExceptionHandler;
    6264import org.openstreetmap.josm.tools.Shortcut;
     65import org.openstreetmap.josm.tools.Utils;
    6366
    6467/**
     
    733736     * @return an unmodifiable list of layers of a certain type.
    734737     */
    735     public <T> List<T>  getLayersOfType(Class<T> ofType) {
    736         List<T> ret = new ArrayList<T>();
    737         for (Layer layer : getAllLayersAsList()) {
    738             if (ofType.isInstance(layer)) {
    739                 ret.add(ofType.cast(layer));
    740             }
    741         }
    742         return ret;
     738    public <T extends Layer> Collection<T>  getLayersOfType(Class<T> ofType) {
     739        return Utils.filteredCollection(getAllLayers(), ofType);
    743740    }
    744741
     
    968965        }
    969966    }
     967
     968    /**
     969     * Get a string representation of all layers suitable for the {@code source} changeset tag.
     970     */
     971    public String getLayerInformationForSourceTag() {
     972        final Collection<String> layerInfo = new ArrayList<String>();
     973        if (!getLayersOfType(GpxLayer.class).isEmpty()) {
     974            // no i18n for international values
     975            layerInfo.add("survey");
     976        }
     977        for (final GeoImageLayer i : getLayersOfType(GeoImageLayer.class)) {
     978            layerInfo.add(i.getName());
     979        }
     980        for (final ImageryLayer i : getLayersOfType(ImageryLayer.class)) {
     981            layerInfo.add(i.getName());
     982        }
     983        return Utils.join("; ", layerInfo);
     984    }
    970985}
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java

    r6388 r6565  
    889889    protected final <P extends OsmPrimitive> OsmDataLayer findLayerFor(P primitive) {
    890890        if (primitive != null) {
    891             List<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class);
     891            Iterable<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class);
    892892            // Find layer with same dataset
    893893            for (OsmDataLayer layer : layers) {
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r6450 r6565  
    1212import java.awt.event.KeyEvent;
    1313import java.awt.event.KeyListener;
     14import java.util.Arrays;
    1415import java.util.Collections;
    1516import java.util.LinkedList;
     
    6566        pnl.add(new JLabel(tr("Specify the data source for the changes:")), GBC.eol().insets(0, 8, 10, 3));
    6667        hcbUploadSource.setToolTipText(tr("Enter a source"));
    67         List<String> sourceHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_HISTORY_KEY, new LinkedList<String>()));
     68        List<String> sourceHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_HISTORY_KEY, Arrays.asList("knowledge", "survey")));
    6869        Collections.reverse(sourceHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    6970        hcbUploadSource.setPossibleItems(sourceHistory);
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r6428 r6565  
    314314    public void setDefaultChangesetTags(Map<String, String> tags) {
    315315        pnlTagSettings.setDefaultTags(tags);
    316          for (Entry<String, String> entry: tags.entrySet()) {
    317             if ("comment".equals(entry.getKey())) {
    318                 changesetCommentModel.setComment(entry.getValue());
    319             }
    320         }
     316        changesetCommentModel.setComment(tags.get("comment"));
     317        changesetSourceModel.setComment(tags.get("source"));
    321318    }
    322319
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java

    r6313 r6565  
    88import java.io.IOException;
    99import java.util.ArrayList;
     10import java.util.Collection;
    1011import java.util.List;
    1112
     
    9596
    9697    protected WMSLayer askWMSLayer() {
    97         List<WMSLayer> targetLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);
     98        Collection<WMSLayer> targetLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);
    9899        if (targetLayers.isEmpty()) {
    99100            warnNoImageryLayers();
Note: See TracChangeset for help on using the changeset viewer.