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

Last change on this file since 266 was 266, checked in by imi, 17 years ago
  • added "Getting Started" welcome screen
  • added latest JOSM version in About dialog
  • set "draw boundaries" to on by default
File size: 3.0 KB
Line 
1package org.openstreetmap.josm.gui;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.awt.GridBagLayout;
6import java.awt.event.ActionEvent;
7import java.awt.event.ActionListener;
8
9import javax.swing.JButton;
10import javax.swing.JEditorPane;
11import javax.swing.JLabel;
12import javax.swing.JPanel;
13import javax.swing.event.HyperlinkEvent;
14import javax.swing.event.HyperlinkListener;
15
16import org.openstreetmap.josm.Main;
17import org.openstreetmap.josm.tools.GBC;
18import org.openstreetmap.josm.tools.ImageProvider;
19import org.openstreetmap.josm.tools.OpenBrowser;
20
21public class GettingStarted extends JPanel implements ActionListener {
22
23 private JPanel panel;
24
25 public class LinkLabel extends JEditorPane implements HyperlinkListener {
26 private String action;
27 public LinkLabel(String text, String action) {
28 this.action = action;
29 String normalized = text.replaceAll("\\[([^\\]]*)\\]", "$1");
30 String link = "<html><h2>"+text.replaceAll("\\[([^\\]]*)\\]", "<a href='"+action+"'>$1</a>")+"</h2></html>";
31 setContentType("text/html");
32 setText(link);
33 setToolTipText(normalized);
34 setEditable(false);
35 setOpaque(false);
36 addHyperlinkListener(this);
37 }
38 public void hyperlinkUpdate(HyperlinkEvent e) {
39 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
40 actionPerformed(new ActionEvent(e.getSource(), 0, action));
41 }
42 }
43
44 public GettingStarted() {
45 super(new GridBagLayout());
46
47 panel = new JPanel(new GridBagLayout());
48
49 addGettingStarted();
50 addGettingHelp();
51
52 panel.add(GBC.glue(0,140), GBC.eol());
53 add(panel);
54 }
55
56 public void addGettingStarted() {
57 addCategory(tr("Getting Started"));
58 addLine("download",tr("[Download] some data from the OSM server"));
59 }
60
61 public void addGettingHelp() {
62 addCategory(tr("Getting Help"));
63 addLine("help",tr("Open the [online help] (english only)"));
64 addLine("tutorial",tr("Watch some [tutorial videos]"));
65 addLine("mailinglist",tr("Join the newbie [mailing list]"));
66 }
67
68 public void addCategory(String category) {
69 panel.add(new JLabel("<html><h1>"+category+"</h1></html>"), GBC.eop().fill(GBC.HORIZONTAL).insets(0,20,0,0));
70 }
71
72 public void addLine(String action, String text) {
73 JButton button = new JButton(ImageProvider.get("getting_started"));
74 button.setBorder(null);
75 button.addActionListener(this);
76 button.setActionCommand(action);
77 panel.add(button, GBC.std().insets(40,0,15,0));
78 panel.add(new LinkLabel(text,action),GBC.eol());
79 }
80
81
82 public void actionPerformed(ActionEvent e) {
83 if (e.getActionCommand().equals("download"))
84 Main.main.menu.download.actionPerformed(e);
85 else if (e.getActionCommand().equals("help"))
86 Main.main.menu.help.actionPerformed(e);
87 else if (e.getActionCommand().equals("tutorial"))
88 OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
89 else if (e.getActionCommand().equals("mailinglist"))
90 OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
91 }
92}
Note: See TracBrowser for help on using the repository browser.