Ignore:
Timestamp:
2016-07-23T23:51:22+02:00 (8 years ago)
Author:
simon04
Message:

JOSM/wikipedia: switch to Java 8

Location:
applications/editors/josm/plugins/wikipedia/src/org/wikipedia
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikidataTagCellRenderer.java

    r32691 r32704  
    7070    protected JLabel renderValues(Collection<String> ids, JTable table, JLabel component) {
    7171
    72         for (String id : ids) {
    73             if (!labelCache.containsKey(id)) {
    74                 labelCache.put(id, Main.worker.submit(new LabelLoader(id, table)));
    75             }
    76         }
     72        ids.stream()
     73                .filter(id -> !labelCache.containsKey(id))
     74                .forEach(id -> {
     75                    labelCache.put(id, Main.worker.submit(new LabelLoader(id, table)));
     76                });
    7777
    7878        final Collection<String> texts = new ArrayList<>(ids.size());
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaAddNamesAction.java

    r32687 r32704  
    1515import org.openstreetmap.josm.data.osm.DataSet;
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.preferences.StringProperty;
    1817import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
    19 import org.openstreetmap.josm.tools.LanguageInfo;
    2018
    2119public class WikipediaAddNamesAction extends JosmAction {
     
    3129        final WikipediaApp.WikipediaLangArticle wp = WikipediaApp.WikipediaLangArticle.parseTag("wikipedia", getWikipediaValue());
    3230        List<String[]> tags = new ArrayList<>();
    33         for (WikipediaApp.WikipediaLangArticle i : WikipediaApp.getInterwikiArticles(wp.lang, wp.article)) {
    34             if (useWikipediaLangArticle(i)) {
    35                 tags.add(new String[]{"name:" + i.lang, i.article});
    36             }
    37         }
     31        WikipediaApp.getInterwikiArticles(wp.lang, wp.article).stream()
     32                .filter(this::useWikipediaLangArticle)
     33                .map(i -> new String[]{"name:" + i.lang, i.article})
     34                .forEach(tags::add);
    3835        if (Main.isDebugEnabled()) {
    3936            Main.debug(tags.toString());
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java

    r32695 r32704  
    2727import javax.xml.parsers.DocumentBuilderFactory;
    2828import javax.xml.parsers.ParserConfigurationException;
    29 import javax.xml.xpath.XPathExpressionException;
    3029
    3130import org.openstreetmap.josm.Main;
     
    3332import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3433import org.openstreetmap.josm.data.osm.Tag;
     34import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    3535import org.openstreetmap.josm.tools.AlphanumComparator;
    3636import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    4242public final class WikipediaApp {
    4343
    44     public static Pattern WIKIDATA_PATTERN = Pattern.compile("Q\\d+");
     44    public static final Pattern WIKIDATA_PATTERN = Pattern.compile("Q\\d+");
    4545    private static final DocumentBuilder DOCUMENT_BUILDER = newDocumentBuilder();
    4646    private static final XPath X_PATH = XPath.getInstance();
     
    141141    static List<WikipediaEntry> getEntriesFromClipboard(final String wikipediaLang) {
    142142        return Pattern.compile("[\\n\\r]+")
    143                 .splitAsStream(Utils.getClipboardContent())
     143                .splitAsStream(ClipboardUtils.getClipboardStringContent())
    144144                .map(x -> new WikipediaEntry(wikipediaLang, x))
    145145                .collect(Collectors.toList());
     
    290290    }
    291291
    292     private static String getFirstField(Collection<String> languages, String field, Node entity) throws XPathExpressionException {
     292    private static String getFirstField(Collection<String> languages, String field, Node entity) {
    293293        return languages.stream()
    294294                .map(language -> X_PATH.evaluateString(language != null
     
    302302    static Collection<WikipediaLangArticle> getInterwikiArticles(String wikipediaLang, String article) {
    303303        try {
    304             Collection<WikipediaLangArticle> r = new ArrayList<>();
    305304            final String url = getSiteUrl(wikipediaLang) + "/w/api.php" +
    306305                    "?action=query" +
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaCategorySearchDialog.java

    r32687 r32704  
    55
    66import java.awt.Dimension;
    7 import java.awt.event.ActionEvent;
    8 import java.awt.event.ActionListener;
    97import java.util.Collections;
    108import java.util.List;
     
    5149    }
    5250
    53     @Override
    54     protected void buttonAction(int buttonIndex, ActionEvent evt) {
    55         super.buttonAction(buttonIndex, evt);
    56     }
    57 
    5851    private static class Selector extends WikiSearchTextResultListPanel<String> {
    5952
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaCopyTemplate.java

    r32691 r32704  
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1919import org.openstreetmap.josm.gui.MainMenu;
    20 import org.openstreetmap.josm.tools.Utils;
     20import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    2121
    2222public class WikipediaCopyTemplate {
     
    8383                return;
    8484            }
    85             Utils.copyToClipboard(pattern
     85            ClipboardUtils.copyString(pattern
    8686                    .replace("{lat}", Double.toString(node.getCoor().lat()))
    8787                    .replace("{lon}", Double.toString(node.getCoor().lon())));
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaToggleDialog.java

    r32687 r32704  
    186186        protected void process(List<WikipediaEntry> chunks) {
    187187            model.clear();
    188             for (WikipediaEntry i : chunks) {
    189                 model.addElement(i);
    190             }
     188            chunks.forEach(model::addElement);
    191189            updateTitle();
    192190            updateWikipediaArticles();
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/XPath.java

    r32695 r32704  
    1919public class XPath implements javax.xml.xpath.XPath {
    2020    private final javax.xml.xpath.XPath xPath;
    21     private static XPath INSTANCE = new XPath(XPathFactory.newInstance().newXPath());
     21    private static final XPath INSTANCE = new XPath(XPathFactory.newInstance().newXPath());
    2222
    2323    private XPath(javax.xml.xpath.XPath xPath) {
Note: See TracChangeset for help on using the changeset viewer.