1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-30 19:52:13 +01:00

"Add library" moved into "Import library" menu

This commit is contained in:
Federico Fissore 2012-10-19 09:32:26 +02:00
parent 3e9ef44401
commit 2a401f2a8b
2 changed files with 16 additions and 16 deletions

View File

@ -954,8 +954,18 @@ public class Base {
return userLibs;
}
public void rebuildImportMenu(JMenu importMenu) {
public void rebuildImportMenu(JMenu importMenu, final Editor editor) {
importMenu.removeAll();
JMenuItem addLibraryMenuItem = new JMenuItem(_("Add Library..."));
addLibraryMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.this.handleAddLibrary(editor);
Base.this.onBoardOrPortChange();
Base.this.rebuildImportMenu(Editor.importMenu, editor);
}
});
importMenu.add(addLibraryMenuItem);
// Split between user supplied libraries and IDE libraries
Map<String, File> ideLibs = getIDELibs();
@ -1108,7 +1118,7 @@ public class Base {
}
public void rebuildBoardsMenu(JMenu boardsMenu, final JMenu cpuTypeMenu) {
public void rebuildBoardsMenu(JMenu boardsMenu, final JMenu cpuTypeMenu, final Editor editor) {
String selPackage = Preferences.get("target_package");
String selPlatform = Preferences.get("target_platform");
String selBoard = Preferences.get("board");
@ -1172,7 +1182,7 @@ public class Base {
onBoardOrPortChange();
Sketch.buildSettingChanged();
rebuildImportMenu(Editor.importMenu);
rebuildImportMenu(Editor.importMenu, editor);
rebuildExamplesMenu(Editor.examplesMenu);
}
};

View File

@ -630,20 +630,10 @@ public class Editor extends JFrame implements RunnerListener {
if (importMenu == null) {
importMenu = new JMenu(_("Import Library..."));
base.rebuildImportMenu(importMenu);
base.rebuildImportMenu(importMenu, this);
}
sketchMenu.add(importMenu);
item = new JMenuItem(_("Add Library..."));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleAddLibrary(Editor.this);
base.onBoardOrPortChange();
base.rebuildImportMenu(Editor.importMenu);
}
});
sketchMenu.add(item);
item = newJMenuItem(_("Show Sketch Folder"), 'K');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -694,10 +684,10 @@ public class Editor extends JFrame implements RunnerListener {
if (boardsMenu == null) {
boardsMenu = new JMenu(_("Board"));
cpuTypeMenu = new JMenu(_("Processor"));
base.rebuildBoardsMenu(boardsMenu, cpuTypeMenu);
base.rebuildBoardsMenu(boardsMenu, cpuTypeMenu, this);
//Debug: rebuild imports
importMenu.removeAll();
base.rebuildImportMenu(importMenu);
base.rebuildImportMenu(importMenu, this);
}
menu.add(boardsMenu);
menu.add(cpuTypeMenu);