Changeset 28784 in osm for applications


Ignore:
Timestamp:
2012-10-07T16:02:46+02:00 (12 years ago)
Author:
zverik
Message:

no_more_mapping plugin done

Location:
applications/editors/josm
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/no_more_mapping/src/nomore/NoMorePlugin.java

    r28783 r28784  
    11package nomore;
    22
     3import java.util.Date;
     4import javax.swing.JOptionPane;
     5import org.openstreetmap.josm.Main;
    36import org.openstreetmap.josm.plugins.Plugin;
    47import org.openstreetmap.josm.plugins.PluginInformation;
     8import static org.openstreetmap.josm.tools.I18n.tr;
    59
    610/**
     
    1317    public NoMorePlugin(PluginInformation info) {
    1418        super(info);
     19        long startDate = Main.pref.getLong("nomoremapping.date", 0);
     20        long lastHash = Math.max(Main.pref.getLong("pluginmanager.lastupdate", 0) / 1000,
     21                Math.max(Main.pref.getLong("cache.motd.html", 0),
     22                Main.pref.getLong("cache.bing.attribution.xml", 0))) + Main.pref.get("osm-download.bounds", "").hashCode();
     23        boolean sameHash = Main.pref.getLong("nomoremapping.hash", 0) == lastHash;
     24        long today = new Date().getTime() / 1000;
     25        if( startDate == 0 || !sameHash ) {
     26            startDate = today;
     27            Main.pref.putLong("nomoremapping.date", startDate);
     28            Main.pref.putLong("nomoremapping.hash", lastHash);
     29        }
     30        long days = Math.max(today - startDate, 0) / (60*60*24);
     31        String message;
     32        if( days == 0 )
     33            message = "Make it one!";
     34        else if( days < 7 )
     35            message = "Keep going!";
     36        else if( days < 31 )
     37            message = "You're good. Keep on!";
     38        else
     39            message = "You don't use Potlach instead, do you?";
     40        String intro = tr("Days without mapping: {0}.", days);
     41        String prefs;
     42        try {
     43             prefs = Main.pref.getPreferenceFile().getCanonicalPath();
     44        } catch( Exception e ) {
     45            prefs = Main.pref.getPreferenceFile().getAbsolutePath();
     46        }
     47        String howto = days > 0 ? "" : "\n\n" + tr("(To miserably continue mapping, edit out no_more_mapping\nfrom {0})", prefs);
     48        JOptionPane.showMessageDialog(Main.parent, intro + " " + message + howto, "No More Mapping", JOptionPane.INFORMATION_MESSAGE);
    1549        System.exit(0);
    1650    }
Note: See TracChangeset for help on using the changeset viewer.