source: josm/trunk/src/org/openstreetmap/josm/gui/GettingStarted.java@ 574

Last change on this file since 574 was 574, checked in by david, 16 years ago

advertise audio mapping

File size: 5.1 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Dimension;
7import java.awt.GridBagLayout;
8import java.awt.event.ActionEvent;
9import java.awt.event.ActionListener;
10
11import javax.swing.JButton;
12import javax.swing.JEditorPane;
13import javax.swing.JLabel;
14import javax.swing.JPanel;
15import javax.swing.JTextField;
16import javax.swing.event.HyperlinkEvent;
17import javax.swing.event.HyperlinkListener;
18
19import org.openstreetmap.josm.Main;
20import org.openstreetmap.josm.tools.GBC;
21import org.openstreetmap.josm.tools.ImageProvider;
22import org.openstreetmap.josm.tools.OpenBrowser;
23
24public class GettingStarted extends JPanel implements ActionListener {
25
26 private JPanel panel;
27
28 public class LinkLabel extends JEditorPane implements HyperlinkListener {
29 private String action;
30 public LinkLabel(String text, String action) {
31 this.action = action;
32 String normalized = text.replaceAll("\\[([^\\]]*)\\]", "$1");
33 String link = "<html><h3>"+text.replaceAll("\\[([^\\]]*)\\]", "<a href='"+action+"'>$1</a>")+"</h3></html>";
34 setContentType("text/html");
35 setText(link);
36 setToolTipText(normalized);
37 setEditable(false);
38 setOpaque(false);
39 addHyperlinkListener(this);
40 }
41 public void hyperlinkUpdate(HyperlinkEvent e) {
42 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
43 actionPerformed(new ActionEvent(e.getSource(), 0, action));
44 }
45 }
46
47 public GettingStarted() {
48 super(new GridBagLayout());
49
50 panel = new JPanel(new GridBagLayout());
51
52 panel.add(new JLabel(tr("<html><h2>You are running the latest JOSM version with built-in mappaint support.</h2>" +
53 "<h3>The mappaint plugin is no longer necessary and has been removed from your configuration<br>" +
54 "file (if it was present). You can now switch between the \"classic\" display and the mappaint<br>" +
55 "style by toggling the \"Wireframe\" option in the \"View\" menu.</h3>" +
56 "<h3>If you have not used new JOSM versions for a while, you will also discover that this JOSM<br>" +
57 "is \"modeless\". It (almost) does away with the old edit modes, like \"add node and connect\" etc.;<br>"+
58 "instead, there are only four modes: zoom, select, edit, and delete. The edit mode will do what<br>"+
59 "you want in most cases (also see the mini help about modifier keys at the bottom of the screen)." +
60 "</h3>")), GBC.eol());
61
62 // remove these two keys from preferences if present
63 boolean changePrefs = ! (
64 "0.5".equals(Main.pref.get("osm-server.version", "0.5")) &&
65 "0.5".equals(Main.pref.get("osm-server.additionalVersions", "0.5"))
66 );
67
68 if (changePrefs) {
69 Main.pref.put("osm-server.version", null);
70 Main.pref.put("osm-server.additional-versions", null);
71 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());
72 }
73
74 addLine("wiki", tr("Read the [Wiki page on API 0.5]"));
75
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 }
90
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("wiki"))
119 OpenBrowser.displayUrl("http://wiki.openstreetmap.org/index.php?title=OSM_Protocol_Version_0.5");
120 else if (e.getActionCommand().equals("tutorial"))
121 OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
122 else if (e.getActionCommand().equals("mailinglist"))
123 OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
124 }
125}
Note: See TracBrowser for help on using the repository browser.