List<Snippet> toSort = new ArrayList<Snippet>();
toSort.addAll(predefinedSnippets);
Collections.sort(toSort, new Snippet.SnippetComparator());
Iterator<Snippet> snippets = toSort.iterator();
while (snippets.hasNext()) {
Snippet snippet = snippets.next();
addSnippetAction(menu, snippet);
}
addSeparatorToMenu(menu);
Plugin.getDefault().getCodeSnippetStore().load();
toSort.clear();
toSort.addAll(Plugin.getDefault().getCodeSnippetStore().getBeans());
Collections.sort(toSort, new Snippet.SnippetComparator());
snippets = toSort.iterator();
boolean snippetsAdded = false;
while (snippets.hasNext()) {
Snippet snippet = snippets.next();
boolean result = addSnippetAction(menu, snippet);
if (!snippetsAdded) {
snippetsAdded = result;
}
}