1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-21 10:52:14 +01:00
Arduino/app/src/cc/arduino/UpdatableBoardsLibsFakeURLsHandler.java

46 lines
1.1 KiB
Java
Raw Normal View History

package cc.arduino;
import processing.app.Base;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.net.URL;
public class UpdatableBoardsLibsFakeURLsHandler implements HyperlinkListener {
private static final String BOARDSMANAGER = "boardsmanager";
private static final String LIBRARYMANAGER = "librarymanager";
private final Base base;
public UpdatableBoardsLibsFakeURLsHandler(Base base) {
this.base = base;
}
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
return;
}
URL url = event.getURL();
if (BOARDSMANAGER.equals(url.getHost())) {
try {
base.openBoardsManager("", "DropdownUpdatableCoresItem");
} catch (Exception e) {
e.printStackTrace();
}
return;
}
if (LIBRARYMANAGER.equals(url.getHost())) {
base.openLibraryManager("DropdownUpdatableLibrariesItem");
return;
}
throw new IllegalArgumentException(url.getHost() + " is invalid");
}
}