}
public void addRecentFile(String fileName, String menuID, String recentMenuID, String recentFilesKey, String menuLabel, PropertyChangeListener listener) {
Plugin plugin = Activator.getDefault();
Preferences prefs = plugin.getPluginPreferences();
String recentFiles = prefs.getString(recentFilesKey);
if (recentFiles == null) {
recentFiles = "";
}
String[] recentFilesArray = recentFiles.split(";");
String[] newFilesArray = new String[10];
// put new file
newFilesArray[0] = fileName;
// move files
for (int i = 0; i < 9; i++) {
// check files
if (i >= recentFilesArray.length) {
break;
}
// check if file has not been already added
if (!fileName.equals(recentFilesArray[i])) {
newFilesArray[i + 1] = recentFilesArray[i];
}
}
// now join
recentFiles = "";
for (String file : newFilesArray) {
if (file != null && file != "") {
recentFiles += file + ";";
}
}
// store preference
prefs.setValue(recentFilesKey, recentFiles);
plugin.savePluginPreferences();
// rebuild menu
rebuildRecentFiles(menuID, recentMenuID, recentFilesKey, menuLabel, listener);
}