source: josm/trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/WebMarker.java@ 1169

Last change on this file since 1169 was 1169, checked in by stoecker, 15 years ago

removed usage of tab stops

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui.layer.markerlayer;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.net.URL;
8
9import javax.swing.JOptionPane;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.data.coor.LatLon;
13import org.openstreetmap.josm.tools.OpenBrowser;
14
15/**
16 * Marker class with Web URL activation.
17 *
18 * @author Frederik Ramm <frederik@remote.org>
19 *
20 */
21public class WebMarker extends ButtonMarker {
22
23 public URL webUrl;
24
25 public static WebMarker create (LatLon ll, String url, MarkerLayer parentLayer, double time, double offset) {
26 try {
27 return new WebMarker(ll, new URL(url), parentLayer, time, offset);
28 } catch (Exception ex) {
29 return null;
30 }
31 }
32
33 private WebMarker(LatLon ll, URL webUrl, MarkerLayer parentLayer, double time, double offset) {
34 super(ll, "web.png", parentLayer, time, offset);
35 this.webUrl = webUrl;
36 }
37
38 @Override public void actionPerformed(ActionEvent ev) {
39 String error = OpenBrowser.displayUrl(webUrl.toString());
40 if (error != null) {
41 JOptionPane.showMessageDialog(Main.parent,
42 "<html><b>" +
43 tr("There was an error while trying to display the URL for this marker") +
44 "</b><br>" + tr("(URL was: ") + webUrl.toString() + ")" + "<br>" + error,
45 tr("Error displaying URL"), JOptionPane.ERROR_MESSAGE);
46 }
47 }
48}
Note: See TracBrowser for help on using the repository browser.