Commit 4c58d3bb authored by Florian Schäfer's avatar Florian Schäfer

Fix some Checkstyle issues, update JOSM version to 13860

parent 6dfdb928
......@@ -3,7 +3,7 @@ plugin.main.version = 13597
# The JOSM version this plugin is currently compiled against
# Please make sure this version is available at https://josm.openstreetmap.de/download
# The special values "latest" and "tested" are also possible here, but not recommended.
plugin.compile.version = 13710
plugin.compile.version = 13860
plugin.canloadatruntime = true
plugin.author = simon04
plugin.class = org.wikipedia.WikipediaPlugin
......
......@@ -18,7 +18,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collector;
......@@ -27,7 +26,6 @@ import java.util.stream.Stream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
......@@ -37,10 +35,6 @@ import org.openstreetmap.josm.tools.Pair;
import org.openstreetmap.josm.tools.Utils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.wikipedia.api.wikidata_action.ApiQueryClient;
import org.wikipedia.api.wikidata_action.WikidataActionApiUrl;
import org.wikipedia.api.wikidata_action.json.CheckEntityExistsResult;
import org.wikipedia.api.wikidata_action.json.SerializationSchema;
import org.wikipedia.data.WikidataEntry;
import org.wikipedia.data.WikipediaEntry;
import org.wikipedia.tools.ListUtil;
......@@ -160,7 +154,7 @@ public final class WikipediaApp {
+ "&depth=" + depth
+ "&cat=" + Utils.encodeUrl(category);
try (final BufferedReader reader = connect(url).getContentReader()) {
try (BufferedReader reader = connect(url).getContentReader()) {
return reader.lines()
.map(line -> new WikipediaEntry(wikipediaLang, line.trim().replace("_", " ")))
.collect(Collectors.toList());
......@@ -188,7 +182,7 @@ public final class WikipediaApp {
try {
final String articles = entries.stream().map(i -> i.article).collect(Collectors.joining(","));
final String requestBody = "articles=" + Utils.encodeUrl(articles);
try (final BufferedReader reader = HttpClient.create(new URL(url), "POST").setReasonForRequest("Wikipedia")
try (BufferedReader reader = HttpClient.create(new URL(url), "POST").setReasonForRequest("Wikipedia")
.setHeader("Content-Type", "application/x-www-form-urlencoded")
.setRequestBody(requestBody.getBytes(StandardCharsets.UTF_8))
.connect().getContentReader()) {
......@@ -311,7 +305,7 @@ public final class WikipediaApp {
"&format=xml" +
"&titles=" + articles.stream().map(Utils::encodeUrl).collect(Collectors.joining("|"));
final Map<String, String> r = new TreeMap<>();
try (final InputStream in = connect(url).getContent()) {
try (InputStream in = connect(url).getContent()) {
final Document xml = newDocumentBuilder().parse(in);
X_PATH.evaluateNodes("//entity", xml).forEach(node -> {
final String wikidata = X_PATH.evaluateString("./@id", node);
......@@ -340,7 +334,7 @@ public final class WikipediaApp {
"&redirects" +
"&format=xml" +
"&titles=" + articles.stream().map(Utils::encodeUrl).collect(Collectors.joining("|"));
try (final InputStream in = connect(url).getContent()) {
try (InputStream in = connect(url).getContent()) {
final Document xml = newDocumentBuilder().parse(in);
// Add both redirects and normalization results to the same map
......@@ -377,7 +371,7 @@ public final class WikipediaApp {
+ "&pslimit=50"
+ "&pssearch=" + Utils.encodeUrl(prefix);
// parse XML document
try (final InputStream in = connect(url).getContent()) {
try (InputStream in = connect(url).getContent()) {
final Document doc = newDocumentBuilder().parse(in);
return X_PATH.evaluateNodes("//ps/@title", doc).stream()
.map(Node::getNodeValue)
......@@ -398,7 +392,7 @@ public final class WikipediaApp {
}
}
static List<WikidataEntry> getLabelForWikidata(List<? extends WikipediaEntry> entries, Locale locale, String ... preferredLanguage) {
static List<WikidataEntry> getLabelForWikidata(List<? extends WikipediaEntry> entries, Locale locale, String... preferredLanguage) {
final Collection<String> languages = new ArrayList<>();
if (locale != null) {
languages.add(getMediawikiLocale(locale));
......@@ -456,7 +450,7 @@ public final class WikipediaApp {
"&titles=" + Utils.encodeUrl(article) +
"&lllimit=500" +
"&format=xml";
try (final InputStream in = connect(url).getContent()) {
try (InputStream in = connect(url).getContent()) {
final Document xml = newDocumentBuilder().parse(in);
return X_PATH.evaluateNodes("//ll", xml).stream()
.map(node -> {
......@@ -477,7 +471,7 @@ public final class WikipediaApp {
"&prop=coordinates" +
"&titles=" + Utils.encodeUrl(article) +
"&format=xml";
try (final InputStream in = connect(url).getContent()) {
try (InputStream in = connect(url).getContent()) {
final Document xml = newDocumentBuilder().parse(in);
final Node node = X_PATH.evaluateNode("//coordinates/co", xml);
if (node == null) {
......@@ -511,8 +505,8 @@ public final class WikipediaApp {
try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch (ParserConfigurationException e) {
Logging.warn("Cannot create DocumentBuilder");
Logging.warn(e);
Logging.warn("Cannot create DocumentBuilder");
Logging.warn(e);
throw new RuntimeException(e);
}
}
......
......@@ -3,7 +3,6 @@ package org.wikipedia;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import org.openstreetmap.josm.data.Version;
import org.openstreetmap.josm.data.validation.OsmValidator;
import org.openstreetmap.josm.gui.MainApplication;
......
......@@ -11,9 +11,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JOptionPane;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.command.ChangePropertyCommand;
import org.openstreetmap.josm.command.Command;
......
......@@ -9,7 +9,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.data.osm.DataSet;
......
......@@ -7,9 +7,7 @@ import java.awt.event.ActionEvent;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.swing.JMenuItem;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.data.Preferences;
......
......@@ -7,7 +7,6 @@ import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.openstreetmap.josm.tools.Logging;
public class ApiUrl {
......
......@@ -4,7 +4,6 @@ package org.wikipedia.api.wikidata_action;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.net.URL;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
......
......@@ -3,12 +3,11 @@ package org.wikipedia.api.wikidata_action;
import java.net.URL;
import java.util.Collection;
import org.openstreetmap.josm.tools.Utils;
import org.wikipedia.api.ApiUrl;
import org.wikipedia.tools.RegexUtil;
public class WikidataActionApiUrl {
public final class WikidataActionApiUrl {
private static final String BASE_URL = "https://www.wikidata.org/w/api.php?";
private static final String FORMAT_PARAMS = "format=json&utf8=1&formatversion=1";
......@@ -47,5 +46,4 @@ public class WikidataActionApiUrl {
"&titles=", Utils.encodeUrl(String.join("|", titles))
);
}
}
......@@ -8,7 +8,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParser;
......
......@@ -2,7 +2,6 @@
package org.wikipedia.api.wikidata_action.json;
import java.util.function.Consumer;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
......
......@@ -3,7 +3,6 @@ package org.wikipedia.data;
import java.util.Comparator;
import java.util.Optional;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.Tag;
import org.openstreetmap.josm.tools.AlphanumComparator;
......
......@@ -4,7 +4,6 @@ package org.wikipedia.data;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.Tag;
import org.openstreetmap.josm.tools.AlphanumComparator;
......
......@@ -9,7 +9,6 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.swing.JOptionPane;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
......@@ -18,7 +17,7 @@ import org.openstreetmap.josm.gui.util.GuiHelper;
import org.openstreetmap.josm.tools.AlphanumComparator;
import org.openstreetmap.josm.tools.Utils;
public class GuiUtils {
public final class GuiUtils {
private GuiUtils() {
// Private constructor to avoid instantiation
......
......@@ -25,7 +25,6 @@ import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.plaf.basic.BasicArrowButton;
import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
import org.openstreetmap.josm.data.Bounds;
......@@ -388,7 +387,9 @@ public class SophoxDownloadReader implements DownloadSource<SophoxDownloadReader
return this.downloadReferrers;
}
boolean getDownloadFull() { return this.downloadFull; }
boolean getDownloadFull() {
return this.downloadFull;
}
Consumer<Collection<Object>> getErrorReporter() {
return this.errorReporter;
......
......@@ -4,12 +4,10 @@ package org.wikipedia.gui;
import static org.openstreetmap.josm.tools.I18n.tr;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
......
......@@ -2,7 +2,6 @@
package org.wikipedia.gui;
import java.util.concurrent.Executors;
import org.openstreetmap.josm.gui.widgets.SearchTextResultListPanel;
import org.openstreetmap.josm.tools.Utils;
import org.wikipedia.tools.Debouncer;
......
......@@ -13,12 +13,10 @@ import java.util.List;
import java.util.Locale;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.data.osm.DataSet;
......
......@@ -7,7 +7,6 @@ import java.awt.Dimension;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.gui.ExtendedDialog;
import org.openstreetmap.josm.gui.util.GuiHelper;
......
......@@ -22,7 +22,6 @@ import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingWorker;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.actions.search.SearchAction;
import org.openstreetmap.josm.command.ChangePropertyCommand;
......@@ -65,6 +64,7 @@ public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerCh
new SideButton(new WikipediaSettingsAction(), false)));
updateTitle();
}
/** A string describing the context (use-case) for determining the dialog title */
String titleContext = null;
static final StringProperty wikipediaLang = new StringProperty("wikipedia.lang", LanguageInfo.getJOSMLocaleCode().substring(0, 2));
......@@ -367,7 +367,7 @@ public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerCh
final String language = getLanguageOfFirstItem();
articles.clear();
if (Main.main != null && MainApplication.getLayerManager().getEditDataSet() != null) {
MainApplication.getLayerManager().getEditDataSet().allPrimitives().stream()
MainApplication.getLayerManager().getEditDataSet().allPrimitives().stream()
.flatMap(p -> WikipediaApp.forLanguage(language).getWikipediaArticles(p))
.forEach(articles::add);
}
......
......@@ -19,12 +19,10 @@ import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonValue;
import org.openstreetmap.josm.actions.DownloadPrimitiveAction;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.DataSource;
......
......@@ -11,7 +11,6 @@ import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathFunctionResolver;
import javax.xml.xpath.XPathVariableResolver;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
......
......@@ -6,7 +6,6 @@ import java.util.List;
import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.data.validation.Test;
import org.openstreetmap.josm.gui.Notification;
......
......@@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.openstreetmap.josm.command.ChangePropertyCommand;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.Notification;
......
......@@ -10,7 +10,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.Notification;
import org.openstreetmap.josm.tools.I18n;
......
......@@ -17,7 +17,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.data.coor.LatLon;
......
......@@ -5,7 +5,6 @@ import static org.junit.Assert.assertEquals;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.Test;
public class ApiUrlTest {
......
......@@ -5,7 +5,6 @@ import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
public class WikidataActionApiUrlTest {
......
......@@ -4,7 +4,6 @@ package org.wikipedia.api.wikidata_action.json;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.Test;
public class CheckEntityExistsResultTest {
......
......@@ -9,7 +9,6 @@ import java.util.Arrays;
import java.util.List;
import javax.swing.JLabel;
import javax.swing.JTable;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.testutils.JOSMTestRules;
......
......@@ -10,7 +10,6 @@ import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.junit.Rule;
import org.junit.Test;
......
......@@ -6,7 +6,6 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.data.osm.Way;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment