Changeset 6674 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2014-01-12T10:41:20+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java
r6577 r6674 3 3 4 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 5 6 import org.openstreetmap.josm.data.osm.PrimitiveId; 7 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 6 8 import org.openstreetmap.josm.gui.ExtendedDialog; 7 9 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; … … 29 31 import java.util.Collection; 30 32 import java.util.Collections; 33 import java.util.HashSet; 31 34 import java.util.LinkedList; 32 35 import java.util.List; 36 import java.util.Set; 33 37 34 38 import static org.openstreetmap.josm.tools.I18n.tr; … … 187 191 String buf = Utils.getClipboardContent(); 188 192 if (buf != null) { 189 if (buf.contains("node")) cbType.setSelectedIndex(0); 190 if (buf.contains("way")) cbType.setSelectedIndex(1); 191 if (buf.contains("relation")) cbType.setSelectedIndex(2); 192 String[] res = buf.split("/"); 193 String txt; 194 if (res.length > 0) { 195 txt = res[res.length - 1]; 196 if (txt.isEmpty() && txt.length() > 1) txt = res[res.length - 2]; 193 if (buf.length() <= Main.pref.getInteger("downloadprimitive.max-autopaste-length", 2000)) { 194 final List<SimplePrimitiveId> ids = SimplePrimitiveId.fuzzyParse(buf); 195 final String parsedText = Utils.join(", ", Utils.transform(ids, new Utils.Function<SimplePrimitiveId, String>() { 196 @Override 197 public String apply(SimplePrimitiveId x) { 198 return x.getType().getAPIName().charAt(0) + String.valueOf(x.getUniqueId()); 199 } 200 })); 201 tfId.tryToPasteFrom(parsedText); 202 final Set<OsmPrimitiveType> types = new HashSet<OsmPrimitiveType>(Utils.transform(ids, new Utils.Function<SimplePrimitiveId, OsmPrimitiveType>() { 203 @Override 204 public OsmPrimitiveType apply(SimplePrimitiveId x) { 205 return x.getType(); 206 } 207 })); 208 if (types.size() == 1) { 209 // select corresponding type 210 cbType.setSelectedItem(types.iterator().next()); 211 } else { 212 // select "mixed" 213 cbType.setSelectedIndex(3); 214 } 197 215 } else { 198 txt = buf; 199 } 200 if (buf.length() <= Main.pref.getInteger("downloadprimitive.max-autopaste-length", 2000)) { 201 tfId.tryToPasteFrom(txt.replaceAll("[^0-9]+", " ").replaceAll("\\s\\s+", " ")); 216 if (buf.contains("node")) cbType.setSelectedIndex(0); 217 if (buf.contains("way")) cbType.setSelectedIndex(1); 218 if (buf.contains("relation")) cbType.setSelectedIndex(2); 219 String[] res = buf.split("/"); 220 String txt; 221 if (res.length > 0) { 222 txt = res[res.length - 1]; 223 if (txt.isEmpty() && txt.length() > 1) txt = res[res.length - 2]; 224 } 202 225 } 203 226 }
Note:
See TracChangeset
for help on using the changeset viewer.