1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.GridBagLayout;
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 | import java.awt.event.ActionListener;
|
---|
9 |
|
---|
10 | import javax.swing.JButton;
|
---|
11 | import javax.swing.JEditorPane;
|
---|
12 | import javax.swing.JLabel;
|
---|
13 | import javax.swing.JPanel;
|
---|
14 | import javax.swing.event.HyperlinkEvent;
|
---|
15 | import javax.swing.event.HyperlinkListener;
|
---|
16 |
|
---|
17 | import org.openstreetmap.josm.Main;
|
---|
18 | import org.openstreetmap.josm.tools.GBC;
|
---|
19 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
20 | import org.openstreetmap.josm.tools.OpenBrowser;
|
---|
21 |
|
---|
22 | public class GettingStarted extends JPanel implements ActionListener {
|
---|
23 |
|
---|
24 | private JPanel panel;
|
---|
25 |
|
---|
26 | public class LinkLabel extends JEditorPane implements HyperlinkListener {
|
---|
27 | private String action;
|
---|
28 | public LinkLabel(String text, String action) {
|
---|
29 | this.action = action;
|
---|
30 | String normalized = text.replaceAll("\\[([^\\]]*)\\]", "$1");
|
---|
31 | String link = "<html><h2>"+text.replaceAll("\\[([^\\]]*)\\]", "<a href='"+action+"'>$1</a>")+"</h2></html>";
|
---|
32 | setContentType("text/html");
|
---|
33 | setText(link);
|
---|
34 | setToolTipText(normalized);
|
---|
35 | setEditable(false);
|
---|
36 | setOpaque(false);
|
---|
37 | addHyperlinkListener(this);
|
---|
38 | }
|
---|
39 | public void hyperlinkUpdate(HyperlinkEvent e) {
|
---|
40 | if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
|
---|
41 | actionPerformed(new ActionEvent(e.getSource(), 0, action));
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public GettingStarted() {
|
---|
46 | super(new GridBagLayout());
|
---|
47 |
|
---|
48 | panel = new JPanel(new GridBagLayout());
|
---|
49 |
|
---|
50 | panel.add(new JLabel("<html><h2>You are running a beta version with a brand new feature <i>multiple data layers</i>.</h2>" +
|
---|
51 | "<h3>This is a major change, so expect some bugs, especally with undo/redo and the merging code.<br>" +
|
---|
52 | "If you can't work, downgrade to josm-1.5.jar, available at http://josm.openstreetmap.org/download/josm-1.5.jar<br><br>" +
|
---|
53 | "Imi.</h3>"), GBC.eol());
|
---|
54 |
|
---|
55 | addGettingStarted();
|
---|
56 | addGettingHelp();
|
---|
57 |
|
---|
58 | panel.add(GBC.glue(0,140), GBC.eol());
|
---|
59 | add(panel);
|
---|
60 | }
|
---|
61 |
|
---|
62 | public void addGettingStarted() {
|
---|
63 | addCategory(tr("Getting Started"));
|
---|
64 | addLine("download",tr("[Download] some data from the OSM server"));
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void addGettingHelp() {
|
---|
68 | addCategory(tr("Getting Help"));
|
---|
69 | addLine("help",tr("Open the [online help] (english only)"));
|
---|
70 | addLine("tutorial",tr("Watch some [tutorial videos]"));
|
---|
71 | addLine("mailinglist",tr("Join the newbie [mailing list]"));
|
---|
72 | }
|
---|
73 |
|
---|
74 | public void addCategory(String category) {
|
---|
75 | panel.add(new JLabel("<html><h1>"+category+"</h1></html>"), GBC.eop().fill(GBC.HORIZONTAL).insets(0,20,0,0));
|
---|
76 | }
|
---|
77 |
|
---|
78 | public void addLine(String action, String text) {
|
---|
79 | JButton button = new JButton(ImageProvider.get("getting_started"));
|
---|
80 | button.setBorder(null);
|
---|
81 | button.addActionListener(this);
|
---|
82 | button.setActionCommand(action);
|
---|
83 | panel.add(button, GBC.std().insets(40,0,15,0));
|
---|
84 | panel.add(new LinkLabel(text,action),GBC.eol());
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | public void actionPerformed(ActionEvent e) {
|
---|
89 | if (e.getActionCommand().equals("download"))
|
---|
90 | Main.main.menu.download.actionPerformed(e);
|
---|
91 | else if (e.getActionCommand().equals("help"))
|
---|
92 | Main.main.menu.help.actionPerformed(e);
|
---|
93 | else if (e.getActionCommand().equals("tutorial"))
|
---|
94 | OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
|
---|
95 | else if (e.getActionCommand().equals("mailinglist"))
|
---|
96 | OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
|
---|
97 | }
|
---|
98 | }
|
---|