...
 
Commits (114)
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="test/unit"/> <classpathentry kind="src" path="test/unit"/>
<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> <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.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
......
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.java]
indent_size = 4
/.gradle/
/.idea/
/bin/
/build/
/javadoc/
/out/
/checkstyle-josm-wikipedia.xml
/findbugs-josm-wikipedia.xml
image: registry.gitlab.com/josm/docker-library/openjdk-8-josmplugin:latest
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
###############
# Build stage #
###############
assemble:
stage: build
script:
- ./gradlew assemble
artifacts:
paths:
- build/
assemble with java 10:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-10-josmplugin:latest
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/
##############
# Test stage #
##############
build:
stage: test
script:
- ./gradlew build generatePot generateSnapshotUpdateSite
artifacts:
paths:
- build
dependencies:
- assemble
compile against min JOSM:
stage: test
script:
- ./gradlew compileJava_minJosm
dependencies:
- assemble
compile against latest JOSM:
stage: test
script:
- ./gradlew compileJava_latestJosm
dependencies:
- assemble
build with java 10:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-10-josmplugin:latest
script:
- ./gradlew build
dependencies:
- assemble with java 10
################
# Deploy stage #
################
upload to transifex:
image: python:3.6-stretch
stage: deploy
environment:
name: transifex
url: https://www.transifex.com/josm/josm/josm-plugin_wikipedia/
before_script:
- apt-get update && apt-get install -yq gettext git
- pip install git+https://github.com/transifex/transifex-client.git
script:
- TX_TOKEN="$TRANSIFEX_TOKEN" tx push -s --no-interactive
dependencies:
- build
only:
- master@JOSM/wikipedia
release:
stage: deploy
environment:
name: pages branch / dist directory
url: https://gitlab.com/JOSM/wikipedia/tree/pages/dist
script:
- &clone_pages_branch |
echo "$SSH_PRIVATE_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git clone --depth 1 --branch pages git@gitlab.com:JOSM/wikipedia.git pages
- |
version=`git describe --always --dirty`
longVersion=`git describe --always --long --dirty`
commitMessage="Release version $longVersion"
- |
mkdir -pv "pages/dist/$version"
cp -v build/dist/* build/tmp/jar/MANIFEST.MF "pages/dist/$version"
rm -fv "pages/dist/latest"
ln -s "./$version" "pages/dist/latest"
- &push_pages_branch |
cd pages/
git config user.name "Deploy with GitLab CI"
git config user.email "JOSM/wikipedia@gitlab.com"
git stage .
git commit -a -m "$commitMessage"
git push origin pages
dependencies:
- build
only:
- tags@JOSM/wikipedia
publish master update site:
stage: deploy
environment:
name: pages branch / snapshot update site
url: https://gitlab.com/JOSM/wikipedia/tree/pages
script:
- *clone_pages_branch
- |
commitHash=`git rev-parse HEAD`
commitMessage="Make latest commit from master available via JOSM update site ($commitHash)"
- |
rm -vrf pages/snapshot/master
mkdir -pv pages/snapshot/master
cp -v build/snapshot-update-site pages/snapshot/master/update-site
cp -v build/dist/* pages/snapshot/master
- *push_pages_branch
dependencies:
- build
only:
- master@JOSM/wikipedia
[main]
host = https://www.transifex.com
[josm.josm-plugin_wikipedia]
file_filter = src/main/po/<lang>.po
source_file = build/i18n/josm-plugin_wikipedia.pot
source_lang = en
type = PO
minimum_perc=40
lang_map = ca@valencia: ca-valencia
...@@ -276,64 +276,3 @@ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY ...@@ -276,64 +276,3 @@ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
JOSM Wikipedia Plugin
=====================
This plugin simplifys linking OSM objects to Wikipedia articles.
Author: Simon Legner (simon04)
License: GPL v2 (as JOSM)
# JOSM Wikipedia Plugin
[![pipeline status](https://gitlab.com/JOSM/wikipedia/badges/master/pipeline.svg)](https://gitlab.com/JOSM/wikipedia/commits/master)
[![license](https://img.shields.io/badge/license-GPLv2-blue.svg?style=flat-square)](./LICENSE)
This plugin simplifies linking OSM objects to Wikipedia articles and Wikidata items. It also helps to maintain existing links to Wikipedia/Wikidata.
For its **user documentation**, see https://josm.openstreetmap.de/wiki/Help/Plugin/Wikipedia
## Installation
To use this plugin, [install JOSM](https://josm.openstreetmap.de/wiki/Download) and then [in the preferences menu install the **wikipedia** plugin](https://josm.openstreetmap.de/wiki/Help/Preferences/Plugins#AutomaticinstallationviaPreferencesmenu)
## Contributing
- The **source code** is hosted on [GitLab](https://gitlab.com/JOSM/wikipedia) and [GitHub](https://github.com/JOSM/wikipedia).
- **Issues** are managed in [JOSM Trac](https://josm.openstreetmap.de/query?status=assigned&status=needinfo&status=new&status=reopened&component=Plugin+wikipedia&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&col=time&col=changetime&report=1&desc=1&order=changet)
- **Translations** are managed [at Transifex](https://www.transifex.com/josm/josm/josm-plugin_wikipedia)
[![translation status](https://www.transifex.com/projects/p/josm/resource/josm-plugin_wikipedia/chart/image_png/)](https://www.transifex.com/josm/josm/josm-plugin_wikipedia)
## Authors
- Simon Legner (simon04)
- Vincent Privat (don-vip)
- Florian Schäfer (floscher)
- Yuri Astrakhan (nyurik)
## License
GPLv2 (same as JOSM)
import com.github.spotbugs.SpotBugsTask
import net.ltgt.gradle.errorprone.javacplugin.CheckSeverity
import org.openstreetmap.josm.gradle.plugin.task.GeneratePluginList
import java.nio.file.Files
import java.nio.file.Paths
import java.time.Duration
import java.time.Instant
plugins {
id "java"
id "eclipse"
id "jacoco"
id "pmd"
id "com.github.ben-manes.versions" version "0.20.0"
id "com.github.spotbugs" version "1.6.2"
id "org.openstreetmap.josm" version "0.5.0"
id "net.ltgt.errorprone" version "0.0.16" apply(false)
id "net.ltgt.errorprone-javacplugin" version "0.3" apply(false)
}
// Set up Errorprone
def errorproneChecks = [
"DefaultCharset": CheckSeverity.ERROR,
"StringEquality": CheckSeverity.ERROR,
"ConstantField": CheckSeverity.WARN,
"FieldCanBeFinal": CheckSeverity.WARN,
"LambdaFunctionalInterface": CheckSeverity.WARN,
"MethodCanBeStatic": CheckSeverity.WARN,
"MultiVariableDeclaration": CheckSeverity.WARN,
"PrivateConstructorForUtilityClass": CheckSeverity.WARN,
"UngroupedOverloads": CheckSeverity.WARN,
"WildcardImport": CheckSeverity.WARN
]
if (JavaVersion.current().java9Compatible) {
apply plugin: "net.ltgt.errorprone-javacplugin"
// TODO: add the errorprone checks
} else {
apply plugin: "net.ltgt.errorprone"
tasks.withType(JavaCompile) {
errorproneChecks.forEach { name, severity ->
options.compilerArgs.add("-Xep:$name:$severity")
}
}
}
def versions = [
errorprone: "2.3.1",
jacoco: "0.8.1",
junit: "5.2.0",
pmd: "6.6.0",
spotbugs: "3.1.6",
]
repositories {
jcenter()
}
dependencies {
errorprone("com.google.errorprone:error_prone_core:${versions.errorprone}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
testImplementation("org.junit.vintage:junit-vintage-engine:${versions.junit}")
testImplementation("com.github.spotbugs:spotbugs-annotations:${versions.spotbugs}")
testImplementation("org.openstreetmap.josm:josm-unittest:"){changing=true}
testImplementation("com.github.tomakehurst:wiremock:2.18.0")
testImplementation("org.awaitility:awaitility:3.1.2")
}
def ivyModule = new XmlParser().parse(new File("$projectDir/ivy.xml"))
logger.info("Dependencies from ivy.xml (added to configuration `packIntoJar`):")
ivyModule.dependencies.dependency.each {
logger.info("* ${it.@org}:${it.@name}:${it.@rev}")
project.dependencies.packIntoJar("${it.@org}:${it.@name}:${it.@rev}")
}
test {
useJUnitPlatform()
testLogging.exceptionFormat = 'full'
}
sourceSets {
test {
java {
srcDirs = ["test/unit"]
}
resources {
srcDirs = ["test/data"]
}
}
}
tasks.processResources {
from("$projectDir/LICENSE")
from("$projectDir/README.md")
}
archivesBaseName = "wikipedia"
josm {
manifest {
oldVersionDownloadLink 13597, "v1.0.1", new URL("https://github.com/JOSM/wikipedia/releases/download/v1.0.1/wikipedia.jar")
oldVersionDownloadLink 12900, "34109", new URL("https://svn.openstreetmap.org/applications/editors/josm/dist/wikipedia.jar?p=34113")
oldVersionDownloadLink 12878, "33635", new URL("https://svn.openstreetmap.org/applications/editors/josm/dist/wikipedia.jar?p=33636")
}
i18n {
pathTransformer = getPathTransformer("gitlab.com/JOSM/wikipedia/blob")
}
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xlint:all",
"-Xlint:-serial",
]
}
// Set up JaCoCo
jacoco {
toolVersion = "${versions.jacoco}"
}
jacocoTestReport {
dependsOn test
reports {
xml.enabled = true
html.enabled = true
}
}
check.dependsOn jacocoTestReport
// Set up PMD
pmd {
toolVersion = versions.pmd
ignoreFailures true
ruleSets = []
ruleSetConfig = resources.text.fromFile("$projectDir/config/pmd/ruleset.xml")
sourceSets = [sourceSets.main]
}
// Set up SpotBugs
spotbugs {
toolVersion = versions.spotbugs
ignoreFailures = true
sourceSets = [sourceSets.main]
}
tasks.withType(SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
task generateSnapshotUpdateSite(type: GeneratePluginList) {
dependsOn(tasks.processResources)
outputFile = new File(project.buildDir, "snapshot-update-site")
versionSuffix = {a -> ""}
doFirst {
def pluginDownloadUrl = "https://josm.gitlab.io/$archivesBaseName/snapshot/master/${archivesBaseName}.jar"
it.iconBase64Provider = {
def file = new File(sourceSets.main.resources.srcDirs[0], it)
if (file.exists()) {
def contentType = file.name.endsWith(".svg") ? "svg+xml" : "png"
return "data:image/" + contentType + ";base64," + Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(file.toURI())));
}
}
it.addPlugin("$archivesBaseName-dev.jar", project.josm.manifest.createJosmPluginJarManifest(), new URL(pluginDownloadUrl))
}
}
// Show task duration and skipped tasks
gradle.taskGraph.beforeTask {
it.ext.startTime = Instant.now()
}
gradle.taskGraph.afterTask {
if (!it.getState().skipped) {
it.logger.lifecycle(String.format("\n 🏁 Finished after %.3f seconds.", Duration.between(it.ext.startTime as Instant, Instant.now()).toMillis() / 1e3))
}
}
gradle.buildFinished {
def wereTasksSkipped = false
tasks.forEach {
if (it.state.skipped) {
if (!wereTasksSkipped) {
it.logger.lifecycle("\nSkipped tasks:")
wereTasksSkipped = true
}
it.logger.lifecycle("⏭️ :${it.name} (${it.state.skipMessage})")
}
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project name="wikipedia" default="dist2" basedir="."> <project xmlns:ivy="antlib:org.apache.ivy.ant" name="wikipedia" default="dist" basedir=".">
<property name="plugin.src.dir" value="src/main/java"/>
<!-- enter the SVN commit message --> <!-- edit the properties of this plugin in the file `gradle.properties` -->
<property name="commit.message" value="Commit message"/> <property file="${basedir}/gradle.properties"/>
<!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
<property name="plugin.main.version" value="13597"/>
<property name="plugin.canloadatruntime" value="true"/>
<property name="plugin.author" value="simon04"/> <!-- ** include targets that all plugins have in common ** -->
<property name="plugin.class" value="org.wikipedia.WikipediaPlugin"/> <import file="../build-common.xml"/>
<property name="plugin.description" value="Simplifies linking OSM objects to Wikipedia articles and Wikidata items"/>
<property name="plugin.icon" value="images/dialogs/wikipedia.png"/>
<property name="plugin.link" value="https://josm.openstreetmap.de/wiki/Help/Plugin/Wikipedia"/>
<!-- ** include targets that all plugins have in common ** --> <!-- Override the `setup-dist-default` task from build-common.xml -->
<import file="../build-common.xml"/> <target name="setup-dist-default">
<copy todir="${plugin.build.dir}" failonerror="no" includeemptydirs="no">
<fileset dir="src/main/resources"/>
</copy>
<copy todir="${plugin.build.dir}">
<fileset dir=".">
<include name="README"/>
<include name="LICENSE*"/>
<include name="*GPL*"/>
<include name="*.md"/>
</fileset>
</copy>
</target>
<target name="dist2" depends="dist"> <property name="ivy.home" value="${user.home}/.ant"/>
<copy file="${plugin.jar}" todir="${plugin.dist.dir}/../.josm/plugins"/> <property name="ivy.jar.dir" value="${ivy.home}/lib"/>
</target> <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
<target name="download-ivy">
<mkdir dir="${ivy.jar.dir}"/>
<get src="https://jcenter.bintray.com/org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar" dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="pre-compile" description="retrieve dependencies with Ivy" depends="init-ivy">
<ivy:retrieve/>
</target>
</project> </project>
coverage:
range: 50..100
fixes:
- "project/::src/"
<?xml version="1.0"?>
<ruleset name="Ruleset for josm-mapillary-plugin"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
This ruleset checks some rules that you should normally follow for the JOSM-wikipedia plugin.
</description>
<rule ref="category/java/bestpractices.xml"/>
<rule ref="category/java/codestyle.xml">
<exclude name="AbstractNaming"/>
<exclude name="AvoidFinalLocalVariable"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="DefaultPackage"/>
<exclude name="LongVariable"/>
<exclude name="MethodArgumentCouldBeFinal"/><!-- way too many -->
<exclude name="ShortVariable"/>
</rule>
<rule ref="category/java/design.xml">
<exclude name="LawOfDemeter"/>
<exclude name="LoosePackageCoupling"/>
</rule>
<rule ref="category/java/errorprone.xml"/>
<rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
<rule ref="category/java/multithreading.xml/NonThreadSafeSingleton" />
</ruleset>
\ No newline at end of file
Binary files a/data/en_AU.lang and /dev/null differ Binary files a/data/en_AU.lang and /dev/null differ
Binary files a/data/en_GB.lang and /dev/null differ Binary files a/data/en_GB.lang and /dev/null differ
# The minimum JOSM version this plugin is compatible with (can be any numeric version)
plugin.main.version = 13927
# 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.canloadatruntime = true
plugin.author = floscher <incoming+JOSM/wikipedia@incoming.gitlab.com>, simon04
plugin.class = org.wikipedia.WikipediaPlugin
plugin.icon = images/dialogs/wikipedia.png
plugin.link = https://josm.openstreetmap.de/wiki/Help/Plugin/Wikipedia
plugin.description = Simplifies linking OSM objects to Wikipedia articles and Wikidata items
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=39e2d5803bbd5eaf6c8efe07067b0e5a00235e8c71318642b2ed262920b27721
\ No newline at end of file
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
<ivy-module version="2.0">
<info organisation="org.openstreetmap.josm.plugins" module="wikipedia"/>
<dependencies>
<dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.9.6"/>
<dependency org="org.wikidata.wdtk" name="wdtk-wikibaseapi" rev="0.9.0"/>
<dependency org="org.wikidata.wdtk" name="wdtk-dumpfiles" rev="0.9.0"/>
</dependencies>
</ivy-module>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>wikipedia</name>
</general-data>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
<!-- Не используйте диалоговое окно свойств проекта при редактировании данного файла вручную. -->
<name>wikipedia</name>
<properties/>
<folders>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>test</label>
<type>java</type>
<location>test</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>wikipedia</label>
<location>.</location>
<encoding>UTF-8</encoding>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>compile</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="run">
<target>runjosm</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>compile</target>
</action>
</ide-actions>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-folder style="packages">
<label>test</label>
<location>test</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="rebuild"/>
<ide-action name="clean"/>
<ide-action name="run"/>
</context-menu>
</view>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="compile">../../core/src</classpath>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>test</package-root>
<unit-tests/>
<source-level>1.8</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
// License: GPL. For details, see LICENSE file.
package org.wikipedia;
import java.io.File;
import org.apache.commons.jcs.access.CacheAccess;
import org.openstreetmap.josm.data.cache.JCSCacheManager;
import org.openstreetmap.josm.spi.preferences.Config;
public final class Caches {
public static final CacheAccess<String, String> API_RESPONSES = JCSCacheManager.getCache(
"api",
1,
10_000,
new File(Config.getDirs().getCacheDirectory(false), "plugin/wikipedia").getAbsolutePath()
);
private Caches() {
// Private constructor to avoid instantiation
}
}
// License: GPL. For details, see LICENSE file. // License: GPL. For details, see LICENSE file.
package org.wikipedia; package org.wikipedia;
import javax.swing.ImageIcon;
import javax.swing.JMenu; import javax.swing.JMenu;
import org.openstreetmap.josm.data.Version;
import org.openstreetmap.josm.data.validation.OsmValidator;
import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.MainMenu; import org.openstreetmap.josm.gui.MainMenu;
import org.openstreetmap.josm.gui.MapFrame; import org.openstreetmap.josm.gui.MapFrame;
...@@ -10,17 +12,34 @@ import org.openstreetmap.josm.gui.download.DownloadDialog; ...@@ -10,17 +12,34 @@ import org.openstreetmap.josm.gui.download.DownloadDialog;
import org.openstreetmap.josm.gui.preferences.PreferenceSetting; import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
import org.openstreetmap.josm.plugins.Plugin; import org.openstreetmap.josm.plugins.Plugin;
import org.openstreetmap.josm.plugins.PluginInformation; import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.tools.ImageProvider;
import org.wikipedia.actions.FetchWikidataAction; import org.wikipedia.actions.FetchWikidataAction;
import org.wikipedia.actions.WikipediaAddNamesAction; import org.wikipedia.actions.WikipediaAddNamesAction;
import org.wikipedia.actions.WikipediaCopyTemplate; import org.wikipedia.actions.WikipediaCopyTemplate;
import org.wikipedia.gui.*; import org.wikipedia.gui.SophoxDownloadReader;
import org.wikipedia.gui.WikiPreferences;
import org.wikipedia.gui.WikidataInfoToggleDialog;
import org.wikipedia.gui.WikidataItemSearchDialog;
import org.wikipedia.gui.WikidataTagCellRenderer;
import org.wikipedia.gui.WikipediaToggleDialog;
import org.wikipedia.validator.UnusualWikidataClasses;
import org.wikipedia.validator.WikidataItemExists;
import org.wikipedia.validator.WikipediaAgainstWikidata;
import org.wikipedia.validator.WikipediaRedirect;
public final class WikipediaPlugin extends Plugin {
public static final ImageIcon LOGO = ImageProvider.get("dialogs/wikipedia");
public static final ImageProvider W_IMAGE = new ImageProvider("w");
public class WikipediaPlugin extends Plugin { private static String name;
private static String versionInfo;
private PreferenceSetting preferences; private final PreferenceSetting preferences = new WikiPreferences();
public WikipediaPlugin(PluginInformation info) { public WikipediaPlugin(PluginInformation info) {
super(info); super(info);
versionInfo = String.format("JOSM/%s JOSM-wikipedia/%s", Version.getInstance().getVersionString(), info.version);
name = info.name;
new WikipediaCopyTemplate(); new WikipediaCopyTemplate();
JMenu dataMenu = MainApplication.getMenu().dataMenu; JMenu dataMenu = MainApplication.getMenu().dataMenu;
MainMenu.add(dataMenu, new WikipediaAddNamesAction()); MainMenu.add(dataMenu, new WikipediaAddNamesAction());
...@@ -28,21 +47,33 @@ public class WikipediaPlugin extends Plugin { ...@@ -28,21 +47,33 @@ public class WikipediaPlugin extends Plugin {
MainMenu.add(dataMenu, new WikidataItemSearchDialog.Action()); MainMenu.add(dataMenu, new WikidataItemSearchDialog.Action());
DownloadDialog.addDownloadSource(new SophoxDownloadReader()); DownloadDialog.addDownloadSource(new SophoxDownloadReader());
OsmValidator.addTest(WikidataItemExists.class);
OsmValidator.addTest(WikipediaAgainstWikidata.class);
OsmValidator.addTest(WikipediaRedirect.class);
OsmValidator.addTest(UnusualWikidataClasses.class);
}
public static String getVersionInfo() {
return versionInfo;
}
public static String getName() {
return name;
} }
@Override @Override
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
if (newFrame != null) { if (newFrame != null) {
newFrame.addToggleDialog(new WikipediaToggleDialog()); final WikipediaToggleDialog wikiDialog = new WikipediaToggleDialog();
newFrame.addToggleDialog(wikiDialog);
newFrame.addToggleDialog(new WikidataInfoToggleDialog(wikiDialog));
newFrame.propertiesDialog.addCustomPropertiesCellRenderer(new WikidataTagCellRenderer()); newFrame.propertiesDialog.addCustomPropertiesCellRenderer(new WikidataTagCellRenderer());
} }
} }
@Override @Override
public PreferenceSetting getPreferenceSetting() { public PreferenceSetting getPreferenceSetting() {
if (preferences == null) {
preferences = (new SophoxServerPreference.Factory()).createPreferenceSetting();
}
return preferences; return preferences;
} }
} }
...@@ -11,9 +11,7 @@ import java.util.HashMap; ...@@ -11,9 +11,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.openstreetmap.josm.actions.JosmAction; import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.command.ChangePropertyCommand; import org.openstreetmap.josm.command.ChangePropertyCommand;
import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.command.Command;
...@@ -45,7 +43,7 @@ public class FetchWikidataAction extends JosmAction { ...@@ -45,7 +43,7 @@ public class FetchWikidataAction extends JosmAction {
if (ds == null) { if (ds == null) {
return; return;
} }
MainApplication.worker.submit(new Fetcher(ds.getSelected())); MainApplication.worker.execute(new Fetcher(ds.getSelected()));
} }
public static class Fetcher extends PleaseWaitRunnable { public static class Fetcher extends PleaseWaitRunnable {
......
// License: GPL. For details, see LICENSE file.
package org.wikipedia.actions;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.gui.SideButton;
import org.openstreetmap.josm.tools.Logging;
public class MultiAction extends JosmAction {
public static SideButton createButton(final String name, final String iconName, final String tooltip, final Action... actions) {
final MultiAction popupAction = new MultiAction(name, iconName, tooltip, actions);
final SideButton button = new SideButton(popupAction);
popupAction.setParent(button);
button.createArrow(it -> button.getAction().actionPerformed(it));
return button;
}
private final JPopupMenu popup;
private Component parent;
private MultiAction(final String name, final String iconName, final String tooltip, final Action... actions) {
// I18n: {0} is the number of available sources
super(name, iconName, tooltip, null, false, false);
popup = new ActionsPopup(actions);
}
@Override
public void actionPerformed(ActionEvent e) {
final Component finalParent = parent;
if (finalParent != null) {
final Rectangle parentBounds = finalParent.getBounds();
popup.show(finalParent, parentBounds.x - parentBounds.width, parentBounds.y);
} else {
Logging.error("The parent component of a MultiAction must not be null!");
}
}
private void setParent(final Component parent) {
this.parent = parent;
}
private static class ActionsPopup extends JPopupMenu {
private ActionsPopup(final Action... actions) {
for (final Action action : actions) {
add(new JMenuItem(action));
}
}
}
}
// License: GPL. For details, see LICENSE file.
package org.wikipedia.actions;
import java.awt.event.ActionEvent;
import java.util.List;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.tools.I18n;
import org.openstreetmap.josm.tools.ImageProvider;
import org.wikipedia.gui.WikiLayer;
import org.wikipedia.gui.WikipediaToggleDialog;
public class ToggleWikiLayerAction extends JosmAction {
private static final ImageProvider ICON_ADDWIKI = new ImageProvider("layer", "addwiki").setMaxSize(ImageProvider.ImageSizes.SIDEBUTTON);
private static final ImageProvider ICON_REMOVEWIKI = new ImageProvider("layer", "removewiki").setMaxSize(ImageProvider.ImageSizes.SIDEBUTTON);
private final WikipediaToggleDialog dialog;
public ToggleWikiLayerAction(final WikipediaToggleDialog dialog) {
super(
I18n.tr("Wiki layer"),
ICON_ADDWIKI,
I18n.tr("Toggle the layer displaying Wikipedia articles or Wikidata items"),
null,
false,
null,
true
);
this.dialog = dialog;
}
@Override
public synchronized void actionPerformed(ActionEvent e) {
final List<WikiLayer> wikiLayers = MainApplication.getLayerManager().getLayersOfType(WikiLayer.class);
if (wikiLayers.size() <= 0) {
MainApplication.getLayerManager().addLayer(new WikiLayer(dialog));
} else {
for (WikiLayer layer : wikiLayers) {
MainApplication.getLayerManager().removeLayer(layer);
}
}
}
@Override
protected boolean listenToSelectionChange() {
return false;
}
@Override
public void updateEnabledState() {
final ImageProvider provider;
if (MainApplication.getLayerManager().getLayersOfType(WikiLayer.class).size() <= 0) {
provider = ICON_ADDWIKI;
} else {
provider = ICON_REMOVEWIKI;
}
provider.getResource().attachImageIcon(this, true);
}
}
...@@ -9,14 +9,17 @@ import java.util.Arrays; ...@@ -9,14 +9,17 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.openstreetmap.josm.Main; import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.actions.JosmAction; import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.gui.Notification;
import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
import org.openstreetmap.josm.tools.I18n;
import org.openstreetmap.josm.tools.ImageProvider;
import org.openstreetmap.josm.tools.Logging; import org.openstreetmap.josm.tools.Logging;
import org.wikipedia.WikipediaApp; import org.wikipedia.WikipediaApp;
import org.wikipedia.WikipediaPlugin;
import org.wikipedia.data.WikipediaEntry; import org.wikipedia.data.WikipediaEntry;
public class WikipediaAddNamesAction extends JosmAction { public class WikipediaAddNamesAction extends JosmAction {
...@@ -30,15 +33,21 @@ public class WikipediaAddNamesAction extends JosmAction { ...@@ -30,15 +33,21 @@ public class WikipediaAddNamesAction extends JosmAction {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final WikipediaEntry wp = WikipediaEntry.parseTag("wikipedia", getWikipediaValue()); final WikipediaEntry wp = WikipediaEntry.parseTag("wikipedia", getWikipediaValue());
List<String[]> tags = new ArrayList<>(); if (wp == null) {
WikipediaApp.forLanguage(wp.lang).getInterwikiArticles(wp.article).stream() new Notification(I18n.tr("Could not add names. Wikipedia tag is not recognized!"))
.setIcon(WikipediaPlugin.W_IMAGE.setMaxSize(ImageProvider.ImageSizes.LARGEICON).get())
.show();
} else {
List<String[]> tags = new ArrayList<>();
WikipediaApp.forLanguage(wp.lang).getInterwikiArticles(wp.article).stream()
.filter(this::useWikipediaLangArticle) .filter(this::useWikipediaLangArticle)
.map(i -> new String[]{"name:" + i.lang, i.article})