Skip to content

Commit 92d741b

Browse files
authored
Merge pull request #13 from floscher/update-josm-api
Replace calls of JOSM API that is now removed (since JOSM 14215)
2 parents 04698ac + 3cb556d commit 92d741b

File tree

7 files changed

+42
-58
lines changed

7 files changed

+42
-58
lines changed

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jdk:
33
- openjdk8
44
- oraclejdk8
55
- oraclejdk9
6-
script: ./gradlew build compileMinJosmVersion
6+
script: ./gradlew build compileJava_minJosm
77
deploy:
88
- provider: releases
99
api-key:
@@ -21,14 +21,13 @@ jobs:
2121
include:
2222
- stage: i18n
2323
language: python
24-
python: "3.5"
25-
install: pip install git+https://github.com/transifex/transifex-client.git@a706ba0cb910e66e852010bcd742221363c7e8be#egg=transifex-client
24+
python: "3.6"
25+
install: pip install git+https://github.com/transifex/transifex-client.git@c8434afc44c74fa36400dc0574f5b0b25580e1e0#egg=transifex-client
2626
script: |
2727
if [ ! -z "$TRANSIFEX_TOKEN" ]; then
28+
export PATH="$PATH:$HOME/.local/bin"
2829
./gradlew generatePot
29-
tx --token="$TRANSIFEX_TOKEN" --force-save --no-interactive init
30-
git checkout HEAD .tx/config
31-
tx push -s --no-interactive
30+
TX_TOKEN="$TRANSIFEX_TOKEN" tx push -s --no-interactive
3231
fi
3332
3433
stages:

build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
plugins {
2-
id "org.openstreetmap.josm" version "0.3.1"
3-
id 'eclipse'
4-
id 'idea'
2+
id "java"
3+
id "org.openstreetmap.josm" version "0.5.0"
54
}
6-
apply from: 'gradle/version-functions.gradle'
75

86
sourceCompatibility = '1.8'
9-
version = getVersionName()
107

