Changeset 6816 in josm
- Timestamp:
- 2014-02-06T10:14:46+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java
r6771 r6816 197 197 protected void tryToPasteFromClipboard(OsmIdTextField tfId, OsmPrimitiveTypesComboBox cbType) { 198 198 String buf = Utils.getClipboardContent(); 199 if (buf != null) { 200 if (buf.length() <= Main.pref.getInteger("downloadprimitive.max-autopaste-length", 2000)) { 201 final List<SimplePrimitiveId> ids = SimplePrimitiveId.fuzzyParse(buf); 202 final String parsedText = Utils.join(", ", Utils.transform(ids, new Utils.Function<SimplePrimitiveId, String>() { 203 @Override 204 public String apply(SimplePrimitiveId x) { 205 return x.getType().getAPIName().charAt(0) + String.valueOf(x.getUniqueId()); 206 } 207 })); 208 tfId.tryToPasteFrom(parsedText); 209 final Set<OsmPrimitiveType> types = new HashSet<OsmPrimitiveType>(Utils.transform(ids, new Utils.Function<SimplePrimitiveId, OsmPrimitiveType>() { 210 @Override 211 public OsmPrimitiveType apply(SimplePrimitiveId x) { 212 return x.getType(); 213 } 214 })); 215 if (types.size() == 1) { 216 // select corresponding type 217 cbType.setSelectedItem(types.iterator().next()); 218 } else { 219 // select "mixed" 220 cbType.setSelectedIndex(3); 199 if (buf == null || buf.length()==0) return; 200 if (buf.length() > Main.pref.getInteger("downloadprimitive.max-autopaste-length", 2000)) return; 201 final List<SimplePrimitiveId> ids = SimplePrimitiveId.fuzzyParse(buf); 202 if (!ids.isEmpty()) { 203 final String parsedText = Utils.join(", ", Utils.transform(ids, new Utils.Function<SimplePrimitiveId, String>() { 204 @Override 205 public String apply(SimplePrimitiveId x) { 206 return x.getType().getAPIName().charAt(0) + String.valueOf(x.getUniqueId()); 221 207 } 208 })); 209 tfId.tryToPasteFrom(parsedText); 210 final Set<OsmPrimitiveType> types = new HashSet<OsmPrimitiveType>(Utils.transform(ids, new Utils.Function<SimplePrimitiveId, OsmPrimitiveType>() { 211 @Override 212 public OsmPrimitiveType apply(SimplePrimitiveId x) { 213 return x.getType(); 214 } 215 })); 216 if (types.size() == 1) { 217 // select corresponding type 218 cbType.setSelectedItem(types.iterator().next()); 222 219 } else { 223 if (buf.contains("node")) cbType.setSelectedIndex(0); 224 if (buf.contains("way")) cbType.setSelectedIndex(1); 225 if (buf.contains("relation")) cbType.setSelectedIndex(2); 226 String[] res = buf.split("/"); 227 String txt; 228 if (res.length > 0) { 229 txt = res[res.length - 1]; 230 if (txt.isEmpty() && txt.length() > 1) txt = res[res.length - 2]; 231 } 232 } 220 // select "mixed" 221 cbType.setSelectedIndex(3); 222 } 223 } else if (buf.matches("[\\d,v\\s]+")) { 224 //fallback solution for id1,id2,id3 format 225 tfId.tryToPasteFrom(buf); 233 226 } 234 227 }
Note:
See TracChangeset
for help on using the changeset viewer.