forked from I2P_Developers/i2p.i2p
DTG: Use UrlLauncher to launch browser
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
<pathelement location="../../core/java/build/i2p.jar" />
|
||||
<pathelement location="../../installer/lib/wrapper/all/wrapper.jar" />
|
||||
<pathelement location="../../router/java/build/router.jar" />
|
||||
<pathelement location="../systray/java/build/systray.jar" />
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
@ -6,16 +6,15 @@ import java.awt.MenuItem;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingWorker;
|
||||
|
||||
import net.i2p.apps.systray.UrlLauncher;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.desktopgui.router.RouterManager;
|
||||
import net.i2p.desktopgui.util.BrowseException;
|
||||
import net.i2p.desktopgui.util.I2PDesktop;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.PortMapper;
|
||||
@ -433,15 +432,16 @@ class InternalTrayManager extends TrayManager {
|
||||
* and launch the browser at it.
|
||||
*
|
||||
* Modified from I2PTunnelHTTPClientBase.
|
||||
* TODO perhaps move this to a new PortMapper method.
|
||||
*
|
||||
* @since 0.9.26
|
||||
*/
|
||||
private void launchBrowser() {
|
||||
// null args ok
|
||||
UrlLauncher launcher = new UrlLauncher(_context, null, null);
|
||||
String url = _context.portMapper().getConsoleURL();
|
||||
try {
|
||||
I2PDesktop.browse(url);
|
||||
} catch (BrowseException e1) {
|
||||
launcher.openUrl(url);
|
||||
} catch (IOException e1) {
|
||||
log.log(Log.WARN, "Failed to open browser!", e1);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import net.i2p.app.ClientAppManager;
|
||||
import net.i2p.app.ClientAppState;
|
||||
import static net.i2p.app.ClientAppState.*;
|
||||
import net.i2p.desktopgui.router.RouterManager;
|
||||
import net.i2p.desktopgui.util.*;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.app.RouterApp;
|
||||
import net.i2p.util.Log;
|
||||
|
@ -1,23 +0,0 @@
|
||||
package net.i2p.desktopgui.util;
|
||||
|
||||
public class BrowseException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BrowseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BrowseException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public BrowseException(String s, Throwable t) {
|
||||
super(s, t);
|
||||
}
|
||||
|
||||
public BrowseException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package net.i2p.desktopgui.util;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Desktop.Action;
|
||||
import java.net.URI;
|
||||
|
||||
public class I2PDesktop {
|
||||
|
||||
public static void browse(String url) throws BrowseException {
|
||||
if(Desktop.isDesktopSupported()) {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
if(desktop.isSupported(Action.BROWSE)) {
|
||||
try {
|
||||
desktop.browse(new URI(url));
|
||||
} catch (Exception e) {
|
||||
throw new BrowseException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new BrowseException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new BrowseException();
|
||||
}
|
||||
}
|
||||
}
|
@ -388,10 +388,7 @@
|
||||
<copy file="apps/i2ptunnel/java/build/i2ptunnel.war" todir="build/" />
|
||||
</target>
|
||||
|
||||
<target name="buildDesktopGui" depends="buildCore, buildrouter" >
|
||||
<!--
|
||||
<ant dir="apps/desktopgui" target="clean" />
|
||||
-->
|
||||
<target name="buildDesktopGui" depends="buildCore, buildrouter, buildSystray" >
|
||||
<ant dir="apps/desktopgui" target="jar" />
|
||||
<copy file="apps/desktopgui/dist/desktopgui.jar" todir="build/" />
|
||||
</target>
|
||||
|
Reference in New Issue
Block a user