| 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 technology preview with support for <i>API 0.5</i>.</h2>" +
|
|---|
| 51 | "<h3>API 0.5 supports object relationships, and segments have been removed.</h3>" +
|
|---|
| 52 | "<h3>This version is hard-coded to use the API 0.5 running on <i>openstreetmap.gryph.de</i> which has data from a recent planet file."+
|
|---|
| 53 | "<br>Please be gentle with that machine and request only moderate bounding boxes.<br>" +
|
|---|
| 54 | "<br>Username and password are also hardcoded, so your real username and password are not transmitted.<br>" +
|
|---|
| 55 | "</h3>"), GBC.eol());
|
|---|
| 56 |
|
|---|
| 57 | addLine("wiki", "Read the [Wiki page on API 0.5]");
|
|---|
| 58 | addGettingStarted();
|
|---|
| 59 | addGettingHelp();
|
|---|
| 60 |
|
|---|
| 61 | panel.add(GBC.glue(0,140), GBC.eol());
|
|---|
| 62 | add(panel);
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | public void addGettingStarted() {
|
|---|
| 66 | addCategory(tr("Getting Started"));
|
|---|
| 67 | addLine("download",tr("[Download] some data from the OSM server"));
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | public void addGettingHelp() {
|
|---|
| 71 | addCategory(tr("Getting Help"));
|
|---|
| 72 | addLine("help",tr("Open the [online help] (english only)"));
|
|---|
| 73 | addLine("tutorial",tr("Watch some [tutorial videos]"));
|
|---|
| 74 | addLine("mailinglist",tr("Join the newbie [mailing list]"));
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | public void addCategory(String category) {
|
|---|
| 78 | panel.add(new JLabel("<html><h1>"+category+"</h1></html>"), GBC.eop().fill(GBC.HORIZONTAL).insets(0,20,0,0));
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | public void addLine(String action, String text) {
|
|---|
| 82 | JButton button = new JButton(ImageProvider.get("getting_started"));
|
|---|
| 83 | button.setBorder(null);
|
|---|
| 84 | button.addActionListener(this);
|
|---|
| 85 | button.setActionCommand(action);
|
|---|
| 86 | panel.add(button, GBC.std().insets(40,0,15,0));
|
|---|
| 87 | panel.add(new LinkLabel(text,action),GBC.eol());
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | public void actionPerformed(ActionEvent e) {
|
|---|
| 92 | if (e.getActionCommand().equals("download"))
|
|---|
| 93 | Main.main.menu.download.actionPerformed(e);
|
|---|
| 94 | else if (e.getActionCommand().equals("help"))
|
|---|
| 95 | Main.main.menu.help.actionPerformed(e);
|
|---|
| 96 | else if (e.getActionCommand().equals("wiki"))
|
|---|
| 97 | OpenBrowser.displayUrl("http://wiki.openstreetmap.org/index.php?title=OSM_Protocol_Version_0.5");
|
|---|
| 98 | else if (e.getActionCommand().equals("tutorial"))
|
|---|
| 99 | OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
|
|---|
| 100 | else if (e.getActionCommand().equals("mailinglist"))
|
|---|
| 101 | OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
|
|---|
| 102 | }
|
|---|
| 103 | }
|
|---|