8000 Storing Libraries in subfolders by matthijskooijman · Pull Request #1986 · arduino/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Storing Libraries in subfolders #1986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Prev Previous commit
Don't show the top-level library categories as submenus
In the previous commit, the import library and example menus were made
recursive. The top level submenus here were the different kinds of
library (hardware-independent libraries, hardware-specific libraries and
sketchbook libraries). With this commit, these different kinds of
libraries are all put together at the top level, with (unselectable)
headers in between (like the boards menu, which already head these
headers for the different platforms).
  • Loading branch information
matthijskooijman committed Oct 30, 2014
commit 1abd31a8f1b2f3a165f86db3feee1277ea53c3d8
38 changes: 33 additions & 5 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,6 @@ public void actionPerformed(ActionEvent e) {
importMenu.add(addLibraryMenuItem);

if (libraries != null) {
importMenu.addSeparator();
try {
addLibraries(importMenu, libraries);
} catch (IOException e) {
Expand All @@ -1307,12 +1306,28 @@ public void rebuildExamplesMenu(JMenu menu) {

// Add examples from distribution "example" folder
boolean found = addSketches(menu, examplesFolder, false);
if (found) {
// Prepend a label
JMenuItem label = new JMenuItem(_("Core examples"));
label.setEnabled(false);
menu.add(label, 0);
}

// Add examples from libraries
if (libraries != null && !libraries.isEmpty()) {
if (found)
menu.addSeparator();
addLibraryExamples(menu, libraries);
for (LibraryList sub : libraries.getSubs()) {
if (found)
menu.addSeparator();

// Prepend a label
JMenuItem label = new JMenuItem(sub.getName());
label.setEnabled(false);
menu.add(label);

addLibraryExamples(menu, sub);

found = true;
}
}
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -1820,13 +1835,26 @@ public void actionPerformed(ActionEvent e) {
}

protected void addLibraries(JMenu menu, LibraryList libs) throws IOException {
for (LibraryList sub : libs.getSubs()) {
menu.addSeparator();

// Prepend a label
JMenuItem label = new JMenuItem(sub.getName());
label.setEnabled(false);
menu.add(label);

addLibrariesRecursive(menu, sub);
}
}

protected void addLibrariesRecursive(JMenu menu, LibraryList libs) throws IOException {
// Add any subdirectories first
for (LibraryList sub : libs.getSubs()) {
if (sub.isEmpty())
continue;

JMenu submenu = new JMenu(sub.getName());
addLibraries(submenu, sub);
addLibrariesRecursive(submenu, sub);
menu.add(submenu);
MenuScroller.setScrollerFor(submenu);
}
Expand Down
0