Changeset 25702 in osm for applications
- Timestamp:
- 2011-03-25T07:32:25+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/relcontext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/relcontext/TODO
r25696 r25702 11 11 - Solve multipolygon settings button width problem 12 12 - Solve width problem for narrows buttons when "fix" and "download" appear simultaneously 13 - Sort relation members button (now it's just role fixer) 13 14 14 15 == RELEASE == -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/CreateMultipolygonAction.java
r25695 r25702 61 61 rel.put("type", "boundary"); 62 62 rel.put("boundary", "administrative"); 63 askForAdminLevelAndName(rel);64 63 } else 65 64 rel.put("type", "multipolygon"); … … 73 72 addBoundaryMembers(rel); 74 73 List<Command> list = removeTagsFromInnerWays(rel); 74 if( !askForAdminLevelAndName(rel) ) 75 return; 75 76 if( isBoundary && getPref("boundaryways") ) 76 77 list.addAll(fixWayTagsForBoundary(rel)); … … 180 181 static public final String[] DEFAULT_LINEAR_TAGS = {"barrier", "source"}; 181 182 183 private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS = new TreeSet<String>(Arrays.asList(new String[] { 184 "boundary", "boundary_type", "type", "admin_level" 185 })); 186 182 187 /** 183 188 * This method removes tags/value pairs from inner ways that are present in relation or outer ways. … … 196 201 List<Way> innerWays = new ArrayList<Way>(); 197 202 List<Way> outerWays = new ArrayList<Way>(); 203 198 204 Set<String> conflictingKeys = new TreeSet<String>(); 199 205 … … 233 239 values.remove("natural"); 234 240 241 boolean isBoundary = getPref("boundary"); 242 String name = values.get("name"); 243 String adminLevel = values.get("admin_level"); 244 if( isBoundary ) { 245 Set<String> keySet = new TreeSet<String>(values.keySet()); 246 for( String key : keySet ) 247 if( !REMOVE_FROM_BOUNDARY_TAGS.contains(key) ) 248 values.remove(key); 249 } 250 235 251 values.put("area", "yes"); 236 252 … … 243 259 244 260 for (Way way: innerWays) { 245 if (value.equals(way.get(key))) {261 if( way.hasKey(key) && (isBoundary || value.equals(way.get(key))) ) { 246 262 affectedWays.add(way); 247 263 } … … 264 280 if( moveTags ) { 265 281 // add those tag values to the relation 282 if( isBoundary ) 283 values.put("name", name); 266 284 boolean fixed = false; 267 285 Relation r2 = new Relation(relation); 268 286 for( String key : values.keySet() ) { 269 if( !r2.hasKey(key) && !key.equals("area") ) { 270 r2.put(key, values.get(key)); 287 if( !r2.hasKey(key) && !key.equals("area") 288 && (!isBoundary || key.equals("admin_level") || key.equals("name"))) { 289 if( relation.isNew() ) 290 relation.put(key, values.get(key)); 291 else 292 r2.put(key, values.get(key)); 271 293 fixed = true; 272 294 } 273 295 } 274 if( fixed )296 if( fixed && !relation.isNew() ) 275 297 commands.add(new ChangeCommand(relation, r2)); 276 298 } … … 279 301 } 280 302 281 private void askForAdminLevelAndName( Relation rel ) { 303 /** 304 * 305 * @param rel 306 * @return false if user pressed "cancel". 307 */ 308 private boolean askForAdminLevelAndName( Relation rel ) { 309 String relAL = rel.get("admin_level"); 310 String relName = rel.get("name"); 311 if( relAL != null && relName != null ) 312 return true; 313 282 314 JPanel panel = new JPanel(new GridBagLayout()); 283 315 panel.add(new JLabel(tr("Enter admin level and name for the border relation:")), GBC.eol().insets(0, 0, 0, 5)); 284 316 285 317 final JTextField admin = new JTextField(); 286 admin.setText( Main.pref.get(PREF_MULTIPOLY + "lastadmin", ""));318 admin.setText(relAL != null ? relAL : Main.pref.get(PREF_MULTIPOLY + "lastadmin", "")); 287 319 panel.add(new JLabel(tr("Admin level")), GBC.std()); 288 320 panel.add(Box.createHorizontalStrut(10), GBC.std()); … … 290 322 291 323 final JTextField name = new JTextField(); 324 if( relName != null ) 325 name.setText(relName); 292 326 panel.add(new JLabel(tr("Name")), GBC.std()); 293 327 panel.add(Box.createHorizontalStrut(10), GBC.std()); … … 316 350 if( answer == null || answer == JOptionPane.UNINITIALIZED_VALUE 317 351 || (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION) ) { 318 return ;352 return false; 319 353 } 320 354 … … 327 361 if( new_name.length() > 0 ) 328 362 rel.put("name", new_name); 363 return true; 329 364 } 330 365 }
Note:
See TracChangeset
for help on using the changeset viewer.