001 // License: GPL. Copyright 2007 by Immanuel Scholz and others 002 package org.openstreetmap.josm.gui.layer.markerlayer; 003 004 import static org.openstreetmap.josm.tools.I18n.tr; 005 006 import java.awt.event.ActionEvent; 007 import java.net.URL; 008 009 import javax.swing.JOptionPane; 010 011 import org.openstreetmap.josm.Main; 012 import org.openstreetmap.josm.data.coor.LatLon; 013 import org.openstreetmap.josm.tools.OpenBrowser; 014 015 /** 016 * Marker class with Web URL activation. 017 * 018 * @author Frederik Ramm <frederik@remote.org> 019 * 020 */ 021 public class WebMarker extends ButtonMarker { 022 023 public final URL webUrl; 024 025 public WebMarker(LatLon ll, URL webUrl, MarkerLayer parentLayer, double time, double offset) { 026 super(ll, "web.png", parentLayer, time, offset); 027 this.webUrl = webUrl; 028 } 029 030 @Override public void actionPerformed(ActionEvent ev) { 031 String error = OpenBrowser.displayUrl(webUrl.toString()); 032 if (error != null) { 033 JOptionPane.showMessageDialog(Main.parent, 034 "<html><b>" + 035 tr("There was an error while trying to display the URL for this marker") + 036 "</b><br>" + tr("(URL was: ") + webUrl.toString() + ")" + "<br>" + error, 037 tr("Error displaying URL"), JOptionPane.ERROR_MESSAGE); 038 } 039 } 040 }