1 19 20 package org.netbeans.modules.ant.browsetask; 21 22 import java.io.File ; 23 import java.net.MalformedURLException ; 24 import java.net.URL ; 25 26 import org.apache.tools.ant.*; 27 28 import org.openide.awt.HtmlBrowser; 29 30 34 public class NbBrowse extends Task { 35 36 private String url; 37 public void setUrl(String s) { 38 url = s; 39 } 40 41 private File file; 42 public void setFile(File f) { 43 file = f; 44 } 45 46 public void execute() throws BuildException { 47 if (url != null ^ file == null) throw new BuildException("You must define the url or file attributes", getLocation()); 48 if (url == null) { 49 url = file.toURI().toString(); 50 } 51 log("Browsing: " + url); 52 try { 53 HtmlBrowser.URLDisplayer.getDefault().showURL(new URL (url)); 54 } catch (MalformedURLException e) { 55 throw new BuildException(e, getLocation()); 56 } 57 } 58 59 } 60 | Popular Tags |