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

Last change on this file since 346 was 346, checked in by framm, 17 years ago
  • smaller fonts for GettingStarted screen
File size: 4.5 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.Dimension;
7import java.awt.GridBagLayout;
8import java.awt.event.ActionEvent;
9import java.awt.event.ActionListener;
10
11import javax.swing.JButton;
12import javax.swing.JEditorPane;
13import javax.swing.JLabel;
14import javax.swing.JPanel;
15import javax.swing.JTextField;
16import javax.swing.event.HyperlinkEvent;
17import javax.swing.event.HyperlinkListener;
18
19import org.openstreetmap.josm.Main;
20import org.openstreetmap.josm.tools.GBC;
21import org.openstreetmap.josm.tools.ImageProvider;
22import org.openstreetmap.josm.tools.OpenBrowser;
23
24public class GettingStarted extends JPanel implements ActionListener {
25
26 private JPanel panel;
27
28 public class LinkLabel extends JEditorPane implements HyperlinkListener {
29 private String action;
30 public LinkLabel(String text, String action) {
31 this.action = action;
32 String normalized = text.replaceAll("\\[([^\\]]*)\\]", "$1");
33 String link = "<html><h3>"+text.replaceAll("\\[([^\\]]*)\\]", "<a href='"+action+"'>$1</a>")+"</h3></html>";
34 setContentType("text/html");
35 setText(link);
36 setToolTipText(normalized);
37 setEditable(false);
38 setOpaque(false);
39 addHyperlinkListener(this);
40 }
41 public void hyperlinkUpdate(HyperlinkEvent e) {
42 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
43 actionPerformed(new ActionEvent(e.getSource(), 0, action));
44 }
45 }
46
47 public GettingStarted() {
48 super(new GridBagLayout());
49
50 panel = new JPanel(new GridBagLayout());
51
52 panel.add(new JLabel("<html><h2>You are running the new JOSM version compatible with the 0.5 API.</h2>" +
53 "<h3>You cannot load old OSM files with this version, but there are converter scripts to make your 0.4 files 0.5 compatible.</h3>"+
54 "<h3>The JOSM interface hasn't changed a lot: Segments are gone, and Relations have been added.<br>You will find general information about the changes on the OSM wiki,<br>and there's a page on working with relations in the JOSM online help." +
55 "</h3>"), GBC.eol());
56
57 // remove these two keys from preferences if present
58 boolean changePrefs = ! (
59 "0.5".equals(Main.pref.get("osm-server.version", "0.5")) &&
60 "0.5".equals(Main.pref.get("osm-server.additionalVersions", "0.5"))
61 );
62
63 if (changePrefs) {
64 Main.pref.put("osm-server.version", null);
65 Main.pref.put("osm-server.additional-versions", null);
66 panel.add(new JLabel("<html><h3>Your preferences have been changed by removing <b>osm-server.version</b> and/or <b>osm-server.additional-versions</b> which were still referring to 0.4.</h3></html>"), GBC.eol());
67 }
68
69 addLine("wiki", "Read the [Wiki page on API 0.5]");
70 addGettingStarted();
71 addGettingHelp();
72
73 panel.add(GBC.glue(0,70), GBC.eol());
74 //panel.setMinimumSize(new Dimension(400, 600));
75 add(panel);
76 }
77
78 public void addGettingStarted() {
79 addCategory(tr("Getting Started"));
80 addLine("download",tr("[Download] some data from the OSM server"));
81 }
82
83 public void addGettingHelp() {
84 addCategory(tr("Getting Help"));
85 addLine("help",tr("Open the [online help] (english only)"));
86 addLine("tutorial",tr("Watch some [tutorial videos]"));
87 addLine("mailinglist",tr("Join the newbie [mailing list]"));
88 }
89
90 public void addCategory(String category) {
91 panel.add(new JLabel("<html><h2>"+category+"</h2></html>"), GBC.eol().fill(GBC.HORIZONTAL).insets(0,20,0,0));
92 }
93
94 public void addLine(String action, String text) {
95 JButton button = new JButton(ImageProvider.get("getting_started"));
96 button.setBorder(null);
97 button.addActionListener(this);
98 button.setActionCommand(action);
99 panel.add(button, GBC.std().insets(20,0,5,0));
100 panel.add(new LinkLabel(text,action),GBC.eol());
101 }
102
103
104 public void actionPerformed(ActionEvent e) {
105 if (e.getActionCommand().equals("download"))
106 Main.main.menu.download.actionPerformed(e);
107 else if (e.getActionCommand().equals("help"))
108 Main.main.menu.help.actionPerformed(e);
109 else if (e.getActionCommand().equals("wiki"))
110 OpenBrowser.displayUrl("http://wiki.openstreetmap.org/index.php?title=OSM_Protocol_Version_0.5");
111 else if (e.getActionCommand().equals("tutorial"))
112 OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
113 else if (e.getActionCommand().equals("mailinglist"))
114 OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
115 }
116}
Note: See TracBrowser for help on using the repository browser.