Ignore:
Timestamp:
2016-01-27T22:18:36+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #12410 - new button to refresh relation in relation editor (patch by kolesar, modified for checkstyle, javadoc, unit test)

File:
1 edited

Legend:

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

    r9496 r9657  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
    67import java.util.ArrayList;
    78import java.util.List;
     
    111112        Main.main.undoRedo.add(new ChangeCommand(editor.getRelation(), editedRelation));
    112113        layer.data.fireSelectionChanged();
    113         // this will refresh the snapshot and update the dialog title
    114         //
    115         editor.setRelation(editor.getRelation());
    116114    }
    117115
     
    166164        // Do nothing
    167165    }
     166
     167    protected boolean applyChanges() {
     168        if (editor.getRelation() == null) {
     169            applyNewRelation(tagModel);
     170        } else if (isEditorDirty()) {
     171            if (editor.isDirtyRelation()) {
     172                if (confirmClosingBecauseOfDirtyState()) {
     173                    if (layer.getConflicts().hasConflictForMy(editor.getRelation())) {
     174                        warnDoubleConflict();
     175                        return false;
     176                    }
     177                    applyExistingConflictingRelation(tagModel);
     178                    hideEditor();
     179                } else
     180                    return false;
     181            } else {
     182                applyExistingNonConflictingRelation(tagModel);
     183            }
     184        }
     185        editor.setRelation(editor.getRelation());
     186        return true;
     187    }
     188
     189    protected void hideEditor() {
     190        if (editor instanceof Component) {
     191            ((Component) editor).setVisible(false);
     192        }
     193    }
     194
     195    protected boolean isEditorDirty() {
     196        Relation snapshot = editor.getRelationSnapshot();
     197        return (snapshot != null && !memberTableModel.hasSameMembersAs(snapshot)) || tagModel.isDirty();
     198    }
    168199}
Note: See TracChangeset for help on using the changeset viewer.