Commit b8a48678 authored by Florian Schäfer's avatar Florian Schäfer

Fix some issues reported by ErrorProne

parent b19e79ae
......@@ -189,7 +189,7 @@ public final class WikipediaApp {
.connect().getContentReader()) {
reader.lines().forEach(line -> {
//[article]\t[0|1]
final String[] x = line.split("\t");
final String[] x = line.split("\t", -1);
if (x.length == 2) {
status.put(x[0], "1".equals(x[1]));
} else {
......
......@@ -13,7 +13,11 @@ import org.openstreetmap.josm.plugins.PluginInformation;
import org.wikipedia.actions.FetchWikidataAction;
import org.wikipedia.actions.WikipediaAddNamesAction;
import org.wikipedia.actions.WikipediaCopyTemplate;
import org.wikipedia.gui.*;
import org.wikipedia.gui.SophoxDownloadReader;
import org.wikipedia.gui.SophoxServerPreference;
import org.wikipedia.gui.WikidataItemSearchDialog;
import org.wikipedia.gui.WikidataTagCellRenderer;
import org.wikipedia.gui.WikipediaToggleDialog;
public class WikipediaPlugin extends Plugin {
......
......@@ -20,6 +20,10 @@ import static org.openstreetmap.josm.tools.I18n.trn;
public class GuiUtils {
private GuiUtils() {
// Private constructor to avoid instantiation
}
public static final String PREF_OVERWRITE = "wikipedia.overwrite-tag";
public static boolean confirmOverwrite(final String key, final String newValue, final Collection<OsmPrimitive> primitives) {
......
......@@ -3,7 +3,10 @@ package org.wikipedia.gui;
import static org.openstreetmap.josm.tools.I18n.tr;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
......@@ -11,7 +14,15 @@ import java.util.Collection;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import javax.swing.*;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.plaf.basic.BasicArrowButton;
......
......@@ -10,7 +10,6 @@ import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
......
......@@ -7,6 +7,8 @@ import static org.openstreetmap.josm.tools.I18n.tr;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
......@@ -118,11 +120,16 @@ public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerCh
private void updateTitle() {
final String lang = getLanguageOfFirstItem();
final String host = WikipediaApp.forLanguage(lang).getSiteUrl().split("/+")[1];
if (titleContext == null) {
setTitle(host);
} else {
setTitle(tr("{0}: {1}", host, titleContext));
try {
final URL url = new URL(WikipediaApp.forLanguage(lang).getSiteUrl());
if (titleContext == null) {
setTitle(url.getHost());
} else {
setTitle(url.getHost() + ": " + titleContext);
}
} catch (MalformedURLException e) {
Logging.warn("The site URL {0} is malformed!", WikipediaApp.forLanguage(lang).getSiteUrl());
setTitle(tr("{0} (malformed site URL)"));
}
}
......
// License: GPL. For details, see LICENSE file.
package org.wikipedia.io;
import org.openstreetmap.josm.actions.DownloadPrimitiveAction;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.DataSource;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.*;
import org.openstreetmap.josm.data.preferences.ListProperty;
import org.openstreetmap.josm.data.preferences.StringProperty;
import org.openstreetmap.josm.gui.progress.ProgressMonitor;
import org.openstreetmap.josm.io.*;
import org.openstreetmap.josm.io.NameFinder.SearchResult;
import org.openstreetmap.josm.tools.HttpClient;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.Utils;
import static org.openstreetmap.josm.tools.I18n.tr;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonValue;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
......@@ -27,12 +11,41 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.ZoneOffset;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.openstreetmap.josm.tools.I18n.tr;
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;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.BBox;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
import org.openstreetmap.josm.data.osm.PrimitiveId;
import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
import org.openstreetmap.josm.data.preferences.ListProperty;
import org.openstreetmap.josm.data.preferences.StringProperty;
import org.openstreetmap.josm.gui.progress.ProgressMonitor;
import org.openstreetmap.josm.io.BoundingBoxDownloader;
import org.openstreetmap.josm.io.IllegalDataException;
import org.openstreetmap.josm.io.NameFinder;
import org.openstreetmap.josm.io.NameFinder.SearchResult;
import org.openstreetmap.josm.io.OsmApiException;
import org.openstreetmap.josm.io.OsmTransferException;
import org.openstreetmap.josm.tools.HttpClient;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.Utils;
/**
* Read content from an Sophox server.
......
// License: GPL. For details, see LICENSE file.
package org.wikipedia.data;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class WikipediaEntryTest {
......
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