package com.onaro.util.launch; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import com.onaro.sanscreen.client.MainDirector; /** * Action class that will launch a URL when the action is performed. * @author jmyers * */ public class LaunchUrlAction extends AbstractAction { private static final long serialVersionUID = 1L; private final LaunchUrl launchUrl; /** * Create an action to launch the given absolute url * @param displayName the display name to use for this action * @param url the absolute url to launch */ public LaunchUrlAction(String displayName, String url) { this(displayName, url, false); } /** * Create an action to launch the given url. * @param displayName the display name to use for this action * @param url the relative or absolute url to launch * @param isRelativeToServer pass true when the url is relative to the server. */ public LaunchUrlAction(String displayName, String url, boolean isRelativeToServer) { putValue(NAME, displayName); if (isRelativeToServer) { url = LaunchUrl.makeUrlRelativeToServer(url); } launchUrl = new LaunchUrl(url); } @Override public void actionPerformed(ActionEvent e) { MainDirector.submit(launchUrl); } }