Do not show invalid sketch filename warnings on reload

With this commit, any warnings about invalid sketch filenames are not
shown when the sketch is reloaded. This reloading happens whenever the
IDE window is focused, so re-logging warnings all the time isn't really
helpful, so this hides them.
This commit is contained in:
Matthijs Kooijman 2015-12-09 11:18:38 +01:00 committed by Martino Facchin
parent 8725bb1ec4
commit f7fdd08695
1 changed files with 7 additions and 4 deletions

View File

@ -74,7 +74,7 @@ public class SketchData {
folder = new File(file.getParent());
codeFolder = new File(folder, "code");
dataFolder = new File(folder, "data");
codes = listSketchFiles();
codes = listSketchFiles(true);
}
static public File checkSketchFile(File file) {
@ -109,7 +109,7 @@ public class SketchData {
* not.
*/
public boolean reload() throws IOException {
List<SketchCode> reloaded = listSketchFiles();
List<SketchCode> reloaded = listSketchFiles(false);
if (!reloaded.equals(codes)) {
codes = reloaded;
return true;
@ -122,13 +122,16 @@ public class SketchData {
* part of this sketch. Doesn't modify this SketchData instance, just
* returns a filtered and sorted list of File objects ready to be
* passed to the SketchCode constructor.
*
* @param showWarnings
* When true, any invalid filenames will show a warning.
*/
private List<SketchCode> listSketchFiles() throws IOException {
private List<SketchCode> listSketchFiles(boolean showWarnings) throws IOException {
Set<SketchCode> result = new TreeSet<>(CODE_DOCS_COMPARATOR);
for (File file : FileUtils.listFiles(folder, false, EXTENSIONS)) {
if (BaseNoGui.isSanitaryName(file.getName())) {
result.add(new SketchCode(file, file.equals(primaryFile)));
} else {
} else if (showWarnings) {
System.err.println(I18n.format(tr("File name {0} is invalid: ignored"), file.getName()));
}
}