118
sourceSets {
129
main {
@@ -25,17 +22,20 @@ sourceSets {
2522
archivesBaseName = 'fieldpapers'
2623
josm {
2724
i18n {
28-
pathTransformer = getGithubPathTransformer('fieldpapers/josm-fieldpapers')
25+
pathTransformer = getPathTransformer("github.com/fieldpapers/josm-fieldpapers/blob")
2926
}
3027
manifest {
3128
oldVersionDownloadLink 10273, 'v0.4.2', new URL('https://github.com/floscher/josm-fieldpapers/releases/download/v0.4.2/fieldpapers.jar')
3229
}
3330
}
3431

35-
eclipse.project.name = 'JOSM-fieldpapers'
36-
eclipseClasspath.dependsOn cleanEclipseClasspath
37-
eclipseProject.dependsOn cleanEclipseProject
38-
3932
tasks.withType(Javadoc) {
4033
failOnError false
4134
}
35+
36+
tasks.withType(JavaCompile) {
37+
options.compilerArgs += [
38+
"-Xlint:all",
39+
"-Xlint:-serial",
40+
]
41+
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ plugin.icon=images/preferences/fieldpapers.png
55
plugin.link=http://wiki.openstreetmap.org/index.php/JOSM/Plugins/FieldPapers
66
# Minimum required JOSM version to run this plugin, choose the lowest version possible that is compatible.
77
# You can check if the plugin compiles against this version by executing `./gradlew minJosmVersionClasses`.
8-
plugin.main.version=12643
8+
plugin.main.version=14140
99
# Version of JOSM against which the plugin is compiled
1010
# Please check, if the specified version is available for download from https://josm.openstreetmap.de/download/ .
1111
# If not, choose the next higher number that is available, or the gradle build will break.
12-
plugin.compile.version=13265
12+
plugin.compile.version=14178

gradle/version-functions.gradle

Lines changed: 0 additions & 17 deletions
This file was deleted.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6-
distributionSha256Sum=5c07b3bac2209fbc98fb1fdf6fd831f72429cdf8c503807404eae03d8c8099e5
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import javax.swing.JOptionPane;
1818
import javax.swing.JPanel;
1919

20-
import org.openstreetmap.josm.Main;
2120
import org.openstreetmap.josm.actions.JosmAction;
2221
import org.openstreetmap.josm.data.Bounds;
2322
import org.openstreetmap.josm.data.coor.LatLon;
@@ -33,7 +32,7 @@
3332
public class FieldPapersAddLayerAction extends JosmAction {
3433

3534
public FieldPapersAddLayerAction() {
36-
super(tr("Scanned Map..."), "fieldpapers",
35+
super(tr("FieldPapers snapshot"), "fieldpapers",
3736
tr("Display a map that was previously scanned and uploaded to fieldpapers.org"), null, false);
3837
}
3938

@@ -42,11 +41,11 @@ public void actionPerformed(ActionEvent e) {
4241

4342
// snapshot URL selection
4443
panel.add(new JLabel(tr("Enter a fieldpapers.org snapshot URL to download from")), GBC.eol());
45-
JosmTextField snapshotAddress = new JosmTextField(Main.pref.get("fieldpapers.last-used-id"));
44+
JosmTextField snapshotAddress = new JosmTextField(FieldPapersPlugin.LAST_USED_ID.get());
4645
snapshotAddress.setToolTipText(tr("Enter an URL from where scanned map should be downloaded"));
4746
panel.add(snapshotAddress, GBC.eop().fill(GBC.BOTH));
4847

49-
ExtendedDialog dialog = new ExtendedDialog(Main.parent,
48+
ExtendedDialog dialog = new ExtendedDialog(MainApplication.getMainFrame(),
5049
tr("Download Snapshot"),
5150
tr("Download"), tr("Cancel"))
5251
.setContent(panel, false)
@@ -64,7 +63,7 @@ public void openUrl(String url) {
6463
if (url == null || url.equals("")) return;
6564

6665
if (!url.startsWith("http")) {
67-
url = Main.pref.get("fieldpapers-base-url", "http://fieldpapers.org/") + "snapshots/" + url;
66+
url = FieldPapersPlugin.BASE_URL.get() + "snapshots/" + url;
6867
}
6968

7069
try {
@@ -88,7 +87,7 @@ public void openUrl(String url) {
8887
double north = bounds.getJsonNumber(3).doubleValue();
8988

9089
// save this atlas as the
91-
Main.pref.put("fieldpapers.last-used-id", id);
90+
FieldPapersPlugin.LAST_USED_ID.put(id);
9291

9392
Bounds b = new Bounds(new LatLon(south, west), new LatLon(north, east));
9493

@@ -97,7 +96,7 @@ public void openUrl(String url) {
9796

9897
} catch (IOException ex) {
9998
Logging.error(ex);
100-
JOptionPane.showMessageDialog(Main.parent,tr("Could not read information for the id \"{0}\" from fieldpapers.org", url));
99+
JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read information for the id \"{0}\" from fieldpapers.org", url));
101100
}
102101
}
103102

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package org.openstreetmap.josm.plugins.fieldpapers;
22

3-
import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
4-
import static org.openstreetmap.josm.tools.I18n.tr;
5-
6-
import java.awt.event.KeyEvent;
7-
8-
import javax.swing.JMenu;
93
import javax.swing.JMenuItem;
104

5+
import org.openstreetmap.josm.data.Preferences;
6+
import org.openstreetmap.josm.data.preferences.StringProperty;
117
import org.openstreetmap.josm.gui.MainApplication;
12-
import org.openstreetmap.josm.gui.MainMenu;
138
import org.openstreetmap.josm.plugins.Plugin;
149
import org.openstreetmap.josm.plugins.PluginInformation;
10+
import org.openstreetmap.josm.tools.Logging;
1511

1612
/**
1713
* Main class for the field papers plugin.
@@ -20,14 +16,22 @@
2016
* @author Frederik Ramm <frederik@remote.org>
2117
*
2218
*/
23-
public class FieldPapersPlugin extends Plugin
24-
{
25-
public FieldPapersPlugin(PluginInformation info)
26-
{
19+
public class FieldPapersPlugin extends Plugin {
20+
public static final StringProperty LAST_USED_ID = new StringProperty("fieldpapers.last-used-id", "");
21+
22+
public static final StringProperty BASE_URL = new StringProperty("fieldpapers.base-url", "http://fieldpapers.org/");
23+
24+
public FieldPapersPlugin(PluginInformation info) {
2725
super(info);
2826

29-
MainMenu menu = MainApplication.getMenu();
30-
JMenu fpMenu = menu.addMenu("Field Papers", tr("Field Papers"), KeyEvent.VK_K, menu.getDefaultMenuPos(), ht("/Plugin/FieldPapers"));
31-
fpMenu.add(new JMenuItem(new FieldPapersAddLayerAction()));
27+
// Migrate old setting, remove this in one of the next versions.
28+
final String oldValue = Preferences.main().get("fieldpapers-base-url");
29+
if (!"".equals(oldValue) && !BASE_URL.isSet()) {
30+
BASE_URL.put(oldValue);
31+
Preferences.main().put("fieldpapers-base-url", null);
32+
Logging.info("Preference `fieldpapers-base-url`={0} was renamed to `fieldpapers.base-url`!", oldValue);
33+
}
34+
35+
MainApplication.getMenu().imageryMenu.add(new JMenuItem(new FieldPapersAddLayerAction()));
3236
}
3337
}

0 commit comments

Comments
 (0)