Commit aa0f2e12 authored by Vincent Privat's avatar Vincent Privat Committed by Florian Schäfer

fix warnings, update to latest JOSM core

parent 9cacc8d5
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="test/unit"/>
<classpathentry kind="src" output="bintest" path="test/unit">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.16.1.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.7.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.9.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.9.5.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.9.6.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.9.6.jar"/>
<classpathentry kind="lib" path="lib/objenesis-2.6.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.25.jar"/>
<classpathentry kind="lib" path="lib/wdtk-datamodel-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/wdtk-dumpfiles-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/wdtk-storage-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/wdtk-util-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/wdtk-wikibaseapi-0.9.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
# The minimum JOSM version this plugin is compatible with (can be any numeric version)
plugin.main.version = 13927
plugin.main.version = 14140
# 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 = 14073
plugin.compile.version = 14178
plugin.canloadatruntime = true
plugin.author = floscher <incoming+JOSM/wikipedia@incoming.gitlab.com>, simon04
plugin.class = org.wikipedia.WikipediaPlugin
......
......@@ -236,7 +236,7 @@ public final class WikipediaApp {
public Map<String, String> getWikidataForArticles(Collection<String> articles) {
final Map<String, String> result = new HashMap<>();
// maximum of 50 titles
ListUtil.processInBatches(new ArrayList<String>(articles), 50, batch -> {
ListUtil.processInBatches(new ArrayList<>(articles), 50, batch -> {
result.putAll(resolveWikidataItems(batch));
});
return result;
......
......@@ -16,6 +16,7 @@ import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.command.ChangePropertyCommand;
import org.openstreetmap.josm.command.Command;
import org.openstreetmap.josm.command.SequenceCommand;
import org.openstreetmap.josm.data.UndoRedoHandler;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
......@@ -97,7 +98,7 @@ public class FetchWikidataAction extends JosmAction {
@Override
protected void finish() {
if (!canceled && !commands.isEmpty()) {
MainApplication.undoRedo.add(commands.size() == 1 ? commands.get(0) : new SequenceCommand(tr("Add Wikidata"), commands));
UndoRedoHandler.getInstance().add(commands.size() == 1 ? commands.get(0) : new SequenceCommand(tr("Add Wikidata"), commands));
}
if (!canceled && !notFound.isEmpty()) {
new Notification(tr("No Wikidata ID found for: {0}", Utils.joinAsHtmlUnorderedList(notFound)))
......
......@@ -9,12 +9,12 @@ 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;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.Notification;
import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.tools.I18n;
import org.openstreetmap.josm.tools.ImageProvider;
import org.openstreetmap.josm.tools.Logging;
......@@ -51,9 +51,9 @@ public class WikipediaAddNamesAction extends JosmAction {
}
private boolean useWikipediaLangArticle(WikipediaEntry i) {
return (!Main.pref.getBoolean("wikipedia.filter-iso-languages", true)
return (!Config.getPref().getBoolean("wikipedia.filter-iso-languages", true)
|| Arrays.asList(Locale.getISOLanguages()).contains(i.lang))
&& (!Main.pref.getBoolean("wikipedia.filter-same-names", true)
&& (!Config.getPref().getBoolean("wikipedia.filter-same-names", true)
|| !i.article.equals(getLayerManager().getEditDataSet().getSelected().iterator().next().get("name")));
}
......
......@@ -8,7 +8,6 @@ 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;
import org.openstreetmap.josm.data.StructUtils;
......@@ -19,6 +18,7 @@ import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.MainMenu;
import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
import org.openstreetmap.josm.spi.preferences.Config;
public class WikipediaCopyTemplate {
......@@ -30,7 +30,7 @@ public class WikipediaCopyTemplate {
);
private static final List<CoordCopyTemplateEntry> TEMPLATE_ENTRIES =
StructUtils.getListOfStructs(Main.pref, "wikipedia.copytemplates", DEFAULT_TEMPLATES, CoordCopyTemplateEntry.class);
StructUtils.getListOfStructs(Config.getPref(), "wikipedia.copytemplates", DEFAULT_TEMPLATES, CoordCopyTemplateEntry.class);
public WikipediaCopyTemplate() {
JosmAction previous = MainApplication.getMenu().copyCoordinates;
......
......@@ -32,6 +32,8 @@ public final class WikidataActionApiQuery<T> extends ApiQuery<T> {
/**
* Convenience constructor
* @param queryString the query string containing the arguments of this query
* @param schema the {@link SerializationSchema} that defines how deserialization of the response is handled
* @see #WikidataActionApiQuery(String, SerializationSchema, long, Function)
*/
private WikidataActionApiQuery(final String queryString, final SerializationSchema<T> schema) {
......@@ -40,6 +42,9 @@ public final class WikidataActionApiQuery<T> extends ApiQuery<T> {
/**
* Convenience constructor
* @param queryString the query string containing the arguments of this query
* @param schema the {@link SerializationSchema} that defines how deserialization of the response is handled
* @param converter a function that maps the
* @see #WikidataActionApiQuery(String, SerializationSchema, long, Function)
*/
private <S> WikidataActionApiQuery(final String queryString, final SerializationSchema<S> schema, final Function<S, T> converter) {
......
......@@ -46,7 +46,7 @@ public class WikipediaActionApiQuery<T> extends ApiQuery<T> {
public static WikipediaActionApiQuery<QueryResult> query(final IWikipediaSite site, final Collection<String> titles) {
Objects.requireNonNull(site);
Objects.requireNonNull(titles);
return new WikipediaActionApiQuery<QueryResult>(
return new WikipediaActionApiQuery<>(
site,
FORMAT_PARAMS +
"&action=query&redirects=1&titles=" +
......
......@@ -9,10 +9,10 @@ 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;
import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.util.GuiHelper;
import org.openstreetmap.josm.tools.AlphanumComparator;
import org.openstreetmap.josm.tools.Utils;
......@@ -35,7 +35,7 @@ public final class GuiUtils {
return true;
}
final Boolean r = GuiHelper.runInEDTAndWaitAndReturn(() ->
ConditionalOptionPaneUtil.showConfirmationDialog(PREF_OVERWRITE, Main.parent,
ConditionalOptionPaneUtil.showConfirmationDialog(PREF_OVERWRITE, MainApplication.getMainFrame(),
trn(
"Overwrite ''{0}'' tag {1} from {2} with new value ''{3}''?",
"Overwrite ''{0}'' tags {1} from {2} with new value ''{3}''?", existingValues.size(),
......
......@@ -17,7 +17,6 @@ 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;
import org.openstreetmap.josm.data.osm.Tag;
......@@ -40,7 +39,7 @@ public final class WikidataItemSearchDialog extends ExtendedDialog {
private static final WikidataItemSearchDialog INSTANCE = new WikidataItemSearchDialog();
private WikidataItemSearchDialog() {
super(Main.parent, tr("Search Wikidata items"), tr("Add Tag"), tr("Cancel"));
super(MainApplication.getMainFrame(), tr("Search Wikidata items"), tr("Add Tag"), tr("Cancel"));
this.selector = new Selector();
this.selector.setDblClickListener(e -> buttonAction(0, null));
this.targetKey = new AutoCompletingComboBox();
......
......@@ -7,8 +7,8 @@ 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.MainApplication;
import org.openstreetmap.josm.gui.util.GuiHelper;
import org.wikipedia.WikipediaApp;
import org.wikipedia.tools.WikiProperties;
......@@ -19,7 +19,7 @@ final class WikipediaCategorySearchDialog extends ExtendedDialog {
private static final WikipediaCategorySearchDialog INSTANCE = new WikipediaCategorySearchDialog();
private WikipediaCategorySearchDialog() {
super(Main.parent, tr("Search Wikipedia category"), new String[]{tr("Load category"), tr("Cancel")});
super(MainApplication.getMainFrame(), tr("Search Wikipedia category"), new String[]{tr("Load category"), tr("Cancel")});
this.selector = new Selector();
this.selector.setDblClickListener(e -> buttonAction(0, null));
......
......@@ -22,9 +22,9 @@ import javax.swing.JLabel;
import javax.swing.JList;
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;
import org.openstreetmap.josm.data.UndoRedoHandler;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
......@@ -41,6 +41,7 @@ import org.openstreetmap.josm.gui.SideButton;
import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.tools.I18n;
import org.openstreetmap.josm.tools.ImageProvider;
import org.openstreetmap.josm.tools.Logging;
......@@ -254,7 +255,7 @@ public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerCh
@Override
List<WikipediaEntry> getEntries() {
return WikipediaApp.forLanguage(WikiProperties.WIKIPEDIA_LANGUAGE.get())
.getEntriesFromCategory(category, Main.pref.getInt("wikipedia.depth", 3));
.getEntriesFromCategory(category, Config.getPref().getInt("wikipedia.depth", 3));
}
}.execute();
}
......@@ -335,7 +336,7 @@ public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerCh
ChangePropertyCommand cmd = new ChangePropertyCommand(
selected,
tag.getKey(), tag.getValue());
MainApplication.undoRedo.add(cmd);
UndoRedoHandler.getInstance().add(cmd);
MainApplication.worker.execute(new FetchWikidataAction.Fetcher(selected));
}
}
......@@ -367,7 +368,7 @@ public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerCh
protected void updateWikipediaArticles() {
final String language = getLanguageOfFirstItem();
articles.clear();
if (Main.main != null && MainApplication.getLayerManager().getEditDataSet() != null) {
if (MainApplication.getLayerManager().getEditDataSet() != null) {
MainApplication.getLayerManager().getEditDataSet().allPrimitives().stream()
.flatMap(p -> WikipediaApp.forLanguage(language).getWikipediaArticles(p))
.forEach(articles::add);
......
......@@ -18,6 +18,7 @@ public final class ListUtil {
* @param fullList the list that should be split into batches
* @param maxBatchSize the maximum size of one batch
* @param processBatch the consumer that is run on each batch
* @param updateProgress progress updater
* @param <T> the type of the list elements
*/
public static <T> void processInBatches(final List<T> fullList, int maxBatchSize, final Consumer<List<T>> processBatch, final BiConsumer<Integer, Integer> updateProgress) {
......
package org.wikipedia.api.wikidata_action;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.wikipedia.api.ApiQueryClient;
import org.wikipedia.testutils.ResourceFileLoader;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
import org.wikipedia.api.ApiQueryClient;
import org.wikipedia.testutils.ResourceFileLoader;
public class QueryResultTest extends WikidataActionApiTestAbstract {
@Test
......
......@@ -11,7 +11,7 @@ import org.openstreetmap.josm.testutils.JOSMTestRules;
public class WikiPreferencesTest {
@Rule
public JOSMTestRules test = new JOSMTestRules().platform();
public JOSMTestRules test = new JOSMTestRules();
@Test
public void testAddGui() {
......
......@@ -20,20 +20,19 @@ public class AllValidationTestsTest {
@Test
public void testValidationTestFields() throws IllegalAccessException {
AllValidationTests.ValidationTest<WikidataItemExists> test = AllValidationTests.INVALID_QID;
final Field[] fields = AllValidationTests.class.getDeclaredFields();
for (Field field : fields) {
if ((field.getModifiers() & Modifier.PRIVATE) == 0) {
final Object fieldValue = field.get(null);
if (fieldValue instanceof AllValidationTests.ValidationTest) {
System.out.print("Check validation test " + field.getName());
testValidationTestField((AllValidationTests.ValidationTest) fieldValue);
testValidationTestField((AllValidationTests.ValidationTest<?>) fieldValue);
}
}
}
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void testValidationTestField(final AllValidationTests.ValidationTest validationTest) {
final TestError te = validationTest
.getBuilder(new org.openstreetmap.josm.data.validation.Test("DummyTest"))
......
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