1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

IDE: prevent multiple bad name notifications.

This patch will prevent the IDE from informing the user about a bad
sketch folder name multiple times.

Now the user is informed once at start up only, or once when it is
detected during a rescan of the folders.
This commit is contained in:
Chris--A 2015-05-12 16:51:52 +10:00 committed by Federico Fissore
parent 281fc68304
commit b2f8b9b6c1

View File

@ -51,6 +51,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import static processing.app.I18n._;
@ -64,6 +65,8 @@ public class LibrariesIndexer {
private final File indexFile;
private final File stagingFolder;
private File sketchbookLibrariesFolder;
private static final List<String> badLibNotified = new ArrayList<String>();
public LibrariesIndexer(File preferencesFolder, ContributionsIndexer contributionsIndexer) {
this.contributionsIndexer = contributionsIndexer;
@ -135,11 +138,18 @@ public class LibrariesIndexer {
for (File subfolder : list) {
if (!BaseNoGui.isSanitaryName(subfolder.getName())) {
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
// Detect whether the current folder name has already had a notification.
if(!badLibNotified.contains(subfolder.getName())) {
badLibNotified.add(subfolder.getName());
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
+ "Library names must contain only basic letters and numbers.\n"
+ "(ASCII only and no spaces, and it cannot start with a number)"),
subfolder.getName());
BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
}
continue;
}