- Timestamp:
- 2013-12-29T21:46:27+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r6546 r6565 827 827 * @since 5519 828 828 */ 829 public static boolean saveUnsavedModifications( List<? extends Layer> selectedLayers, boolean exit) {829 public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, boolean exit) { 830 830 SaveLayersDialog dialog = new SaveLayersDialog(parent); 831 831 List<OsmDataLayer> layersWithUnmodifiedChanges = new ArrayList<OsmDataLayer>(); -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r6380 r6565 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 import java.util.HashMap; 9 10 import java.util.LinkedList; 10 11 import java.util.List; … … 231 232 @Override 232 233 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); 234 240 } 235 241 }); -
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r6336 r6565 10 10 import java.awt.event.ActionEvent; 11 11 import java.util.ArrayList; 12 import java.util.Collection; 12 13 import java.util.HashSet; 13 14 import java.util.Iterator; … … 47 48 @Override 48 49 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); 50 51 if (layers.isEmpty()) { 51 52 setEnabled(false); … … 58 59 JPopupMenu popup = new JPopupMenu(); 59 60 if (layers.size() == 1) { 60 JComponent c = layers. get(0).getOffsetMenuItem(popup);61 JComponent c = layers.iterator().next().getOffsetMenuItem(popup); 61 62 if (c instanceof JMenuItem) { 62 63 ((JMenuItem) c).getAction().actionPerformed(e); … … 183 184 return singleOffset; 184 185 } 185 List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);186 Collection<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class); 186 187 if (layers.isEmpty()) { 187 188 offsetAction.setEnabled(false); … … 200 201 newMenu.setAction(offsetAction); 201 202 if (layers.size() == 1) 202 return (JMenuItem)layers. get(0).getOffsetMenuItem(newMenu);203 return (JMenuItem)layers.iterator().next().getOffsetMenuItem(newMenu); 203 204 for (ImageryLayer layer : layers) { 204 205 JMenuItem layerMenu = layer.getOffsetMenuItem(); -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r6316 r6565 52 52 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 53 53 import org.openstreetmap.josm.gui.layer.GpxLayer; 54 import org.openstreetmap.josm.gui.layer.ImageryLayer; 54 55 import org.openstreetmap.josm.gui.layer.Layer; 55 56 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 56 57 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 58 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 57 59 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 58 60 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; … … 61 63 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 62 64 import org.openstreetmap.josm.tools.Shortcut; 65 import org.openstreetmap.josm.tools.Utils; 63 66 64 67 /** … … 733 736 * @return an unmodifiable list of layers of a certain type. 734 737 */ 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); 743 740 } 744 741 … … 968 965 } 969 966 } 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 } 970 985 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r6388 r6565 889 889 protected final <P extends OsmPrimitive> OsmDataLayer findLayerFor(P primitive) { 890 890 if (primitive != null) { 891 List<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class);891 Iterable<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class); 892 892 // Find layer with same dataset 893 893 for (OsmDataLayer layer : layers) { -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r6450 r6565 12 12 import java.awt.event.KeyEvent; 13 13 import java.awt.event.KeyListener; 14 import java.util.Arrays; 14 15 import java.util.Collections; 15 16 import java.util.LinkedList; … … 65 66 pnl.add(new JLabel(tr("Specify the data source for the changes:")), GBC.eol().insets(0, 8, 10, 3)); 66 67 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"))); 68 69 Collections.reverse(sourceHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement() 69 70 hcbUploadSource.setPossibleItems(sourceHistory); -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r6428 r6565 314 314 public void setDefaultChangesetTags(Map<String, String> tags) { 315 315 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")); 321 318 } 322 319 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java
r6313 r6565 8 8 import java.io.IOException; 9 9 import java.util.ArrayList; 10 import java.util.Collection; 10 11 import java.util.List; 11 12 … … 95 96 96 97 protected WMSLayer askWMSLayer() { 97 List<WMSLayer> targetLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);98 Collection<WMSLayer> targetLayers = Main.map.mapView.getLayersOfType(WMSLayer.class); 98 99 if (targetLayers.isEmpty()) { 99 100 warnNoImageryLayers();
Note:
See TracChangeset
for help on using the changeset viewer.