|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.wisc.ssec.mcidasv.util.WebBrowser
public final class WebBrowser
Field Summary | |
---|---|
private static List<String> |
unixBrowsers
Probe Unix-like systems for these browsers, in this order. |
Constructor Summary | |
---|---|
private |
WebBrowser()
None shall instantiate WebBrowser!! |
Method Summary | |
---|---|
static void |
browse(String url)
Attempts to use the system default browser to visit url . |
private static boolean |
canAttemptNewStyle()
There's supposedly a bug lurking that can hang the JVM on Linux if java.net.useSystemProxies is enabled. |
private static boolean |
isMac()
|
private static boolean |
isUnix()
|
private static boolean |
isWindows()
|
static void |
main(String[] args)
|
private static boolean |
openNewStyle(String url)
Uses the new functionality in Desktop to try opening
the browser. |
private static void |
openOldStyle(String url)
Uses Runtime.exec(String) to launch the user's preferred web
browser. |
private static boolean |
tryUserSpecifiedBrowser(String url)
Attempts to launch the browser pointed at by the "idv.browser.path" IDV property, if it has been set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final List<String> unixBrowsers
Constructor Detail |
---|
private WebBrowser()
Method Detail |
---|
public static void browse(String url)
url
. Tries
looking for and executing any browser specified by the IDV property
"idv.browser.path".
If the property wasn't given or there was an error, try the new (as of Java 1.6) way of opening a browser.
If the previous attempts failed (or we're in 1.5), we finally try some more primitive measures.
Note: if you are trying to use this method with a
JTextPane
you may need to turn off editing via
JTextComponent.setEditable(boolean)
.
url
- URL to visit.tryUserSpecifiedBrowser(String)
,
openNewStyle(String)
,
openOldStyle(String)
private static boolean openNewStyle(String url)
Desktop
to try opening
the browser. Because McIDAS-V does not yet require Java 1.6, and
Desktop
was introduced in 1.6, we have to jump through some
reflection hoops.
url
- URL to visit.
true
if things look ok, false
if there
were problems.private static void openOldStyle(String url)
Runtime.exec(String)
to launch the user's preferred web
browser. This method isn't really recommended unless you're stuck with
Java 1.5.
Note that the browsers need to be somewhere in the PATH, as this
method uses the which
command (also needs to be in the PATH!).
url
- URL to visit.private static boolean tryUserSpecifiedBrowser(String url)
url
- URL to open.
true
if the command-line was executed, false
if
either the command-line wasn't launched or "idv.browser.path"
was not set.private static boolean canAttemptNewStyle()
java.net.useSystemProxies
is enabled. Detect whether or not our
configuration may trigger the bug.
true
if everything is ok, false
otherwise.private static boolean isMac()
private static boolean isUnix()
private static boolean isWindows()
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |