Changeset 1840 in josm for trunk/src/org


Ignore:
Timestamp:
2009-07-25T17:31:48+02:00 (15 years ago)
Author:
Gubaer
Message:

prevent circular references in relations (contributes to a fix for #2996)

File:
1 edited

Legend:

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

    r1839 r1840  
    6969import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;
    7070import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
     71import org.openstreetmap.josm.gui.OptionPaneUtil;
    7172import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    7273import org.openstreetmap.josm.gui.PrimitiveNameFormatter;
     
    666667        }
    667668
     669        protected void warnOfCircularReferences(OsmPrimitive primitive) {
     670            String msg = tr("<html>You are trying to add a relation to itself.<br>"
     671                    + "<br>"
     672                    + "This creates circular references and is therefore discouraged.<br>"
     673                    + "Skipping relation ''{0}''.</html>",
     674                    this.nameFormatter.getName(primitive)
     675            );
     676            OptionPaneUtil.showMessageDialog(Main.parent, msg, tr("Warning"), JOptionPane.WARNING_MESSAGE);
     677        }
     678
    668679        protected List<OsmPrimitive> filterConfirmedPrimitives(List<OsmPrimitive> primitives) throws AddAbortException {
    669680            if (primitives == null || primitives.isEmpty())
     
    673684            while(it.hasNext()) {
    674685                OsmPrimitive primitive = it.next();
     686                if (primitive instanceof Relation && getRelation().equals(primitive)) {
     687                    warnOfCircularReferences(primitive);
     688                    continue;
     689                }
    675690                if (isPotentialDuplicate(primitive) && confirmAddingPrimtive(primitive)) {
    676691                    ret.add(primitive);
Note: See TracChangeset for help on using the changeset viewer.