Ignore:
Timestamp:
2009-08-02T14:36:40+02:00 (17 years ago)
Author:
Gubaer
Message:

towards a fix for #3142: JOSM applet class no longer functional

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r1755 r1879  
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
    7 import java.io.IOException;
    8 import java.util.ArrayList;
    9 import java.util.concurrent.Executors;
    10 import java.util.concurrent.ExecutorService;
    11 import java.util.concurrent.Callable;
    12 import java.util.concurrent.Future;
    13 import java.util.regex.Matcher;
    14 import java.util.regex.Pattern;
    15 
    167import java.awt.BorderLayout;
    178import java.awt.EventQueue;
    189
    19 import javax.swing.JScrollPane;
    2010import javax.swing.JEditorPane;
    2111import javax.swing.JPanel;
     12import javax.swing.JScrollPane;
     13import javax.swing.border.EmptyBorder;
    2214import javax.swing.event.HyperlinkEvent;
    2315import javax.swing.event.HyperlinkListener;
    24 import javax.swing.border.EmptyBorder;
    2516
    2617import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.actions.AboutAction;
    2719import org.openstreetmap.josm.io.CacheCustomContent;
    2820import org.openstreetmap.josm.tools.LanguageInfo;
    2921import org.openstreetmap.josm.tools.OpenBrowser;
    3022import org.openstreetmap.josm.tools.WikiReader;
    31 import org.openstreetmap.josm.actions.AboutAction;
    3223
    3324public class GettingStarted extends JPanel {
    3425    private String content = "";
    35     static private String styles = "<style type=\"text/css\">\n"+
    36             "body { font-family: sans-serif; font-weight: bold; }\n"+
    37             "h1 {text-align: center;}\n"+
    38             "</style>\n";
     26    static private String styles = "<style type=\"text/css\">\n"
     27        + "body { font-family: sans-serif; font-weight: bold; }\n" + "h1 {text-align: center;}\n" + "</style>\n";
    3928
    4029    public class LinkGeneral extends JEditorPane implements HyperlinkListener {
     
    4635            addHyperlinkListener(this);
    4736        }
     37
    4838        public void hyperlinkUpdate(HyperlinkEvent e) {
    4939            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
     
    5646     * Grabs current MOTD from cache or webpage and parses it.
    5747     */
    58     private class assignContent extends CacheCustomContent {
    59         public assignContent() {
     48    private class MotdContent extends CacheCustomContent {
     49        public MotdContent() {
    6050            super("motd.html", CacheCustomContent.INTERVAL_DAILY);
    6151        }
     
    6858         * @see org.openstreetmap.josm.io.CacheCustomContent#updateData()
    6959         */
     60        @Override
    7061        protected byte[] updateData() {
    7162            String motd = new WikiReader().readLang("StartupPage");
    72             if(motd.length() == 0)
    73             {
    74                 motd = "<html>" + styles + "<body><h1>" +
    75                 "JOSM - " + tr("Java OpenStreetMap Editor") +
    76                 "</h1>\n<h2 align=\"center\">(" +
    77                 tr("Message of the day not available") +
    78                 ")</h2></html>";
    79             }
    80             else
    81             {
    82                 motd = motd.replace("<!-- VERSION -->", tr("- running version is {0}",
    83                 AboutAction.getVersionString()));
     63            if (motd.length() == 0) {
     64                motd = "<html>" + styles + "<body><h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")
     65                + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>";
     66            } else {
     67                motd = motd.replace("<!-- VERSION -->", tr("- running version is {0}", AboutAction.getVersionString()));
    8468            }
    8569            // Save this to prefs in case JOSM is updated so MOTD can be refreshed
     
    9882            // 1. Not yet written - but so isn't the interval variable, so it gets updated anyway
    9983            // 2. Cannot be written (e.g. while developing). Obviously we don't want to update
    100             //    everytime because of something we can't read.
     84            // everytime because of something we can't read.
    10185            return (Main.pref.getInteger("cache.motd.html.version", -999) == myVersion)
    10286            && Main.pref.get("cache.motd.html.lang").equals(myLang);
     
    10589
    10690    /**
    107      * Initializes getting the MOTD as well as enabling the FileDrop Listener.
    108      * Displays a message while the MOTD is downloading.
     91     * Initializes getting the MOTD as well as enabling the FileDrop Listener. Displays a message
     92     * while the MOTD is downloading.
    10993     */
    11094    public GettingStarted() {
    11195        super(new BorderLayout());
    112         final LinkGeneral lg = new LinkGeneral(
    113             "<html>" +
    114             styles +
    115             "<h1>" +
    116             "JOSM - " +
    117             tr("Java OpenStreetMap Editor") +
    118             "</h1><h2 align=\"center\">" +
    119             tr("Downloading \"Message of the day\"") +
    120             "</h2>");
     96        final LinkGeneral lg = new LinkGeneral("<html>" + styles + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")
     97                + "</h1><h2 align=\"center\">" + tr("Downloading \"Message of the day\"") + "</h2>");
    12198        JScrollPane scroller = new JScrollPane(lg);
    122         scroller.setViewportBorder(new EmptyBorder(10,100,10,100));
     99        scroller.setViewportBorder(new EmptyBorder(10, 100, 10, 100));
    123100        add(scroller, BorderLayout.CENTER);
    124101
     
    126103        Thread t = new Thread(new Runnable() {
    127104            public void run() {
    128                 if (content.length() == 0 && Main.pref.getBoolean("help.displaymotd", true))
    129                     content = new assignContent().updateIfRequiredString();
     105                if (content.length() == 0 && Main.pref.getBoolean("help.displaymotd", true)) {
     106                    content = new MotdContent().updateIfRequiredString();
     107                }
    130108
    131109                EventQueue.invokeLater(new Runnable() {
    132110                    public void run() {
    133                        lg.setText(content);
    134                        //lg.moveCaretPosition(0);
     111                        lg.setText(content);
     112                        // lg.moveCaretPosition(0);
    135113                    }
    136114                });
Note: See TracChangeset for help on using the changeset viewer.