- Timestamp:
- 2008-05-08T22:07:43+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r487 r623 62 62 } 63 63 64 static public String getVersion() { 65 return version; 66 } 67 64 68 public AboutAction() { 65 69 super(tr("About"), "about",tr("Display the about screen."), KeyEvent.VK_F1, KeyEvent.SHIFT_DOWN_MASK, true); -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r610 r623 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java. awt.GridBagLayout;8 import java. awt.event.ActionEvent;9 import java. awt.event.ActionListener;7 import java.io.IOException; 8 import java.util.regex.Matcher; 9 import java.util.regex.Pattern; 10 10 11 import javax.swing.JButton; 11 import java.awt.BorderLayout; 12 13 import javax.swing.JScrollPane; 12 14 import javax.swing.JEditorPane; 13 import javax.swing.JLabel;14 15 import javax.swing.JPanel; 15 16 import javax.swing.event.HyperlinkEvent; 16 17 import javax.swing.event.HyperlinkListener; 18 import javax.swing.border.EmptyBorder; 17 19 18 20 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.tools.GBC;20 21 import org.openstreetmap.josm.tools.ImageProvider; 21 22 import org.openstreetmap.josm.tools.OpenBrowser; 23 import org.openstreetmap.josm.tools.WikiReader; 24 import org.openstreetmap.josm.actions.AboutAction; 22 25 23 public class GettingStarted extends JPanel implements ActionListener{26 public class GettingStarted extends JPanel { 24 27 25 28 private JPanel panel; 29 static private String content = ""; 26 30 27 public class Link Label extends JEditorPane implements HyperlinkListener {31 public class LinkGeneral extends JEditorPane implements HyperlinkListener { 28 32 private String action; 29 public LinkLabel(String text, String action) { 30 this.action = action; 31 String normalized = text.replaceAll("\\[([^\\]]*)\\]", "$1"); 32 String link = "<html><h3>"+text.replaceAll("\\[([^\\]]*)\\]", "<a href='"+action+"'>$1</a>")+"</h3></html>"; 33 public LinkGeneral(String text) { 33 34 setContentType("text/html"); 34 setText(link); 35 setToolTipText(normalized); 35 setText(text); 36 36 setEditable(false); 37 37 setOpaque(false); … … 39 39 } 40 40 public void hyperlinkUpdate(HyperlinkEvent e) { 41 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 42 actionPerformed(new ActionEvent(e.getSource(), 0, action)); 41 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 42 OpenBrowser.displayUrl(e.getDescription()); 43 } 43 44 } 44 45 } 45 46 46 public GettingStarted() { 47 super(new GridBagLayout()); 48 49 panel = new JPanel(new GridBagLayout()); 50 51 panel.add(new JLabel(tr("<html><h2>You are running the latest JOSM version with some geometry extensions.</h2>" + 52 "<h3>New elements in the status bar will inform you about the orientation and size of the object<br />" + 53 "being drawn. There is a new \"extrude\" mode that you can use to create rectangular shapes.</h3>" + 54 "<h3>There is also a new option in the tools menu that will make existing shapes into proper<br>" + 55 "rectangles. Note that all this is dependent on the projection you're using; you must use<br>"+ 56 "a projection in which rectangles look rectangular and not skewed. Try it out.</h3>"+ 57 "<h3>If you dislike the helper line dangling from the mouse cursor, set the \"draw.helper-line\"<br>"+ 58 "preference to \"false\"."+ 59 "</h3>")), GBC.eol()); 47 private void assignContent() { 48 if (content.length() == 0) { 49 String baseurl = Main.pref.get("help.baseurl", "http://josm.openstreetmap.de"); 50 WikiReader wr = new WikiReader(baseurl); 51 String motdcontent = ""; 52 try { 53 motdcontent = wr.read(baseurl + "/wiki/MessageOfTheDay"); 54 } catch (IOException ioe) { 55 motdcontent = tr("<h2>(Message of the day not available)</h2>"); 56 } 60 57 61 /* 62 boolean changePrefs = ! ( 63 "0.5".equals(Main.pref.get("osm-server.version", "0.5")) && 64 "0.5".equals(Main.pref.get("osm-server.additionalVersions", "0.5")) 65 ); 66 67 if (changePrefs) { 68 Main.pref.put("osm-server.version", null); 69 Main.pref.put("osm-server.additional-versions", null); 70 panel.add(new JLabel(tr("<html><h3>Your preferences have been changed by removing <b>osm-server.version</b> and/or <b>osm-server.additional-versions</b> which were still referring to 0.4.</h3></html>")), GBC.eol()); 58 int myVersion; 59 try { 60 myVersion = Integer.parseInt(AboutAction.getVersion()); 61 } catch (NumberFormatException e) { 62 myVersion = 0; 63 } 64 65 Pattern commentPattern = Pattern.compile("\\<p\\>\\s*\\/\\*[^\\*]*\\*\\/\\s*\\<\\/p\\>", Pattern.CASE_INSENSITIVE|Pattern.DOTALL|Pattern.MULTILINE); 66 Matcher matcherComment = commentPattern.matcher(motdcontent); 67 motdcontent = matcherComment.replaceAll(""); 68 69 /* look for hrefs of the form wiki/MessageOfTheDay>123 where > can also be <,<=,>= and the number is the revision number */ 70 int start = 0; 71 boolean nothingIncluded = true; 72 Pattern versionPattern = Pattern.compile("\\<a[^\\>]*href\\=\\\"([^\\\"]*\\/wiki\\/MessageOfTheDay(\\%3E%3D|%3C%3D|\\%3E|\\%3C)([0-9]+))\\\"[^\\>]*\\>[^\\<]*\\<\\/a\\>", Pattern.CASE_INSENSITIVE|Pattern.DOTALL|Pattern.MULTILINE); 73 Matcher matcher = versionPattern.matcher(motdcontent); 74 matcher.reset(); 75 while (matcher.find()) { 76 int targetVersion = Integer.parseInt(matcher.group(3)); 77 String condition = matcher.group(2); 78 boolean included = false; 79 if (condition.equals("%3E")) { 80 if ((myVersion == 0 || myVersion > targetVersion) && ! Main.pref.getBoolean("motd.gt."+targetVersion)) { 81 Main.pref.put("motd.gt."+targetVersion, true); 82 included = true; 83 } 84 } else if (condition.equals("%3E%3D")) { 85 if ((myVersion == 0 || myVersion > targetVersion) && ! Main.pref.getBoolean("motd.ge."+targetVersion)) { 86 Main.pref.put("motd.ge."+targetVersion, true); 87 included = true; 88 } 89 } else if (condition.equals("%3C")) { 90 included = myVersion < targetVersion; 91 } else { 92 included = myVersion <= targetVersion; 93 } 94 if (matcher.start() > start) { 95 content += motdcontent.substring(start, matcher.start() - 1); 96 } 97 start = matcher.end(); 98 if (included) { 99 try { 100 content += wr.read(matcher.group(1)).replace("<html>", "").replace("</html>", "").replace("<div id=\"searchable\">", "").replace("</div>", ""); 101 nothingIncluded = false; 102 } catch (IOException ioe) { 103 // do nothing 104 } 105 } 106 } 107 if (nothingIncluded) { 108 content += "<div align=\"center\">Watch this space for announcements</div>"; 109 content += "<div align=\"center\" style=\"font-weight: normal\">(remove the \"motd\" entries in Advanced Preferences to see any available announcements next time)</div>"; 110 } 111 content += motdcontent.substring(start); 112 content = content.replace("<html>", "<html><style>\nbody { font-family: sans-serif; font-weight: bold; }\n</style>"); 113 content = content.replace("<h1", "<h1 align=\"center\""); 71 114 } 72 */73 74 addLine("extrudevideo", tr("Short (sound-less) [video] demonstrating the new \"extrude\" feature"));75 115 76 addLine("audio", tr("This version also has built-in support for [Audio Mapping] with continuously recorded sound tracks."));77 78 addGettingStarted();79 addGettingHelp();80 81 panel.add(GBC.glue(0,70), GBC.eol());82 //panel.setMinimumSize(new Dimension(400, 600));83 add(panel);84 }85 86 public void addGettingStarted() {87 addCategory(tr("Getting Started"));88 addLine("download",tr("[Download] some data from the OSM server"));89 116 } 90 117 91 public void addGettingHelp() { 92 addCategory(tr("Getting Help")); 93 addLine("help",tr("Open the [online help] (english only)")); 94 addLine("mailinglist",tr("Join the newbie [mailing list]")); 95 } 96 97 public void addCategory(String category) { 98 panel.add(new JLabel("<html><h2>"+category+"</h2></html>"), GBC.eol().fill(GBC.HORIZONTAL).insets(0,20,0,0)); 99 } 100 101 public void addLine(String action, String text) { 102 JButton button = new JButton(ImageProvider.get("getting_started")); 103 button.setBorder(null); 104 button.addActionListener(this); 105 button.setActionCommand(action); 106 panel.add(button, GBC.std().insets(20,0,5,0)); 107 panel.add(new LinkLabel(text,action),GBC.eol()); 108 } 109 110 111 public void actionPerformed(ActionEvent e) { 112 if (e.getActionCommand().equals("download")) 113 Main.main.menu.download.actionPerformed(e); 114 else if (e.getActionCommand().equals("help")) 115 Main.main.menu.help.actionPerformed(e); 116 else if (e.getActionCommand().equals("audio")) 117 OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/Help/HowTo/AudioMapping"); 118 else if (e.getActionCommand().equals("tutorial")) 119 OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos"); 120 else if (e.getActionCommand().equals("mailinglist")) 121 OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe"); 122 else if (e.getActionCommand().equals("extrudevideo")) 123 OpenBrowser.displayUrl("http://josm.openstreetmap.de/download/tutorials/josm-extrude-feature.mpeg"); 118 public GettingStarted() { 119 super(new BorderLayout()); 120 assignContent(); 121 122 // panel.add(GBC.glue(0,1), GBC.eol()); 123 //panel.setMinimumSize(new Dimension(400, 600)); 124 JScrollPane scroller = new JScrollPane(new LinkGeneral(content)); 125 scroller.setViewportBorder(new EmptyBorder(100,100,10,100)); 126 add(scroller, BorderLayout.CENTER); 124 127 } 125 128 }
Note:
See TracChangeset
for help on using the changeset viewer.