final List<INews> news = getNewsList(query);
Runnable runnable = new Runnable() {
public void run() {
INews.State newState = INews.State.READ;
boolean affectEquivalentNews = OwlUI.markReadDuplicates();
UndoStack.getInstance().addOperation(new NewsStateOperation(news, newState, affectEquivalentNews));
fNewsDao.setState(news, newState, affectEquivalentNews, false);
}
};
if (CBrowser.isMozillaRunningOnWindows()) //Bug in XULRunner, otherwise won't work
delayInUI(runnable);
else
runnable.run();
}
/* Toggle Read */
else if (queryProvided && TOGGLE_READ_HANDLER_ID.equals(id)) {
INews news = getNews(query);
if (news != null) {
/* Remove Focus from Link */
blur(Dynamic.TOGGLE_READ_LINK.getId(news));
/* Update State */
INews.State newState = (news.getState() == INews.State.READ) ? INews.State.UNREAD : INews.State.READ;
Set<INews> singleNewsSet = Collections.singleton(news);
boolean affectEquivalentNews = (newState != INews.State.UNREAD && OwlUI.markReadDuplicates());
UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, newState, affectEquivalentNews));
fNewsDao.setState(singleNewsSet, newState, affectEquivalentNews, false);
if (newState == INews.State.UNREAD)
fMarkedUnreadByUserCache.add(news.getId());
}
}
/* Toggle Sticky */
else if (queryProvided && TOGGLE_STICKY_HANDLER_ID.equals(id)) {
INews news = getNews(query);
if (news != null) {
/* Remove Focus from Link */
blur(Dynamic.TOGGLE_STICKY_LINK.getId(news));
if (isHeadlinesLayout())
blur(Dynamic.TINY_TOGGLE_STICKY_LINK.getId(news), true);
/* Toggle Sticky State */
Set<INews> singleNewsSet = Collections.singleton(news);
UndoStack.getInstance().addOperation(new StickyOperation(singleNewsSet, !news.isFlagged()));
news.setFlagged(!news.isFlagged());
Controller.getDefault().getSavedSearchService().forceQuickUpdate();
DynamicDAO.saveAll(singleNewsSet);
}
}
/* Archive */
else if (queryProvided && ARCHIVE_HANDLER_ID.equals(id)) {
INews news = getNews(query);
if (news != null) {
ArchiveNewsAction action = new ArchiveNewsAction(new StructuredSelection(news));
action.run();
}
}
/* Delete */
else if (queryProvided && DELETE_HANDLER_ID.equals(id)) {
INews news = getNews(query);
if (news != null) {
Set<INews> singleNewsSet = Collections.singleton(news);
UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, INews.State.HIDDEN, false));
fNewsDao.setState(singleNewsSet, INews.State.HIDDEN, false, false);
}
}
/* Labels Menu */