Changeset 7153 in josm for trunk/src/org
- Timestamp:
- 2014-05-20T21:48:59+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r7100 r7153 384 384 originalSelectionEmpty = participants.isEmpty(); 385 385 Collection<OsmPrimitive> sel = new LinkedList<>(); 386 for (OsmPrimitive osm : participants) 387 { 388 if (types != null) 389 { 390 if(osm instanceof Relation) 391 { 392 if(!types.contains(TaggingPresetType.RELATION) && 393 !(types.contains(TaggingPresetType.CLOSEDWAY) && ((Relation)osm).isMultipolygon())) { 394 continue; 395 } 396 } 397 else if(osm instanceof Node) 398 { 399 if(!types.contains(TaggingPresetType.NODE)) { 400 continue; 401 } 402 } 403 else if(osm instanceof Way) 404 { 405 if(!types.contains(TaggingPresetType.WAY) && 406 !(types.contains(TaggingPresetType.CLOSEDWAY) && ((Way)osm).isClosed())) { 407 continue; 408 } 409 } 410 } 411 sel.add(osm); 386 for (OsmPrimitive osm : participants) { 387 if (typeMatches(EnumSet.of(TaggingPresetType.forPrimitive(osm)))) { 388 sel.add(osm); 389 } 412 390 } 413 391 return sel; -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSelector.java
r7100 r7153 53 53 import org.openstreetmap.josm.gui.widgets.JosmTextField; 54 54 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 55 import org.openstreetmap.josm.tools.Predicate; 56 import org.openstreetmap.josm.tools.Utils; 55 57 56 58 /** … … 334 336 boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected(); 335 337 336 List<PresetClassification> result = new ArrayList<>(); 337 PRESET_LOOP: 338 for (PresetClassification presetClasification: classifications) { 339 TaggingPreset preset = presetClasification.preset; 340 presetClasification.classification = 0; 341 342 if (onlyApplicable && preset.types != null) { 343 boolean found = false; 344 for (TaggingPresetType type: preset.types) { 345 if (getTypesInSelection().contains(type)) { 346 found = true; 347 break; 348 } 349 } 350 if (!found) { 351 continue; 352 } 353 } 354 355 if (groupWords != null && presetClasification.isMatchingGroup(groupWords) == 0) { 356 continue PRESET_LOOP; 357 } 358 359 int matchName = presetClasification.isMatchingName(nameWords); 360 361 if (matchName == 0) { 362 if (groupWords == null) { 363 int groupMatch = presetClasification.isMatchingGroup(nameWords); 364 if (groupMatch > 0) { 365 presetClasification.classification = CLASSIFICATION_GROUP_MATCH + groupMatch; 366 } 367 } 368 if (presetClasification.classification == 0 && inTags) { 369 int tagsMatch = presetClasification.isMatchingTags(nameWords); 370 if (tagsMatch > 0) { 371 presetClasification.classification = CLASSIFICATION_TAGS_MATCH + tagsMatch; 372 } 373 } 338 final List<PresetClassification> result = new ArrayList<>(); 339 for (PresetClassification presetClassification : classifications) { 340 TaggingPreset preset = presetClassification.preset; 341 presetClassification.classification = 0; 342 343 if (onlyApplicable && !preset.typeMatches(getTypesInSelection())) { 344 final Predicate<Role> memberExpressionMatchesOnePrimitive = new Predicate<Role>() { 345 @Override 346 public boolean evaluate(Role object) { 347 return object.memberExpression != null && Utils.exists(Main.main.getCurrentDataSet().getSelected(), object.memberExpression); 348 } 349 }; 350 if (preset.types.contains(TaggingPresetType.RELATION) && preset.roles != null 351 && Utils.exists(preset.roles.roles, memberExpressionMatchesOnePrimitive)) { 352 // keep to allow the creation of new relations 374 353 } else { 375 presetClasification.classification = CLASSIFICATION_NAME_MATCH + matchName; 376 } 377 378 if (presetClasification.classification > 0) { 379 presetClasification.classification += presetClasification.favoriteIndex; 380 result.add(presetClasification); 381 } 382 } 354 continue; 355 } 356 } 357 358 if (groupWords != null && presetClassification.isMatchingGroup(groupWords) == 0) { 359 continue; 360 } 361 362 int matchName = presetClassification.isMatchingName(nameWords); 363 364 if (matchName == 0) { 365 if (groupWords == null) { 366 int groupMatch = presetClassification.isMatchingGroup(nameWords); 367 if (groupMatch > 0) { 368 presetClassification.classification = CLASSIFICATION_GROUP_MATCH + groupMatch; 369 } 370 } 371 if (presetClassification.classification == 0 && inTags) { 372 int tagsMatch = presetClassification.isMatchingTags(nameWords); 373 if (tagsMatch > 0) { 374 presetClassification.classification = CLASSIFICATION_TAGS_MATCH + tagsMatch; 375 } 376 } 377 } else { 378 presetClassification.classification = CLASSIFICATION_NAME_MATCH + matchName; 379 } 380 381 if (presetClassification.classification > 0) { 382 presetClassification.classification += presetClassification.favoriteIndex; 383 result.add(presetClassification); 384 } 385 } 383 386 384 387 Collections.sort(result);
Note:
See TracChangeset
for help on using the changeset viewer.