Changeset 4796 in josm
- Timestamp:
- 2012-01-15T21:28:46+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java
r4675 r4796 200 200 } 201 201 202 void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers, boolean full) { 202 /** 203 * @param newLayer if the data should be downloaded into a new layer 204 * @param ids 205 * @param downloadReferrers if the referrers of the object should be downloaded as well, i.e., parent relations, and for nodes, additionally, parent ways 206 * @param full if the members of a relation should be downloaded as well 207 */ 208 public static void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers, boolean full) { 203 209 OsmDataLayer layer = getEditLayer(); 204 210 if ((layer == null) || newLayer) { … … 274 280 } 275 281 276 private ExtendedDialog reportProblemDialog(Set<PrimitiveId> errs,282 private static ExtendedDialog reportProblemDialog(Set<PrimitiveId> errs, 277 283 String TITLE, String TEXT, String LIST_LABEL, int msgType) { 278 284 JPanel p = new JPanel(new GridBagLayout()); -
trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java
r3115 r4796 3 3 4 4 import java.io.Serializable; 5 import java.util.regex.Matcher; 6 import java.util.regex.Pattern; 5 7 6 8 public class SimplePrimitiveId implements PrimitiveId, Serializable { … … 57 59 return type + " " + id; 58 60 } 61 62 /** 63 * Parses a {@code OsmPrimitiveType} from the string {@code s}. 64 * @param s the string to be parsed, e.g., {@code n1}, {@code node1}, 65 * {@code w1}, {@code way1}, {@code r1}, {@code rel1}, {@code relation1}. 66 * @return the parsed {@code OsmPrimitiveType} 67 * @throws IllegalArgumentException if the string does not match the pattern 68 */ 69 public static SimplePrimitiveId fromString(String s) { 70 final Pattern p = Pattern.compile("((n(ode)?|w(ay)?|r(el(ation)?)?)/?)(\\d+)"); 71 final Matcher m = p.matcher(s); 72 if (m.matches()) { 73 return new SimplePrimitiveId(Long.parseLong(m.group(m.groupCount())), 74 s.charAt(0) == 'n' ? OsmPrimitiveType.NODE 75 : s.charAt(0) == 'w' ? OsmPrimitiveType.WAY 76 : OsmPrimitiveType.RELATION); 77 } else { 78 throw new IllegalArgumentException("The string " + s + " does not match the pattern " + p); 79 } 80 } 59 81 } -
trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java
r4081 r4796 92 92 93 93 public boolean readOsmIds() { 94 String value 94 String value = getComponent().getText(); 95 95 char c; 96 if (value == null || value.trim().length() == 0) return false; 97 try { 98 ids.clear(); 99 StringTokenizer st = new StringTokenizer(value,",.+/ \t\n"); 100 String s; 101 while (st.hasMoreTokens()) { 102 s = st.nextToken(); 103 // convert tokens to int skipping v-words (version v2 etc) 104 c = s.charAt(0); 105 if (c=='v') { 106 continue; 107 } 108 else if (c=='n') { 109 ids.add(new SimplePrimitiveId(Long.parseLong(s.substring(1)), OsmPrimitiveType.NODE)); 110 } else if (c=='w') { 111 ids.add(new SimplePrimitiveId(Long.parseLong(s.substring(1)), OsmPrimitiveType.WAY)); 112 } else if (c=='r') { 113 ids.add(new SimplePrimitiveId(Long.parseLong(s.substring(1)), OsmPrimitiveType.RELATION)); 114 } else if (type==OsmPrimitiveType.NODE) { 115 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.NODE)); 116 } else if (type==OsmPrimitiveType.WAY) { 117 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.WAY)); 118 } else if (type==OsmPrimitiveType.RELATION) { 119 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.RELATION)); 96 if (value == null || value.trim().length() == 0) { 97 return false; 98 } 99 ids.clear(); 100 StringTokenizer st = new StringTokenizer(value, ",.+/ \t\n"); 101 String s; 102 while (st.hasMoreTokens()) { 103 s = st.nextToken(); 104 // convert tokens to int skipping v-words (version v2 etc) 105 c = s.charAt(0); 106 if (c == 'v') { 107 continue; 108 } else { 109 try { 110 ids.add(SimplePrimitiveId.fromString(s)); 111 } catch (IllegalArgumentException ex) { 112 if (type == OsmPrimitiveType.NODE) { 113 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.NODE)); 114 } else if (type == OsmPrimitiveType.WAY) { 115 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.WAY)); 116 } else if (type == OsmPrimitiveType.RELATION) { 117 ids.add(new SimplePrimitiveId(Long.parseLong(s), OsmPrimitiveType.RELATION)); 118 } else { 119 return false; 120 } 120 121 } 121 122 } 122 return true;123 } catch(NumberFormatException e) {124 return false;125 123 } 124 return true; 126 125 } 127 126 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
r3715 r4796 19 19 import org.openstreetmap.josm.io.remotecontrol.handler.ImportHandler; 20 20 import org.openstreetmap.josm.io.remotecontrol.handler.LoadAndZoomHandler; 21 import org.openstreetmap.josm.io.remotecontrol.handler.LoadObject; 21 22 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler; 22 23 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; … … 117 118 addRequestHandlerClass(ImportHandler.command, ImportHandler.class, true); 118 119 addRequestHandlerClass(VersionHandler.command, VersionHandler.class, true); 120 addRequestHandlerClass(LoadObject.command, LoadObject.class, true); 119 121 } 120 122
Note:
See TracChangeset
for help on using the changeset viewer.