00001 package edu.stanford.hci.r3.actions.types;
00002
00003 import java.net.URL;
00004
00005 import net.sf.wraplog.SystemLogger;
00006 import edu.stanford.ejalbert.BrowserLauncher;
00007 import edu.stanford.ejalbert.exception.BrowserLaunchingExecutionException;
00008 import edu.stanford.ejalbert.exception.BrowserLaunchingInitializingException;
00009 import edu.stanford.ejalbert.exception.UnsupportedOperatingSystemException;
00010 import edu.stanford.hci.r3.actions.R3Action;
00011
00024 public class OpenURL2Action implements R3Action {
00025
00029 public static final String FIREFOX = "FIREFOX";
00030
00031 public static final String IE = "IE";
00032
00033 private String browser;
00034
00035 private URL url;
00036
00040 public OpenURL2Action(URL theURL) {
00041 this(theURL, null);
00042 }
00043
00050 public OpenURL2Action(URL theURL, String targetBrowser) {
00051 url = theURL;
00052 browser = targetBrowser;
00053 }
00054
00055 public void invoke() {
00056 try {
00057 BrowserLauncher b = new BrowserLauncher(new SystemLogger());
00058
00059
00060 if (browser == null) {
00061
00062 b.openURLinBrowser(url.toString());
00063 } else {
00064 b.openURLinBrowser(browser, url.toString());
00065 }
00066 } catch (BrowserLaunchingInitializingException e) {
00067 e.printStackTrace();
00068 } catch (UnsupportedOperatingSystemException e) {
00069 e.printStackTrace();
00070 } catch (BrowserLaunchingExecutionException e) {
00071 e.printStackTrace();
00072 }
00073 }
00074
00075 }