mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-06 01:08:25 +01:00
Removed "libraries" and "hardware" entries from File > Sketchbook. Fixes #3432
This commit is contained in:
parent
fef4e56044
commit
afecb819a7
46
app/src/cc/arduino/view/JMenuUtils.java
Normal file
46
app/src/cc/arduino/view/JMenuUtils.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Arduino.
|
||||||
|
*
|
||||||
|
* Arduino is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* As a special exception, you may use this file as part of a free software
|
||||||
|
* library without restriction. Specifically, if other files instantiate
|
||||||
|
* templates or use macros or inline functions from this file, or you compile
|
||||||
|
* this file and link it with other files to produce an executable, this
|
||||||
|
* file does not by itself cause the resulting executable to be covered by
|
||||||
|
* the GNU General Public License. This exception does not however
|
||||||
|
* invalidate any other reasons why the executable file might be covered by
|
||||||
|
* the GNU General Public License.
|
||||||
|
*
|
||||||
|
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cc.arduino.view;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class JMenuUtils {
|
||||||
|
|
||||||
|
public static JMenu findSubMenuWithLabel(JMenu menu, String text) {
|
||||||
|
for (Component submenu : menu.getMenuComponents()) {
|
||||||
|
if (submenu instanceof JMenu && text.equals(((JMenu) submenu).getText())) {
|
||||||
|
return (JMenu) submenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1122,32 +1122,26 @@ public class Base {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
// Add a list of all sketches and subfolders
|
// Add a list of all sketches and subfolders
|
||||||
try {
|
|
||||||
boolean sketches = addSketches(menu, BaseNoGui.getSketchbookFolder(), true);
|
boolean sketches = addSketches(menu, BaseNoGui.getSketchbookFolder(), true);
|
||||||
if (sketches) menu.addSeparator();
|
if (sketches) menu.addSeparator();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add each of the subfolders of examples directly to the menu
|
// Add each of the subfolders of examples directly to the menu
|
||||||
try {
|
|
||||||
boolean found = addSketches(menu, BaseNoGui.getExamplesFolder(), true);
|
boolean found = addSketches(menu, BaseNoGui.getExamplesFolder(), true);
|
||||||
if (found) menu.addSeparator();
|
if (found) menu.addSeparator();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void rebuildSketchbookMenu(JMenu menu) {
|
protected void rebuildSketchbookMenu(JMenu menu) {
|
||||||
//System.out.println("rebuilding sketchbook menu");
|
|
||||||
//new Exception().printStackTrace();
|
|
||||||
try {
|
|
||||||
menu.removeAll();
|
menu.removeAll();
|
||||||
addSketches(menu, BaseNoGui.getSketchbookFolder(), false);
|
addSketches(menu, BaseNoGui.getSketchbookFolder(), false);
|
||||||
//addSketches(menu, getSketchbookFolder());
|
|
||||||
} catch (IOException e) {
|
JMenu librariesMenu = JMenuUtils.findSubMenuWithLabel(menu, "libraries");
|
||||||
e.printStackTrace();
|
if (librariesMenu != null) {
|
||||||
|
menu.remove(librariesMenu);
|
||||||
|
}
|
||||||
|
JMenu hardwareMenu = JMenuUtils.findSubMenuWithLabel(menu, "hardware");
|
||||||
|
if (hardwareMenu != null) {
|
||||||
|
menu.remove(hardwareMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,9 +1228,10 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void rebuildExamplesMenu(JMenu menu) {
|
public void rebuildExamplesMenu(JMenu menu) {
|
||||||
if (menu == null)
|
if (menu == null) {
|
||||||
return;
|
return;
|
||||||
try {
|
}
|
||||||
|
|
||||||
menu.removeAll();
|
menu.removeAll();
|
||||||
|
|
||||||
// Add examples from distribution "example" folder
|
// Add examples from distribution "example" folder
|
||||||
@ -1256,9 +1251,6 @@ public class Base {
|
|||||||
for (UserLibrary lib : userLibs)
|
for (UserLibrary lib : userLibs)
|
||||||
addSketchesSubmenu(menu, lib, false);
|
addSketchesSubmenu(menu, lib, false);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBoardOrPortChange() {
|
public void onBoardOrPortChange() {
|
||||||
@ -1588,7 +1580,7 @@ public class Base {
|
|||||||
* should replace the sketch in the current window, or false when the
|
* should replace the sketch in the current window, or false when the
|
||||||
* sketch should open in a new window.
|
* sketch should open in a new window.
|
||||||
*/
|
*/
|
||||||
protected boolean addSketches(JMenu menu, File folder, final boolean replaceExisting) throws IOException {
|
protected boolean addSketches(JMenu menu, File folder, final boolean replaceExisting) {
|
||||||
if (folder == null)
|
if (folder == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1624,14 +1616,13 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean addSketchesSubmenu(JMenu menu, UserLibrary lib,
|
private boolean addSketchesSubmenu(JMenu menu, UserLibrary lib,
|
||||||
boolean replaceExisting)
|
boolean replaceExisting) {
|
||||||
throws IOException {
|
|
||||||
return addSketchesSubmenu(menu, lib.getName(), lib.getInstalledFolder(),
|
return addSketchesSubmenu(menu, lib.getName(), lib.getInstalledFolder(),
|
||||||
replaceExisting);
|
replaceExisting);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addSketchesSubmenu(JMenu menu, String name, File folder,
|
private boolean addSketchesSubmenu(JMenu menu, String name, File folder,
|
||||||
final boolean replaceExisting) throws IOException {
|
final boolean replaceExisting) {
|
||||||
|
|
||||||
ActionListener listener = new ActionListener() {
|
ActionListener listener = new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user