Ticket #20024: 20024.patch

File 20024.patch, 1.5 KB (added by GerdP, 5 years ago)

this one should work

  • src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

     
    401401    public void showAndApply(Collection<OsmPrimitive> primitives) {
    402402        // Display dialog even if no data layer (used by preset-tagging-tester plugin)
    403403        Collection<OsmPrimitive> sel = createSelection(primitives);
    404         int answer = showDialog(sel, supportsRelation());
     404        boolean showNewRelation = supportsRelation() &&
     405                primitives.stream().allMatch(prim -> roles.roles.stream()
     406                        .anyMatch(role -> role.types.contains(TaggingPresetType.forPrimitive(prim))));
    405407
     408        int answer = showDialog(sel, showNewRelation);
     409
    406410        if (!sel.isEmpty() && answer == DIALOG_ANSWER_APPLY) {
    407411            Command cmd = createCommand(sel, getChangedTags());
    408412            if (cmd != null) {
     
    492496        PresetPanel p = createPanel(sel);
    493497
    494498        int answer = 1;
    495         boolean canCreateRelation = types == null || types.contains(TaggingPresetType.RELATION);
     499        boolean canCreateRelation = supportsRelation();
    496500        if (originalSelectionEmpty && !canCreateRelation) {
    497501            new Notification(
    498502                    tr("The preset <i>{0}</i> cannot be applied since nothing has been selected!", getLocaleName()))