Changeset 6524 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2013-12-24T21:12:40+01:00 (10 years ago)
Author:
Don-vip
Message:

global use of Utils.joinAsHtmlUnorderedList()

Location:
trunk/src/org/openstreetmap/josm
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r6380 r6524  
    88import java.net.URL;
    99import java.net.URLEncoder;
     10import java.util.ArrayList;
    1011import java.util.Collection;
    1112import java.util.concurrent.Future;
     
    2930import org.openstreetmap.josm.io.OsmTransferCanceledException;
    3031import org.openstreetmap.josm.io.OsmTransferException;
     32import org.openstreetmap.josm.tools.Utils;
    3133import org.xml.sax.SAXException;
    3234
     
    322324            if (urlString.matches(PATTERN_OSM_API_URL)) {
    323325                // TODO: proper i18n after stabilization
    324                 String message = "<ul><li>"+tr("OSM Server URL:") + " " + url.getHost() + "</li><li>" +
    325                         tr("Command")+": "+url.getPath()+"</li>";
     326                Collection<String> items = new ArrayList<String>();
     327                items.add(tr("OSM Server URL:") + " " + url.getHost());
     328                items.add(tr("Command")+": "+url.getPath());
    326329                if (url.getQuery() != null) {
    327                     message += "<li>" + tr("Request details: {0}", url.getQuery().replaceAll(",\\s*", ", ")) + "</li>";
    328                 }
    329                 message += "</ul>";
    330                 return message;
     330                    items.add(tr("Request details: {0}", url.getQuery().replaceAll(",\\s*", ", ")));
     331                }
     332                return Utils.joinAsHtmlUnorderedList(items);
    331333            }
    332334            // TODO: other APIs
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r6336 r6524  
    3434import org.openstreetmap.josm.tools.ExceptionUtil;
    3535import org.openstreetmap.josm.tools.ImageProvider;
     36import org.openstreetmap.josm.tools.Utils;
    3637
    3738/**
     
    257258            }
    258259            if (!errors.isEmpty()) {
    259                 final StringBuilder sb = new StringBuilder();
     260                final Collection<String> items = new ArrayList<String>();
    260261                for (Object error : errors) {
    261262                    if (error instanceof String) {
    262                         sb.append("<li>").append(error).append("</li>").append("<br>");
     263                        items.add((String) error);
    263264                    } else if (error instanceof Exception) {
    264                         sb.append("<li>").append(ExceptionUtil.explainException((Exception) error)).append("</li>")
    265                         .append("<br>");
     265                        items.add(ExceptionUtil.explainException((Exception) error));
    266266                    }
    267267                }
    268                 sb.insert(0, "<ul>");
    269                 sb.append("</ul>");
    270268
    271269                GuiHelper.runInEDT(new Runnable() {
     
    273271                    public void run() {
    274272                        JOptionPane.showMessageDialog(Main.parent, "<html>"
    275                                 + tr("The following errors occurred during mass download: {0}", sb.toString()) + "</html>",
     273                                + tr("The following errors occurred during mass download: {0}",
     274                                        Utils.joinAsHtmlUnorderedList(items)) + "</html>",
    276275                                tr("Errors during download"), JOptionPane.ERROR_MESSAGE);
    277276                    }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java

    r6084 r6524  
    55
    66import java.util.ArrayList;
     7import java.util.Collection;
    78import java.util.LinkedHashSet;
    89import java.util.List;
     
    1516import org.openstreetmap.josm.gui.ExceptionDialogUtil;
    1617import org.openstreetmap.josm.tools.ExceptionUtil;
     18import org.openstreetmap.josm.tools.Utils;
    1719
    1820public class PostDownloadHandler implements Runnable {
     
    104106        //
    105107        if (!errors.isEmpty()) {
    106             final StringBuffer sb = new StringBuffer();
     108            final Collection<String> items = new ArrayList<String>();
    107109            for (Object error:errors) {
    108110                if (error instanceof String) {
    109                     sb.append("<li>").append(error).append("</li>").append("<br>");
     111                    items.add((String) error);
    110112                } else if (error instanceof Exception) {
    111                     sb.append("<li>").append(ExceptionUtil.explainException((Exception)error)).append("</li>").append("<br>");
     113                    items.add(ExceptionUtil.explainException((Exception)error));
    112114                }
    113115            }
    114             sb.insert(0, "<html><ul>");
    115             sb.append("</ul></html>");
    116116
    117117            SwingUtilities.invokeLater(new Runnable() {
     
    120120                    JOptionPane.showMessageDialog(
    121121                            Main.parent,
    122                             sb.toString(),
     122                            "<html>"+Utils.joinAsHtmlUnorderedList(items)+"</html>",
    123123                            tr("Errors during download"),
    124124                            JOptionPane.ERROR_MESSAGE);
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r6429 r6524  
    189189                label.setToolTipText("<html>"
    190190                        + description
    191                         + (examples.length > 0 ? ("<ul><li>" + Utils.join("</li><li>", Arrays.asList(examples)) + "</li></ul>") : "")
     191                        + (examples.length > 0 ? Utils.joinAsHtmlUnorderedList(Arrays.asList(examples)) : "")
    192192                        + "</html>");
    193193            }
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r6380 r6524  
    1717import java.util.List;
    1818import java.util.Map;
     19import java.util.Map.Entry;
    1920import java.util.Set;
    20 import java.util.Map.Entry;
    2121
    2222import javax.swing.Icon;
     
    272272     *    <li>it is untagged (see {@link Node#isTagged()}</li>
    273273     *    <li>it is not referred to by other non-deleted primitives outside of  <code>primitivesToDelete</code></li>
    274      * <ul>
     274     * </ul>
    275275     * @param layer  the layer in whose context primitives are deleted
    276276     * @param primitivesToDelete  the primitives to delete
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayNoTagCorrector.java

    r6362 r6524  
    1515import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1616import org.openstreetmap.josm.gui.DefaultNameFormatter;
     17import org.openstreetmap.josm.tools.Utils;
    1718
    1819/**
    1920 * A ReverseWayNoTagCorrector warns about ways that should not be reversed
    20  * because their semantic meaning cannot be preserved in that case. 
     21 * because their semantic meaning cannot be preserved in that case.
    2122 * E.g. natural=coastline, natural=cliff, barrier=retaining_wall cannot be changed.
    2223 * @see ReverseWayTagCorrector for handling of tags that can be modified (oneway=yes, etc.)
     
    3031   
    3132    /**
    32      * Tags that imply a semantic meaning from the way direction and cannot be changed. 
     33     * Tags that imply a semantic meaning from the way direction and cannot be changed.
    3334     */
    3435    public static final TagCollection directionalTags = new TagCollection(Arrays.asList(new Tag[]{
     
    4647   
    4748    /**
    48      * Replies the tags that imply a semantic meaning from <code>way</code> direction and cannot be changed. 
     49     * Replies the tags that imply a semantic meaning from <code>way</code> direction and cannot be changed.
    4950     * @param way The way to look for
    5051     * @return tags that imply a semantic meaning from <code>way</code> direction and cannot be changed
     
    6869            return tags.iterator().next().toString();
    6970        } else if (tags.size() > 1) {
    70             StringBuilder s = new StringBuilder("<ul>");
    71             for (Tag t : tags) {
    72                 s.append("<li>").append(t).append("</li>");
    73             }
    74             s.append("</ul>");
    75             return s.toString();
     71            return Utils.joinAsHtmlUnorderedList(tags);
    7672        } else {
    7773            return "";
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r6523 r6524  
    480480        }
    481481
    482         private static String getHtmlList(Collection<String> set) {
    483             StringBuilder sb = new StringBuilder("<ul>");
    484             for (String s : set) {
    485                 sb.append("<li>"+s+"</li>");
    486             }
    487             return sb.append("</ul>").toString();
    488         }
    489 
    490482        private void handleProxyErrors() {
    491483            if (proxySelector.hasErrors()) {
     
    497489                ed.setIcon(JOptionPane.WARNING_MESSAGE);
    498490                ed.setContent(tr("JOSM tried to access the following resources:")+
    499                         "<br>"+getHtmlList(proxySelector.getErrorResources())+
     491                        "<br>"+Utils.joinAsHtmlUnorderedList(proxySelector.getErrorResources())+
    500492                        tr("but <b>failed</b> to do so, because of the following proxy errors:")+
    501                         "<br>"+getHtmlList(proxySelector.getErrorMessages())+
     493                        "<br>"+Utils.joinAsHtmlUnorderedList(proxySelector.getErrorMessages())+
    502494                        tr("Would you like to change your proxy settings now ?")
    503495                        );
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java

    r6317 r6524  
    3636import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel;
    3737import org.openstreetmap.josm.tools.CheckParameterUtil;
     38import org.openstreetmap.josm.tools.Utils;
    3839
    3940/**
     
    358359        sb.append("<html>");
    359360        sb.append(tr("The following objects could not be copied to the target object<br>because they are deleted in the target dataset:"));
    360         sb.append("<ul>");
    361         for (String item: items) {
    362             sb.append("<li>").append(item).append("</li>");
    363         }
    364         sb.append("</ul>");
     361        sb.append(Utils.joinAsHtmlUnorderedList(items));
    365362        sb.append("</html>");
    366363        HelpAwareOptionPane.showOptionDialog(
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverTable.java

    r6084 r6524  
    4747     * pressing TAB or ENTER. The action alters the standard navigation path from cell to cell: <ul>
    4848     * <li>it jumps over cells in the first column</li> <li>it automatically add a new empty row
    49      * when the user leaves the last cell in the table</li> <ul>
     49     * when the user leaves the last cell in the table</li></ul>
    5050     *
    5151     *
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverTable.java

    r6084 r6524  
    4949     * pressing TAB or ENTER. The action alters the standard navigation path from cell to cell: <ul>
    5050     * <li>it jumps over cells in the first column</li> <li>it automatically add a new empty row
    51      * when the user leaves the last cell in the table</li> <ul>
     51     * when the user leaves the last cell in the table</li></ul>
    5252     *
    5353     *
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r6316 r6524  
    156156     * pressing TAB or ENTER. The action alters the standard navigation path from cell to cell: <ul>
    157157     * <li>it jumps over cells in the first column</li> <li>it automatically add a new empty row
    158      * when the user leaves the last cell in the table</li> <ul>
     158     * when the user leaves the last cell in the table</li></ul>
    159159     *
    160160     *
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r6362 r6524  
    5656 *   <li>a dedicated version in this {@link History} called the {@link PointInTimeType#REFERENCE_POINT_IN_TIME}</li>
    5757 *   <li>another version in this {@link History} called the {@link PointInTimeType#CURRENT_POINT_IN_TIME}</li>
    58  * <ul>
     58 * </ul>
    5959 * {@link HistoryBrowser} always compares the {@link PointInTimeType#REFERENCE_POINT_IN_TIME} with the
    6060 * {@link PointInTimeType#CURRENT_POINT_IN_TIME}.
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r6456 r6524  
    6363import org.openstreetmap.josm.tools.ExifReader;
    6464import org.openstreetmap.josm.tools.ImageProvider;
     65import org.openstreetmap.josm.tools.Utils;
    6566
    6667import com.drew.imaging.jpeg.JpegMetadataReader;
     
    221222                sb.append(errorMessages.iterator().next());
    222223            } else {
    223                 sb.append("<ul>");
    224                 for (String msg: errorMessages) {
    225                     sb.append("<li>").append(msg).append("</li>");
    226                 }
    227                 sb.append("/ul>");
     224                sb.append(Utils.joinAsHtmlUnorderedList(errorMessages));
    228225            }
    229226            sb.append("</html>");
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java

    r6142 r6524  
    3030import org.openstreetmap.josm.plugins.PluginInformation;
    3131import org.openstreetmap.josm.tools.OpenBrowser;
     32import org.openstreetmap.josm.tools.Utils;
    3233
    3334public class PluginListPanel extends VerticallyScrollablePanel{
     
    170171                otherPlugins.size()
    171172        ));
    172         sb.append("<ul>");
    173         for (String p: otherPlugins) {
    174             sb.append("<li>").append(p).append("</li>");
    175         }
    176         sb.append("</ul>").append("</html>");
     173        sb.append(Utils.joinAsHtmlUnorderedList(otherPlugins));
     174        sb.append("</html>");
    177175        JOptionPane.showMessageDialog(
    178176                parent,
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java

    r6321 r6524  
    22package org.openstreetmap.josm.gui.tagging;
    33
     4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    4546import org.openstreetmap.josm.data.osm.Tag;
    4647import org.openstreetmap.josm.gui.dialogs.relation.RunnableAction;
    47 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    4848import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
    4949import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
     
    103103     *   <li>it automatically add a new empty row when the user leaves the
    104104     *   last cell in the table</li>
    105      * <ul>
     105     * </ul>
    106106     *
    107107     */
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r6362 r6524  
    6464import org.openstreetmap.josm.tools.I18n;
    6565import org.openstreetmap.josm.tools.ImageProvider;
     66import org.openstreetmap.josm.tools.Utils;
    6667
    6768/**
     
    411412                missingRequiredPlugin.size()
    412413        ));
    413         sb.append("<ul>");
    414         for (String p: missingRequiredPlugin) {
    415             sb.append("<li>").append(p).append("</li>");
    416         }
    417         sb.append("</ul>").append("</html>");
     414        sb.append(Utils.joinAsHtmlUnorderedList(missingRequiredPlugin));
     415        sb.append("</html>");
    418416        JOptionPane.showMessageDialog(
    419417                parent,
     
    710708                "JOSM could not find information about the following plugins:",
    711709                plugins.size()));
    712         sb.append("<ul>");
    713         for (String plugin: plugins) {
    714             sb.append("<li>").append(plugin).append("</li>");
    715         }
    716         sb.append("</ul>");
     710        sb.append(Utils.joinAsHtmlUnorderedList(plugins));
    717711        sb.append(trn("The plugin is not going to be loaded.",
    718712                "The plugins are not going to be loaded.",
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6421 r6524  
    201201    }
    202202
    203     public static String joinAsHtmlUnorderedList(Collection<?> values) {
     203    /**
     204     * Converts the given iterable collection as an unordered HTML list.
     205     * @param values The iterable collection
     206     * @return An unordered HTML list
     207     */
     208    public static String joinAsHtmlUnorderedList(Iterable<?> values) {
    204209        StringBuilder sb = new StringBuilder(1024);
    205210        sb.append("<ul>");
Note: See TracChangeset for help on using the changeset viewer.