source: josm/branch/0.5/src/org/openstreetmap/josm/gui/GettingStarted.java@ 329

Last change on this file since 329 was 329, checked in by framm, 17 years ago

This commit is a manual merge of all changes that have been made to
the intermediate "core_0.5" branch on the main OSM repository,
bevore JOSM was moved to openstreetmap.de.

Changes incorporated here:

r4464@svn.openstreetmap.org
r4466@svn.openstreetmap.org
r4468@svn.openstreetmap.org
r4469@svn.openstreetmap.org
r4479@svn.openstreetmap.org

File size: 3.9 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.GridBagLayout;
7import java.awt.event.ActionEvent;
8import java.awt.event.ActionListener;
9
10import javax.swing.JButton;
11import javax.swing.JEditorPane;
12import javax.swing.JLabel;
13import javax.swing.JPanel;
14import javax.swing.event.HyperlinkEvent;
15import javax.swing.event.HyperlinkListener;
16
17import org.openstreetmap.josm.Main;
18import org.openstreetmap.josm.tools.GBC;
19import org.openstreetmap.josm.tools.ImageProvider;
20import org.openstreetmap.josm.tools.OpenBrowser;
21
22public 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}
Note: See TracBrowser for help on using the repository browser.