Changeset 1879 in josm for trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
- Timestamp:
- 2009-08-02T14:36:40+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r1755 r1879 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 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 16 7 import java.awt.BorderLayout; 17 8 import java.awt.EventQueue; 18 9 19 import javax.swing.JScrollPane;20 10 import javax.swing.JEditorPane; 21 11 import javax.swing.JPanel; 12 import javax.swing.JScrollPane; 13 import javax.swing.border.EmptyBorder; 22 14 import javax.swing.event.HyperlinkEvent; 23 15 import javax.swing.event.HyperlinkListener; 24 import javax.swing.border.EmptyBorder;25 16 26 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.actions.AboutAction; 27 19 import org.openstreetmap.josm.io.CacheCustomContent; 28 20 import org.openstreetmap.josm.tools.LanguageInfo; 29 21 import org.openstreetmap.josm.tools.OpenBrowser; 30 22 import org.openstreetmap.josm.tools.WikiReader; 31 import org.openstreetmap.josm.actions.AboutAction;32 23 33 24 public class GettingStarted extends JPanel { 34 25 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"; 39 28 40 29 public class LinkGeneral extends JEditorPane implements HyperlinkListener { … … 46 35 addHyperlinkListener(this); 47 36 } 37 48 38 public void hyperlinkUpdate(HyperlinkEvent e) { 49 39 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { … … 56 46 * Grabs current MOTD from cache or webpage and parses it. 57 47 */ 58 private class assignContent extends CacheCustomContent {59 public assignContent() {48 private class MotdContent extends CacheCustomContent { 49 public MotdContent() { 60 50 super("motd.html", CacheCustomContent.INTERVAL_DAILY); 61 51 } … … 68 58 * @see org.openstreetmap.josm.io.CacheCustomContent#updateData() 69 59 */ 60 @Override 70 61 protected byte[] updateData() { 71 62 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())); 84 68 } 85 69 // Save this to prefs in case JOSM is updated so MOTD can be refreshed … … 98 82 // 1. Not yet written - but so isn't the interval variable, so it gets updated anyway 99 83 // 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. 101 85 return (Main.pref.getInteger("cache.motd.html.version", -999) == myVersion) 102 86 && Main.pref.get("cache.motd.html.lang").equals(myLang); … … 105 89 106 90 /** 107 * Initializes getting the MOTD as well as enabling the FileDrop Listener. 108 * Displays a messagewhile 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. 109 93 */ 110 94 public GettingStarted() { 111 95 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>"); 121 98 JScrollPane scroller = new JScrollPane(lg); 122 scroller.setViewportBorder(new EmptyBorder(10, 100,10,100));99 scroller.setViewportBorder(new EmptyBorder(10, 100, 10, 100)); 123 100 add(scroller, BorderLayout.CENTER); 124 101 … … 126 103 Thread t = new Thread(new Runnable() { 127 104 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 } 130 108 131 109 EventQueue.invokeLater(new Runnable() { 132 110 public void run() { 133 lg.setText(content); 134 //lg.moveCaretPosition(0);111 lg.setText(content); 112 // lg.moveCaretPosition(0); 135 113 } 136 114 });
Note:
See TracChangeset
for help on using the changeset viewer.
