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><h3>"+text.replaceAll("\\[([^\\]]*)\\]", "<a href='"+action+"'>$1</a>")+"</h3></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(tr("<html><h2>You are running the latest JOSM version with built-in mappaint support.</h2>" +
|
---|
51 | "<h3>The mappaint plugin is no longer necessary and has been removed from your configuration<br>" +
|
---|
52 | "file (if it was present). You can now switch between the \"classic\" display and the mappaint<br>" +
|
---|
53 | "style by toggling the \"Wireframe\" option in the \"View\" menu.</h3>" +
|
---|
54 | "<h3>If you have not used new JOSM versions for a while, you will also discover that this JOSM<br>" +
|
---|
55 | "is \"modeless\". It (almost) does away with the old edit modes, like \"add node and connect\" etc.;<br>"+
|
---|
56 | "instead, there are only four modes: zoom, select, edit, and delete. The edit mode will do what<br>"+
|
---|
57 | "you want in most cases (also see the mini help about modifier keys at the bottom of the screen)." +
|
---|
58 | "</h3>")), GBC.eol());
|
---|
59 |
|
---|
60 | // remove these two keys from preferences if present
|
---|
61 | boolean changePrefs = ! (
|
---|
62 | "0.5".equals(Main.pref.get("osm-server.version", "0.5")) &&
|
---|
63 | "0.5".equals(Main.pref.get("osm-server.additionalVersions", "0.5"))
|
---|
64 | );
|
---|
65 |
|
---|
66 | if (changePrefs) {
|
---|
67 | Main.pref.put("osm-server.version", null);
|
---|
68 | Main.pref.put("osm-server.additional-versions", null);
|
---|
69 | panel.add(new JLabel(tr("<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());
|
---|
70 | }
|
---|
71 |
|
---|
72 | addLine("wiki", tr("Read the [Wiki page on API 0.5]"));
|
---|
73 |
|
---|
74 | addLine("audio", tr("This version also has built-in support for [Audio Mapping] with continuously recorded sound tracks."));
|
---|
75 |
|
---|
76 | addGettingStarted();
|
---|
77 | addGettingHelp();
|
---|
78 |
|
---|
79 | panel.add(GBC.glue(0,70), GBC.eol());
|
---|
80 | //panel.setMinimumSize(new Dimension(400, 600));
|
---|
81 | add(panel);
|
---|
82 | }
|
---|
83 |
|
---|
84 | public void addGettingStarted() {
|
---|
85 | addCategory(tr("Getting Started"));
|
---|
86 | addLine("download",tr("[Download] some data from the OSM server"));
|
---|
87 | }
|
---|
88 |
|
---|
89 | public void addGettingHelp() {
|
---|
90 | addCategory(tr("Getting Help"));
|
---|
91 | addLine("help",tr("Open the [online help] (english only)"));
|
---|
92 | addLine("mailinglist",tr("Join the newbie [mailing list]"));
|
---|
93 | }
|
---|
94 |
|
---|
95 | public void addCategory(String category) {
|
---|
96 | panel.add(new JLabel("<html><h2>"+category+"</h2></html>"), GBC.eol().fill(GBC.HORIZONTAL).insets(0,20,0,0));
|
---|
97 | }
|
---|
98 |
|
---|
99 | public void addLine(String action, String text) {
|
---|
100 | JButton button = new JButton(ImageProvider.get("getting_started"));
|
---|
101 | button.setBorder(null);
|
---|
102 | button.addActionListener(this);
|
---|
103 | button.setActionCommand(action);
|
---|
104 | panel.add(button, GBC.std().insets(20,0,5,0));
|
---|
105 | panel.add(new LinkLabel(text,action),GBC.eol());
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | public void actionPerformed(ActionEvent e) {
|
---|
110 | if (e.getActionCommand().equals("download"))
|
---|
111 | Main.main.menu.download.actionPerformed(e);
|
---|
112 | else if (e.getActionCommand().equals("help"))
|
---|
113 | Main.main.menu.help.actionPerformed(e);
|
---|
114 | else if (e.getActionCommand().equals("audio"))
|
---|
115 | OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/Help/HowTo/AudioMapping");
|
---|
116 | else if (e.getActionCommand().equals("wiki"))
|
---|
117 | OpenBrowser.displayUrl("http://wiki.openstreetmap.org/index.php?title=OSM_Protocol_Version_0.5");
|
---|
118 | else if (e.getActionCommand().equals("tutorial"))
|
---|
119 | OpenBrowser.displayUrl("http://josm.openstreetmap.de/wiki/TutorialVideos");
|
---|
120 | else if (e.getActionCommand().equals("mailinglist"))
|
---|
121 | OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe");
|
---|
122 | }
|
---|
123 | }
|
---|