Recent list no longer has empty entries for missing files
This commit is contained in:
parent
7a61767e26
commit
5a88cb276b
@ -199,17 +199,30 @@ public class MainGUI extends javax.swing.JFrame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] fileList = files.split("\n");
|
String[] fileList = files.split("\n");
|
||||||
KeyValListItem[] items = new KeyValListItem[fileList.length];
|
int neededLength = 0;
|
||||||
for (int i = 0; i < fileList.length; i++) {
|
for (String file : fileList) {
|
||||||
if (i < RECENT_FILES) {
|
if ((new File(file)).isFile()) {
|
||||||
File file = new File(fileList[i]);
|
neededLength++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KeyValListItem[] items = new KeyValListItem[neededLength];
|
||||||
|
int i = 0;
|
||||||
|
for (String f : fileList) {
|
||||||
|
File file = new File(f);
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
items[i] = new KeyValListItem(file.getName(), file.getPath());
|
items[i] = new KeyValListItem(file.getName(), file.getPath());
|
||||||
}
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recentFileList.setListData(items);
|
recentFileList.setListData(items);
|
||||||
|
|
||||||
|
// Re-save list to remove bad entries
|
||||||
|
String list = "";
|
||||||
|
for (KeyValListItem item : items) {
|
||||||
|
list += item.getValue() + "\n";
|
||||||
|
}
|
||||||
|
PrefStorage.saveSetting("recentfiles", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addRecentFile(String file) {
|
public static void addRecentFile(String file) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user