Ticket #24444: 24444.patch

File 24444.patch, 4.1 KB (added by GerdP, 7 months ago)

Please review. It seems to fix the known problems, but the code itself is not very self explaining.

  • src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

     
    160160     * A list of listeners that need to be notified on clipboard content changes.
    161161     */
    162162    private final ArrayList<FlavorListener> clipboardListeners = new ArrayList<>();
     163    private boolean isSaving;
    163164
    164165    /**
    165166     * Creates a new relation editor for the given relation. The relation will be saved if the user
     
    10701071            } else if (isDirtyRelation()) {
    10711072                if (!isDirtyEditor()) {
    10721073                    reloadDataFromRelation();
    1073                 } else {
     1074                } else if (!isSaving) {
    10741075                    new Notification(tr("Relation modified outside of relation editor with pending changes. Conflict resolution required."))
    10751076                    .setIcon(JOptionPane.WARNING_MESSAGE).show();
    10761077                }
     
    10851086        return (snapshot != null && !memberTableModel.hasSameMembersAs(snapshot)) ||
    10861087                tagEditorPanel.getModel().isDirty() || relation == null || relation.getDataSet() == null;
    10871088    }
     1089
     1090    @Override
     1091    public void setIsSaving(boolean b) {
     1092        isSaving = b;
     1093    }
    10881094}
  • src/org/openstreetmap/josm/gui/dialogs/relation/IRelationEditor.java

     
    6666    boolean isDirtyEditor();
    6767
    6868    /**
     69     * Set the isSaving flag to the given value
     70     * @param b the flag value
     71     * @since xxx
     72     */
     73    void setIsSaving(boolean b);
     74
     75    /**
    6976     * Reloads data from relation.
    7077     */
    7178    void reloadDataFromRelation();
  • src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

     
    115115
    116116    @Override
    117117    public final void setRelation(Relation relation) {
     118        setIsSaving(false);
    118119        setRelationSnapshot((relation == null) ? null : new Relation(relation));
    119120        Relation oldValue = this.relation;
    120121        this.relation = relation;
  • src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java

     
    171171                        warnDoubleConflict();
    172172                        return false;
    173173                    }
     174                    getEditor().setIsSaving(true);
    174175                    applyExistingConflictingRelation(getTagModel());
    175176                    hideEditor();
    176177                    return false;
     
    177178                } else
    178179                    return false;
    179180            } else {
     181                getEditor().setIsSaving(true);
    180182                applyExistingNonConflictingRelation(getTagModel());
    181183            }
    182184        }
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java

     
    122122            public OsmDataLayer getLayer() {
    123123                return layer;
    124124            }
     125
     126            @Override
     127            public void setIsSaving(boolean b) {
     128                // do nothing
     129            }
    125130        };
    126131    }
    127132