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

Last change on this file since 312 was 312, checked in by imi, 17 years ago
  • fixed bug to allow move of one node
  • removed "new shiny beta" warning
  • fixed uploading data marks as modified when saved before
File size: 3.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.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 addGettingStarted();
51 addGettingHelp();
52
53 panel.add(GBC.glue(0,140), GBC.eol());
54 add(panel);
55 }
56
57 public void addGettingStarted() {
58 addCategory(tr("Getting Started"));
59 addLine("download",tr("[Download] some data from the OSM server"));
60 }
61
62 public void addGettingHelp() {
63 addCategory(tr("Getting Help"));
64 addLine("help",tr("Open the [online help] (english only)"));
65 addLine("tutorial",tr("Watch some [tutorial videos]"));
66 addLine("mailinglist",tr("Join the newbie [mailing list]"));
67 }
68
69 public void addCategory(String category) {
70 panel.add(new JLabel("<html><h1>"+category+"</h1></html>"), GBC.eop().fill(GBC.HORIZONTAL).insets(0,20,0,0));
71 }
72
73 public void addLine(String action, String text) {
74 JButton button = new JButton(ImageProvider.get("getting_started"));
75 button.setBorder(null);
76 button.addActionListener(this);
77 button.setActionCommand(action);
78 panel.add(button, GBC.std().insets(40,0,15,0));
79 panel.add(new LinkLabel(text,action),GBC.eol());
80 }
81
82
83 public void actionPerformed(ActionEvent e) {
84 if (e.getActionCommand().equals("download"))
85 Main.main.menu.download.actionPerformed(e);
86 else if (e.getActionCommand().equals("help"))
87 Main.main.menu.help.actionPerformed(e);
88 else if (e.getActionCommand().equals("tutorial"))
89 OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
90 else if (e.getActionCommand().equals("mailinglist"))
91 OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
92 }
93}
Note: See TracBrowser for help on using the repository browser.