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

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