mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Enable links to directly open Lib/Board manager
If a sketch contains a link to http://librarymanager/${dropdown}#${filter} or http://boardmanager/${dropdown}#${filter} (for example http://librarymanager/All#OneWire) Library or Board manager will be opened applying the secified filters
This commit is contained in:
parent
a329731525
commit
b99ab40ba2
@ -53,22 +53,28 @@ public class UpdatableBoardsLibsFakeURLsHandler implements HyperlinkListener {
|
||||
}
|
||||
|
||||
URL url = event.getURL();
|
||||
openBoardLibManager(url);
|
||||
}
|
||||
|
||||
public void openBoardLibManager(URL url) {
|
||||
if (BOARDSMANAGER.equals(url.getHost())) {
|
||||
try {
|
||||
base.openBoardsManager("", "DropdownUpdatableCoresItem");
|
||||
base.openBoardsManager(url.getRef() == null ? "": url.getRef() , url.getPath() == null ? "" : url.getPath().replace("/", ""));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(url.getRef() + " " + url.getHost() + " " + url.getPath());
|
||||
|
||||
if (LIBRARYMANAGER.equals(url.getHost())) {
|
||||
base.openLibraryManager("DropdownUpdatableLibrariesItem");
|
||||
base.openLibraryManager(url.getRef() == null ? "": url.getRef() , url.getPath() == null ? "" : url.getPath().replace("/", ""));
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(url.getHost() + " is invalid");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
|
||||
String text;
|
||||
if (updatableLibraries > 0 && updatablePlatforms <= 0) {
|
||||
text = I18n.format(tr("Updates available for some of your {0}libraries{1}"), "<a href=\"http://librarymanager\">", "</a>");
|
||||
text = I18n.format(tr("Updates available for some of your {0}libraries{1}"), "<a href=\"http://librarymanager/DropdownUpdatableLibrariesItem\">", "</a>");
|
||||
} else if (updatableLibraries <= 0 && updatablePlatforms > 0) {
|
||||
text = I18n.format(tr("Updates available for some of your {0}boards{1}"), "<a href=\"http://boardsmanager\">", "</a>");
|
||||
text = I18n.format(tr("Updates available for some of your {0}boards{1}"), "<a href=\"http://boardsmanager/DropdownUpdatableCoresItem\">", "</a>");
|
||||
} else {
|
||||
text = I18n.format(tr("Updates available for some of your {0}boards{1} and {2}libraries{3}"), "<a href=\"http://boardsmanager\">", "</a>", "<a href=\"http://librarymanager\">", "</a>");
|
||||
}
|
||||
|
@ -1135,7 +1135,7 @@ public class Base {
|
||||
importMenu.removeAll();
|
||||
|
||||
JMenuItem menu = new JMenuItem(tr("Manage Libraries..."));
|
||||
menu.addActionListener(e -> openLibraryManager(""));
|
||||
menu.addActionListener(e -> openLibraryManager("", ""));
|
||||
importMenu.add(menu);
|
||||
importMenu.addSeparator();
|
||||
|
||||
@ -1264,7 +1264,7 @@ public class Base {
|
||||
}
|
||||
}
|
||||
|
||||
public void openLibraryManager(String dropdownItem) {
|
||||
public void openLibraryManager(final String filterText, String dropdownItem) {
|
||||
if (contributionsSelfCheck != null) {
|
||||
contributionsSelfCheck.cancel();
|
||||
}
|
||||
@ -1280,6 +1280,9 @@ public class Base {
|
||||
if (StringUtils.isNotEmpty(dropdownItem)) {
|
||||
selectDropdownItemByClassName(dropdownItem);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(filterText)) {
|
||||
setFilterText(filterText);
|
||||
}
|
||||
}
|
||||
};
|
||||
managerUI.setLocationRelativeTo(activeEditor);
|
||||
|
@ -29,6 +29,7 @@ import cc.arduino.packages.uploaders.SerialUploader;
|
||||
import cc.arduino.view.GoToLineNumber;
|
||||
import cc.arduino.view.StubMenuListener;
|
||||
import cc.arduino.view.findreplace.FindReplace;
|
||||
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import jssc.SerialPortException;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
|
||||
@ -1015,9 +1016,15 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size"));
|
||||
textArea.addHyperlinkListener(evt -> {
|
||||
try {
|
||||
platform.openURL(sketch.getFolder(), evt.getURL().toExternalForm());
|
||||
} catch (Exception e) {
|
||||
Base.showWarning(e.getMessage(), e.getMessage(), e);
|
||||
UpdatableBoardsLibsFakeURLsHandler boardLibHandler = new UpdatableBoardsLibsFakeURLsHandler(base);
|
||||
boardLibHandler.openBoardLibManager(evt.getURL());
|
||||
}
|
||||
catch (Exception e) {
|
||||
try {
|
||||
platform.openURL(sketch.getFolder(), evt.getURL().toExternalForm());
|
||||
} catch (Exception f) {
|
||||
Base.showWarning(f.getMessage(), f.getMessage(), f);
|
||||
}
|
||||
}
|
||||
});
|
||||
textArea.addCaretListener(e -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user