001/* 002 * PDB web development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * 015 * Created on Jul 21, 2009 016 * Created by ap3 017 * 018 */ 019 020package org.biojava.nbio.structure.align.webstart; 021 022import org.slf4j.Logger; 023import org.slf4j.LoggerFactory; 024 025import java.net.MalformedURLException; 026import java.net.URL; 027 028 029public class BrowserOpener { 030 031 private static final Logger logger = LoggerFactory.getLogger(BrowserOpener.class); 032 033 /** open a URL in the browser that was used to launch SPICE 034 * 035 * @param url URL to be opened 036 * @return true if this was successfull 037 */ 038 public static boolean showDocument(URL url) 039 { 040 if ( url != null ){ 041 boolean success = JNLPProxy.showDocument(url); 042 if ( ! success) 043 logger.info("could not open URL "+url+" in browser. check your config or browser version."); 044 return success; 045 046 } 047 else 048 return false; 049 } 050 051 052 /** open a URL in the browser that was used to launch SPICE 053 * 054 * @param urlstring string represntation of URL to be opened 055 * @return true if this was successfull 056 */ 057 public static boolean showDocument(String urlstring){ 058 try{ 059 URL url = new URL(urlstring); 060 061 return showDocument(url); 062 } catch (MalformedURLException e){ 063 logger.warn("malformed URL {}", urlstring, e); 064 return false; 065 } 066 } 067 068} 069