Skip to content

Commit

Permalink
Merge pull request #13 from floscher/update-josm-api
Browse files Browse the repository at this point in the history
Replace calls of JOSM API that is now removed (since JOSM 14215)
  • Loading branch information
iandees authored Sep 20, 2018
2 parents 04698ac + 3cb556d commit 92d741b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 58 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jdk:
- openjdk8
- oraclejdk8
- oraclejdk9
script: ./gradlew build compileMinJosmVersion
script: ./gradlew build compileJava_minJosm
deploy:
- provider: releases
api-key:
Expand All @@ -21,14 +21,13 @@ jobs:
include:
- stage: i18n
language: python
python: "3.5"
install: pip install git+https://github.com/transifex/transifex-client.git@a706ba0cb910e66e852010bcd742221363c7e8be#egg=transifex-client
python: "3.6"
install: pip install git+https://github.com/transifex/transifex-client.git@c8434afc44c74fa36400dc0574f5b0b25580e1e0#egg=transifex-client
script: |
if [ ! -z "$TRANSIFEX_TOKEN" ]; then
export PATH="$PATH:$HOME/.local/bin"
./gradlew generatePot
tx --token="$TRANSIFEX_TOKEN" --force-save --no-interactive init
git checkout HEAD .tx/config
tx push -s --no-interactive
TX_TOKEN="$TRANSIFEX_TOKEN" tx push -s --no-interactive
fi
stages:
Expand Down
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
plugins {
id "org.openstreetmap.josm" version "0.3.1"
id 'eclipse'
id 'idea'
id "java"
id "org.openstreetmap.josm" version "0.5.0"
}
apply from: 'gradle/version-functions.gradle'

sourceCompatibility = '1.8'
version = getVersionName()

sourceSets {
main {
Expand All @@ -25,17 +22,20 @@ sourceSets {
archivesBaseName = 'fieldpapers'
josm {
i18n {
pathTransformer = getGithubPathTransformer('fieldpapers/josm-fieldpapers')
pathTransformer = getPathTransformer("github.com/fieldpapers/josm-fieldpapers/blob")
}
manifest {
oldVersionDownloadLink 10273, 'v0.4.2', new URL('https://github.com/floscher/josm-fieldpapers/releases/download/v0.4.2/fieldpapers.jar')
}
}

eclipse.project.name = 'JOSM-fieldpapers'
eclipseClasspath.dependsOn cleanEclipseClasspath
eclipseProject.dependsOn cleanEclipseProject

tasks.withType(Javadoc) {
failOnError false
}

tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xlint:all",
"-Xlint:-serial",
]
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugin.icon=images/preferences/fieldpapers.png
plugin.link=http://wiki.openstreetmap.org/index.php/JOSM/Plugins/FieldPapers
# Minimum required JOSM version to run this plugin, choose the lowest version possible that is compatible.
# You can check if the plugin compiles against this version by executing `./gradlew minJosmVersionClasses`.
plugin.main.version=12643
plugin.main.version=14140
# Version of JOSM against which the plugin is compiled
# Please check, if the specified version is available for download from https://josm.openstreetmap.de/download/ .
# If not, choose the next higher number that is available, or the gradle build will break.
plugin.compile.version=13265
plugin.compile.version=14178
17 changes: 0 additions & 17 deletions gradle/version-functions.gradle

This file was deleted.

3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionSha256Sum=5c07b3bac2209fbc98fb1fdf6fd831f72429cdf8c503807404eae03d8c8099e5
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.coor.LatLon;
Expand All @@ -33,7 +32,7 @@
public class FieldPapersAddLayerAction extends JosmAction {

public FieldPapersAddLayerAction() {
super(tr("Scanned Map..."), "fieldpapers",
super(tr("FieldPapers snapshot"), "fieldpapers",
tr("Display a map that was previously scanned and uploaded to fieldpapers.org"), null, false);
}

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

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

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

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

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

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

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

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

} catch (IOException ex) {
Logging.error(ex);
JOptionPane.showMessageDialog(Main.parent,tr("Could not read information for the id \"{0}\" from fieldpapers.org", url));
JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read information for the id \"{0}\" from fieldpapers.org", url));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package org.openstreetmap.josm.plugins.fieldpapers;

import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
import static org.openstreetmap.josm.tools.I18n.tr;

import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

import org.openstreetmap.josm.data.Preferences;
import org.openstreetmap.josm.data.preferences.StringProperty;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.MainMenu;
import org.openstreetmap.josm.plugins.Plugin;
import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.tools.Logging;

/**
* Main class for the field papers plugin.
Expand All @@ -20,14 +16,22 @@
* @author Frederik Ramm <[email protected]>
*
*/
public class FieldPapersPlugin extends Plugin
{
public FieldPapersPlugin(PluginInformation info)
{
public class FieldPapersPlugin extends Plugin {
public static final StringProperty LAST_USED_ID = new StringProperty("fieldpapers.last-used-id", "");

public static final StringProperty BASE_URL = new StringProperty("fieldpapers.base-url", "http://fieldpapers.org/");

public FieldPapersPlugin(PluginInformation info) {
super(info);

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

MainApplication.getMenu().imageryMenu.add(new JMenuItem(new FieldPapersAddLayerAction()));
}
}

0 comments on commit 92d741b

Please sign in to comment.