Skip to content

Add "Manage libraries..." to the "Tools" menu too and add a shortcut for it. #6638

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

Merged
merged 5 commits into from Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,10 @@ public void rebuildImportMenu(JMenu importMenu) {
importMenu.removeAll();

JMenuItem menu = new JMenuItem(tr("Manage Libraries..."));
// Ctrl+Shift+I on Windows and Linux, Command+Shift+I on macOS
menu.setAccelerator(KeyStroke.getKeyStroke('I',
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() |
ActionEvent.SHIFT_MASK));
menu.addActionListener(e -> openLibraryManager("", ""));
importMenu.add(menu);
importMenu.addSeparator();
Expand Down
69 changes: 35 additions & 34 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public boolean test(SketchController sketch) {

static volatile AbstractMonitor serialMonitor;
static AbstractMonitor serialPlotter;

final EditorHeader header;
EditorStatus status;
EditorConsole console;
Expand Down Expand Up @@ -248,7 +248,7 @@ public void windowDeactivated(WindowEvent e) {

//PdeKeywords keywords = new PdeKeywords();
//sketchbook = new Sketchbook(this);

buildMenuBar();

// For rev 0120, placing things inside a JPanel
Expand Down Expand Up @@ -399,8 +399,7 @@ public boolean importData(JComponent src, Transferable transferable) {
statusNotice(tr("One file added to the sketch."));

} else {
statusNotice(
I18n.format(tr("{0} files added to the sketch."), successful));
statusNotice(I18n.format(tr("{0} files added to the sketch."), successful));
}
return true;
}
Expand Down Expand Up @@ -732,16 +731,16 @@ private JMenu buildToolsMenu() {

addInternalTools(toolsMenu);

JMenuItem item = newJMenuItemShift(tr("Serial Monitor"), 'M');
JMenuItem item = newJMenuItemShift(tr("Manage Libraries..."), 'I');
item.addActionListener(e -> base.openLibraryManager("", ""));
toolsMenu.add(item);

item = newJMenuItemShift(tr("Serial Monitor"), 'M');
item.addActionListener(e -> handleSerial());
toolsMenu.add(item);

item = newJMenuItemShift(tr("Serial Plotter"), 'L');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handlePlotter();
}
});
item.addActionListener(e -> handlePlotter());
toolsMenu.add(item);

addTools(toolsMenu, BaseNoGui.getToolsFolder());
Expand Down Expand Up @@ -947,14 +946,14 @@ private String findClassInZipFile(String base, File file) {
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e) {
// noop
}
}
}
return null;
}
zipFile.close();
} catch (IOException e) {
// noop
}
}
}
return null;
}

public void updateKeywords(PdeKeywords keywords) {
for (EditorTab tab : tabs)
Expand Down Expand Up @@ -1476,6 +1475,7 @@ static public JMenuItem newJMenuItem(String title, int what) {
/**
* Like newJMenuItem() but adds shift as a modifier for the key command.
*/
// Control + Shift + K seems to not be working on linux (Xubuntu 17.04, 2017-08-19)
static public JMenuItem newJMenuItemShift(String title, int what) {
JMenuItem menuItem = new JMenuItem(title);
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK | ActionEvent.SHIFT_MASK));
Expand Down Expand Up @@ -2096,18 +2096,19 @@ private boolean serialPrompt() {
names[i] = portMenu.getItem(i).getText();
}

// FIXME: This is horribly unreadable
String result = (String)
JOptionPane.showInputDialog(this,
I18n.format(
tr("Serial port {0} not found.\n" +
"Retry the upload with another serial port?"),
PreferencesData.get("serial.port")
),
"Serial port not found",
JOptionPane.PLAIN_MESSAGE,
null,
names,
0);
JOptionPane.showInputDialog(this,
I18n.format(
tr("Serial port {0} not found.\n" +
"Retry the upload with another serial port?"),
PreferencesData.get("serial.port")
),
"Serial port not found",
JOptionPane.PLAIN_MESSAGE,
null,
names,
0);
if (result == null) return false;
selectSerialPort(result);
base.onBoardOrPortChange();
Expand Down Expand Up @@ -2321,7 +2322,7 @@ public void handleSerial() {
return;
}
}

if (serialMonitor != null) {
// The serial monitor already exists

Expand Down Expand Up @@ -2351,14 +2352,14 @@ public void handleSerial() {
}

serialMonitor = new MonitorFactory().newMonitor(port);

if (serialMonitor == null) {
String board = port.getPrefs().get("board");
String boardName = BaseNoGui.getPlatform().resolveDeviceByBoardID(BaseNoGui.packages, board);
statusError(I18n.format(tr("Serial monitor is not supported on network ports such as {0} for the {1} in this release"), PreferencesData.get("serial.port"), boardName));
return;
}

Base.setIcon(serialMonitor);

// If currently uploading, disable the monitor (it will be later
Expand Down Expand Up @@ -2418,7 +2419,7 @@ public void handleSerial() {
} while (serialMonitor.requiresAuthorization() && !success);

}

public void handlePlotter() {
if(serialMonitor != null) {
if(serialMonitor.isClosed()) {
Expand All @@ -2428,7 +2429,7 @@ public void handlePlotter() {
return;
}
}

if (serialPlotter != null) {
// The serial plotter already exists

Expand Down
2 changes: 1 addition & 1 deletion app/src/processing/app/helpers/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static KeyStroke ctrlShift(int keyCode) {
}

/**
* Creates a KeyCode for the "menu shortcut" + shift + the key passed in. By
* Creates a KeyCode for the "menu shortcut" + alt + the key passed in. By
* default, the menu shortcut is the ctrl key (hence the method name), but
* platforms might use a different key (like the Apple key on OSX).
*
Expand Down