Skip to content

Commit b99ab40

Browse files
committed
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
1 parent a329731 commit b99ab40

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

Diff for: app/src/cc/arduino/UpdatableBoardsLibsFakeURLsHandler.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,28 @@ public void hyperlinkUpdate(HyperlinkEvent event) {
5353
}
5454

5555
URL url = event.getURL();
56+
openBoardLibManager(url);
57+
}
5658

59+
public void openBoardLibManager(URL url) {
5760
if (BOARDSMANAGER.equals(url.getHost())) {
5861
try {
59-
base.openBoardsManager("", "DropdownUpdatableCoresItem");
62+
base.openBoardsManager(url.getRef() == null ? "": url.getRef() , url.getPath() == null ? "" : url.getPath().replace("/", ""));
6063
} catch (Exception e) {
6164
e.printStackTrace();
6265
}
6366
return;
6467
}
6568

69+
System.out.println(url.getRef() + " " + url.getHost() + " " + url.getPath());
70+
6671
if (LIBRARYMANAGER.equals(url.getHost())) {
67-
base.openLibraryManager("DropdownUpdatableLibrariesItem");
72+
base.openLibraryManager(url.getRef() == null ? "": url.getRef() , url.getPath() == null ? "" : url.getPath().replace("/", ""));
6873
return;
6974
}
7075

7176
throw new IllegalArgumentException(url.getHost() + " is invalid");
77+
7278
}
7379

7480
}

Diff for: app/src/cc/arduino/contributions/ContributionsSelfCheck.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public void run() {
8383

8484
String text;
8585
if (updatableLibraries > 0 && updatablePlatforms <= 0) {
86-
text = I18n.format(tr("Updates available for some of your {0}libraries{1}"), "<a href=\"http://librarymanager\">", "</a>");
86+
text = I18n.format(tr("Updates available for some of your {0}libraries{1}"), "<a href=\"http://librarymanager/DropdownUpdatableLibrariesItem\">", "</a>");
8787
} else if (updatableLibraries <= 0 && updatablePlatforms > 0) {
88-
text = I18n.format(tr("Updates available for some of your {0}boards{1}"), "<a href=\"http://boardsmanager\">", "</a>");
88+
text = I18n.format(tr("Updates available for some of your {0}boards{1}"), "<a href=\"http://boardsmanager/DropdownUpdatableCoresItem\">", "</a>");
8989
} else {
9090
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>");
9191
}

Diff for: app/src/processing/app/Base.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ public void rebuildImportMenu(JMenu importMenu) {
11351135
importMenu.removeAll();
11361136

11371137
JMenuItem menu = new JMenuItem(tr("Manage Libraries..."));
1138-
menu.addActionListener(e -> openLibraryManager(""));
1138+
menu.addActionListener(e -> openLibraryManager("", ""));
11391139
importMenu.add(menu);
11401140
importMenu.addSeparator();
11411141

@@ -1264,7 +1264,7 @@ public void onBoardOrPortChange() {
12641264
}
12651265
}
12661266

1267-
public void openLibraryManager(String dropdownItem) {
1267+
public void openLibraryManager(final String filterText, String dropdownItem) {
12681268
if (contributionsSelfCheck != null) {
12691269
contributionsSelfCheck.cancel();
12701270
}
@@ -1280,6 +1280,9 @@ protected void onIndexesUpdated() throws Exception {
12801280
if (StringUtils.isNotEmpty(dropdownItem)) {
12811281
selectDropdownItemByClassName(dropdownItem);
12821282
}
1283+
if (StringUtils.isNotEmpty(filterText)) {
1284+
setFilterText(filterText);
1285+
}
12831286
}
12841287
};
12851288
managerUI.setLocationRelativeTo(activeEditor);

Diff for: app/src/processing/app/Editor.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import cc.arduino.view.GoToLineNumber;
3030
import cc.arduino.view.StubMenuListener;
3131
import cc.arduino.view.findreplace.FindReplace;
32+
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
3233
import com.jcraft.jsch.JSchException;
3334
import jssc.SerialPortException;
3435
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
@@ -1015,9 +1016,15 @@ private SketchTextArea createTextArea() throws IOException {
10151016
textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size"));
10161017
textArea.addHyperlinkListener(evt -> {
10171018
try {
1018-
platform.openURL(sketch.getFolder(), evt.getURL().toExternalForm());
1019-
} catch (Exception e) {
1020-
Base.showWarning(e.getMessage(), e.getMessage(), e);
1019+
UpdatableBoardsLibsFakeURLsHandler boardLibHandler = new UpdatableBoardsLibsFakeURLsHandler(base);
1020+
boardLibHandler.openBoardLibManager(evt.getURL());
1021+
}
1022+
catch (Exception e) {
1023+
try {
1024+
platform.openURL(sketch.getFolder(), evt.getURL().toExternalForm());
1025+
} catch (Exception f) {
1026+
Base.showWarning(f.getMessage(), f.getMessage(), f);
1027+
}
10211028
}
10221029
});
10231030
textArea.addCaretListener(e -> {

0 commit comments

Comments
 (0)