Favorite[] favArr = favorites.toArray(new Favorite[favorites.size()]);
if(ManageFavoritesDialog.getInstance() != null && ManageFavoritesDialog.getInstance().isVisible()) {
if(!favorites.isEmpty()) {
ActionMenu blackListAction = createBlackListFavoriteMenuAction(favArr, program);
ArrayList<Object> subItems = new ArrayList<Object>(2);
subItems.add(createExcludeFromFavoritesMenuAction(favArr, program));
if(blackListAction != null) {
subItems.add(0,blackListAction);
}
return new ActionMenu(mLocalizer.msg("favorites", "Favorites"),FavoritesPlugin.getFavoritesIcon(16),subItems.toArray());
}
else {
return null;
}
}
else {
if (favorites.isEmpty()) {
return new ActionMenu(mLocalizer.msg("favorites", "Favorites"), FavoritesPlugin.getFavoritesIcon(16), new ActionMenu[] {
createAddToFavoritesActionMenu(program),
createGlobalExclusionMenu(program)
});
}
else {
ActionMenu blackListAction = createBlackListFavoriteMenuAction(favArr, program);
ActionMenu repetitions = FavoritesPlugin.getInstance().isShowingRepetitions() ? createRepetitionsMenuAction(favArr, program) : null;
ArrayList<Object> subItems = new ArrayList<Object>(8);
subItems.add(createManageFavoriteMenuAction(favArr));
subItems.add(createEditFavoriteMenuAction(favArr));
subItems.add(createExcludeFromFavoritesMenuAction(favArr, program));
subItems.add(createDeleteFavoriteMenuAction(favArr));
subItems.add(ContextMenuSeparatorAction.getInstance());
subItems.add(createGlobalExclusionMenu(program));
subItems.add(createAddToFavoritesActionMenu(program));
if (repetitions != null) {
subItems.add(3, repetitions);
}
if(blackListAction != null) {
subItems.add(1, blackListAction);
}
return new ActionMenu(mLocalizer.msg("favorites", "Favorites"), FavoritesPlugin.getFavoritesIcon(16), subItems.toArray());
}
}
}