Changeset 7546 in josm for trunk


Ignore:
Timestamp:
2014-09-16T19:51:33+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10354 - Do not display warning when canceling a new empty relation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r7434 r7546  
    7878import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    7979import org.openstreetmap.josm.gui.tagging.PresetHandler;
     80import org.openstreetmap.josm.gui.tagging.TagEditorModel;
    8081import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    8182import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     
    738739    }
    739740
    740     public static Command addPrimitivesToRelation(final Relation orig, Collection<? extends OsmPrimitive> primitivesToAdd) throws IllegalArgumentException {
     741    public static Command addPrimitivesToRelation(final Relation orig, Collection<? extends OsmPrimitive> primitivesToAdd)
     742            throws IllegalArgumentException {
    741743        CheckParameterUtil.ensureParameterNotNull(orig, "orig");
    742744        try {
    743             final Collection<TaggingPreset> presets = TaggingPreset.getMatchingPresets(EnumSet.of(TaggingPresetType.RELATION), orig.getKeys(), false);
     745            final Collection<TaggingPreset> presets = TaggingPreset.getMatchingPresets(
     746                    EnumSet.of(TaggingPresetType.RELATION), orig.getKeys(), false);
    744747            Relation relation = new Relation(orig);
    745748            boolean modified = false;
     
    13701373        public void actionPerformed(ActionEvent e) {
    13711374            memberTable.stopHighlighting();
    1372             if (!memberTableModel.hasSameMembersAs(getRelationSnapshot()) || tagEditorPanel.getModel().isDirty()) {
     1375            TagEditorModel tagModel = tagEditorPanel.getModel();
     1376            Relation snapshot = getRelationSnapshot();
     1377            if ( (!memberTableModel.hasSameMembersAs(snapshot) || tagModel.isDirty())
     1378             && !(snapshot == null && tagModel.getTags().isEmpty())) {
    13731379                //give the user a chance to save the changes
    13741380                int ret = confirmClosingByCancel();
     
    13781384                    if (getRelation() == null) {
    13791385                        applyNewRelation();
    1380                     } else if (!memberTableModel.hasSameMembersAs(getRelationSnapshot())
    1381                             || tagEditorPanel.getModel().isDirty()) {
     1386                    } else if (!memberTableModel.hasSameMembersAs(snapshot) || tagModel.isDirty()) {
    13821387                        if (isDirtyRelation()) {
    13831388                            if (confirmClosingBecauseOfDirtyState()) {
     
    13931398                        }
    13941399                    }
    1395                 }
    1396                 else if (ret == 2) //Cancel, continue editing
     1400                } else if (ret == 2) //Cancel, continue editing
    13971401                    return;
    13981402                //in case of "No, discard", there is no extra action to be performed here.
Note: See TracChangeset for help on using the changeset viewer.