Ticket #6561: 6561.patch

File 6561.patch, 10.7 KB (added by simon04, 14 years ago)
  • src/org/openstreetmap/josm/actions/MergeNodesAction.java

    diff --git a/src/org/openstreetmap/josm/actions/MergeNodesAction.java b/src/org/openstreetmap/josm/actions/MergeNodesAction.java
    index 63f36d6..5118068 100644
    a b public class MergeNodesAction extends JosmAction {  
    214214                    };
    215215                    HelpAwareOptionPane.showOptionDialog(
    216216                            Main.parent,
    217                             tr(
    218                                     "Cannot merge nodes: Would have to delete way ''{0}'' which is still used.",
    219                                     w.getDisplayName(DefaultNameFormatter.getInstance())
    220                             ),
     217                            tr("Cannot merge nodes: Would have to delete way {0} which is still used by {1}",
     218                                DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(w),
     219                                DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(w.getReferrers())),
    221220                            tr("Warning"),
    222221                            JOptionPane.WARNING_MESSAGE,
    223222                            null, /* no icon */
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java

    diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
    index 5a98e40..8eaac96 100644
    a b public class DownloadOsmTaskList {  
    159159                                ),
    160160        };
    161161
    162         String message = "<html>"
    163                 + trn("There is {0} object in your local dataset which "
    164                         + "might be deleted on the server. If you later try to delete or "
    165                         + "update this the server is likely to report a conflict.",
    166                         "There are {0} objects in your local dataset which "
    167                                 + "might be deleted on the server. If you later try to delete or "
    168                                 + "update them the server is likely to report a conflict.", potentiallyDeleted.size(), potentiallyDeleted.size())
    169                                 + "<br>"
    170                                 + trn("Click <strong>{0}</strong> to check the state of this object on the server.",
    171                                         "Click <strong>{0}</strong> to check the state of these objects on the server.",
    172                                         potentiallyDeleted.size(),
    173                                         options[0].text) + "<br>"
    174                                         + tr("Click <strong>{0}</strong> to ignore." + "</html>", options[1].text);
     162        String message = "<html>" + trn(
     163                "There is {0} object in your local dataset which "
     164                + "might be deleted on the server.<br>If you later try to delete or "
     165                + "update this the server is likely to report a conflict.",
     166                "There are {0} objects in your local dataset which "
     167                + "might be deleted on the server.<br>If you later try to delete or "
     168                + "update them the server is likely to report a conflict.",
     169                potentiallyDeleted.size(), potentiallyDeleted.size())
     170                + "<br>"
     171                + trn("Click <strong>{0}</strong> to check the state of this object on the server.",
     172                "Click <strong>{0}</strong> to check the state of these objects on the server.",
     173                potentiallyDeleted.size(),
     174                options[0].text) + "<br>"
     175                + tr("Click <strong>{0}</strong> to ignore." + "</html>", options[1].text);
    175176
    176177        int ret = HelpAwareOptionPane.showOptionDialog(
    177178                Main.parent,
  • src/org/openstreetmap/josm/command/DeleteCommand.java

    diff --git a/src/org/openstreetmap/josm/command/DeleteCommand.java b/src/org/openstreetmap/josm/command/DeleteCommand.java
    index e6751cc..b1fc08d 100644
    a b public class DeleteCommand extends Command {  
    473473    }
    474474
    475475    private static boolean confirmRelationDeletion(Collection<Relation> relations) {
    476         String relationString = "<ul>";
    477         for(Relation r:relations) {
    478             relationString += "<li>"+DefaultNameFormatter.getInstance().format(r) + "</li>";
    479         }
    480         relationString += "</ul>";
    481        
    482476        JPanel msg = new JPanel(new GridBagLayout());
    483477        msg.add(new JLabel("<html>" + trn(
    484478                "You are about to delete {0} relation: {1}"
    public class DeleteCommand extends Command {  
    491485                + "This step is rarely necessary and cannot be undone easily after being uploaded to the server."
    492486                + "<br/>"
    493487                + "Do you really want to delete?",
    494                 relations.size(), relations.size(), relationString) + "</html>"));
     488                relations.size(), relations.size(), DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relations))
     489                + "</html>"));
    495490        boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    496491                "delete_relations",
    497492                Main.parent,
  • src/org/openstreetmap/josm/data/osm/DataIntegrityProblemException.java

    diff --git a/src/org/openstreetmap/josm/data/osm/DataIntegrityProblemException.java b/src/org/openstreetmap/josm/data/osm/DataIntegrityProblemException.java
    index 12ee0d3..071d8be 100644
    a b package org.openstreetmap.josm.data.osm;  
    33
    44public class DataIntegrityProblemException extends RuntimeException {
    55
     6    private String htmlMessage;
     7
    68    public DataIntegrityProblemException(String message) {
    79        super(message);
    810    }
    911
     12    public DataIntegrityProblemException(String message, String htmlMessage) {
     13        super(message);
     14        this.htmlMessage = htmlMessage;
     15    }
     16
     17    public String getHtmlMessage() {
     18        return htmlMessage;
     19    }
    1020}
  • src/org/openstreetmap/josm/data/osm/Way.java

    diff --git a/src/org/openstreetmap/josm/data/osm/Way.java b/src/org/openstreetmap/josm/data/osm/Way.java
    index 5a5e847..4826657 100644
    a b import org.openstreetmap.josm.Main;  
    1313import org.openstreetmap.josm.data.coor.LatLon;
    1414import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    1515import org.openstreetmap.josm.data.osm.visitor.Visitor;
     16import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1617import org.openstreetmap.josm.tools.CopyList;
    1718import org.openstreetmap.josm.tools.Pair;
    1819
    public final class Way extends OsmPrimitive implements IWay {  
    507508            Node[] nodes = this.nodes;
    508509            for (Node n: nodes) {
    509510                if (n.getDataSet() != dataSet)
    510                     throw new DataIntegrityProblemException("Nodes in way must be in the same dataset");
     511                    throw new DataIntegrityProblemException("Nodes in way must be in the same dataset",
     512                            tr("Nodes in way must be in the same dataset"));
    511513                if (n.isDeleted())
    512                     throw new DataIntegrityProblemException("Deleted node referenced: " + toString());
     514                    throw new DataIntegrityProblemException("Deleted node referenced: " + toString(),
     515                            "<html>" + tr("Deleted node referenced by {0}", DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(this)) + "</html>");
    513516            }
    514517            if (Main.pref.getBoolean("debug.checkNullCoor", true)) {
    515518                for (Node n: nodes) {
    516519                    if (!n.isIncomplete() && (n.getCoor() == null || n.getEastNorth() == null))
    517                         throw new DataIntegrityProblemException("Complete node with null coordinates: " + toString() + n.get3892DebugInfo());
     520                        throw new DataIntegrityProblemException("Complete node with null coordinates: " + toString() + n.get3892DebugInfo(),
     521                                "<html>" + tr("Complete node {0} with null coordinates in way {1}",
     522                                DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(n),
     523                                DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(this)) + "</html>");
    518524                }
    519525            }
    520526        }
  • src/org/openstreetmap/josm/gui/DefaultNameFormatter.java

    diff --git a/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java b/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
    index 142f3d4..0b06aa0 100644
    a b import static org.openstreetmap.josm.tools.I18n.trn;  
    88
    99import java.util.ArrayList;
    1010import java.util.Arrays;
     11import java.util.Collection;
    1112import java.util.Collections;
    1213import java.util.Comparator;
    1314import java.util.HashSet;
    import org.openstreetmap.josm.data.osm.IPrimitive;  
    2223import org.openstreetmap.josm.data.osm.IRelation;
    2324import org.openstreetmap.josm.data.osm.NameFormatter;
    2425import org.openstreetmap.josm.data.osm.Node;
     26import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2527import org.openstreetmap.josm.data.osm.OsmUtils;
    2628import org.openstreetmap.josm.data.osm.Relation;
    2729import org.openstreetmap.josm.data.osm.Way;
    public class DefaultNameFormatter implements NameFormatter, HistoryNameFormatter  
    707709        sb.append("</html>");
    708710        return sb.toString();
    709711    }
     712
     713    public String formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives) {
     714        StringBuilder sb = new StringBuilder(1024);
     715        sb.append("<ul>");
     716        for (OsmPrimitive i : primitives) {
     717            sb.append("<li>").append(i.getDisplayName(this)).append("</li>");
     718        }
     719        sb.append("</ul>");
     720        return sb.toString();
     721    }
     722
     723    public String formatAsHtmlUnorderedList(OsmPrimitive... primitives) {
     724        return formatAsHtmlUnorderedList(Arrays.asList(primitives));
     725    }
    710726}
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    diff --git a/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java b/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
    index 2b06a02..83b3d80 100644
    a b public class OsmDataLayer extends Layer implements Listener, SelectionChangedLis  
    328328        } catch (DataIntegrityProblemException e) {
    329329            JOptionPane.showMessageDialog(
    330330                    Main.parent,
    331                     e.getMessage(),
     331                    e.getHtmlMessage() != null ? e.getHtmlMessage() : e.getMessage(),
    332332                    tr("Error"),
    333333                    JOptionPane.ERROR_MESSAGE
    334334            );