}
private void internalRun() {
/* Require a Page */
IWorkbenchPage page = OwlUI.getPage();
if (page == null)
return;
int openedEditors = 0;
int maxOpenEditors = EditorUtils.getOpenEditorLimit();
IEditorPart lastOpenedEditor = null;
/* Convert selection to List of News (1 per Feed) */
List< ? > list = fSelection.toList();
List<FeedLinkReference> handledFeeds = new ArrayList<FeedLinkReference>(list.size());
List<INews> newsToOpen = new ArrayList<INews>(list.size());
for (Object selection : list) {
if (selection instanceof INews) {
INews news = (INews) selection;
FeedLinkReference feedRef = news.getFeedReference();
/* Check if already Handled */
if (!handledFeeds.contains(feedRef)) {
newsToOpen.add(news);
handledFeeds.add(feedRef);
}
}
}
/* Minimize Shell if present */
if (newsToOpen.size() > 0 && fShellToMinimize != null)
fShellToMinimize.setMinimized(true);
/* Open Bookmarks belonging to the News */
for (int i = 0; i < newsToOpen.size() && openedEditors < maxOpenEditors; i++) {
INews news = newsToOpen.get(i);
/* Receive the first Bookmark belonging to the News and open it */
Set<IBookMark> bookmarks = fCacheService.getBookMarks(news.getFeedReference());
if (!bookmarks.isEmpty()) {
IBookMark mark = bookmarks.iterator().next();
/* Select this News in the FeedView */
PerformAfterInputSet perform = PerformAfterInputSet.selectNews(new NewsReference(news.getId()));
perform.setActivate(false);
/* Open this Bookmark */
FeedViewInput fvInput = new FeedViewInput(mark, perform);
try {
FeedView feedview = null;
/* First check if input already shown */
IEditorPart existingEditor = page.findEditor(fvInput);
if (existingEditor != null && existingEditor instanceof FeedView) {
feedview = (FeedView) existingEditor;
/* Set Selection */
feedview.setSelection(new StructuredSelection(news));
}
/* Otherwise open the Input in a new Editor */
else
feedview = (FeedView) page.openEditor(fvInput, FeedView.ID, true);
openedEditors++;
lastOpenedEditor = feedview;
} catch (PartInitException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
}
}
/* Activate the last opened editor */
if (lastOpenedEditor != null)
page.activate(lastOpenedEditor);
}