1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

Extend UpdatableBoardsLibsFakeURLsHandler to handle real links

This commit is contained in:
Martino Facchin 2017-01-05 12:56:57 +01:00
parent 97fd81ac0c
commit 58eeaafde1

View File

@ -34,6 +34,10 @@ import processing.app.Base;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.net.URL;
import java.net.URI;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URISyntaxException;
public class UpdatableBoardsLibsFakeURLsHandler implements HyperlinkListener {
@ -71,6 +75,18 @@ public class UpdatableBoardsLibsFakeURLsHandler implements HyperlinkListener {
return;
}
if(Desktop.isDesktopSupported())
{
try {
Desktop.getDesktop().browse(url.toURI());
return;
} catch (IOException e) {
throw new IllegalArgumentException(url.getHost() + " is invalid");
} catch (URISyntaxException e) {
throw new IllegalArgumentException(url.getHost() + " is invalid");
}
}
throw new IllegalArgumentException(url.getHost() + " is invalid");
}