for (NewsEvent event : events) {
if (isInputRelatedTo(event.getEntity(), EventType.PERSIST)) {
if (addedNews == null)
addedNews = new ArrayList<INews>();
INews news = event.getEntity();
addedNews.add(news);
/* Update Cache */
synchronized (NewsContentProvider.this) {
fCachedNews.add(news);
}
}
}
/* Event not interesting for us or we are disposed */
if (addedNews == null || addedNews.size() == 0)
return;
/* Ask Group */
if (fGrouping.needsRefresh(INews.class, events, false)) {
fFeedView.refresh(true, false);
return;
}
/* Add to Table-Viewer if Visible */
if (fFeedView.isTableViewerVisible())
fTableViewer.add(fTableViewer.getInput(), addedNews.toArray());
/* Add to Browser-Viewer if showing entire Feed */
if (fBrowserViewer.getInput() instanceof BookMarkReference)
fBrowserViewer.add(fBrowserViewer.getInput(), addedNews.toArray());
}
});
}
/* News got Updated */
@Override
public void entitiesUpdated(final Set<NewsEvent> events) {
JobRunner.runInUIThread(fFeedView.getEditorControl(), new Runnable() {
public void run() {
List<INews> deletedNews = null;
List<INews> updatedNews = null;
/* Filter News which are from a different Feed than displayed */
for (NewsEvent event : events) {
if (isInputRelatedTo(event.getEntity(), EventType.UPDATE)) {
INews news = event.getEntity();
/* News got Deleted */
if (!news.isVisible()) {
if (deletedNews == null)
deletedNews = new ArrayList<INews>();
deletedNews.add(news);
synchronized (NewsContentProvider.this) {
fCachedNews.remove(news);
}
}
/* News got Updated */
else {
if (updatedNews == null)
updatedNews = new ArrayList<INews>();
updatedNews.add(news);
}
}
}
/* Event not interesting for us or we are disposed */
if (deletedNews == null && updatedNews == null)
return;
/* News got Deleted */
if (deletedNews != null && !isGroupingEnabled()) {
/* Remove from Table-Viewer */
if (fFeedView.isTableViewerVisible())
fTableViewer.remove(deletedNews.toArray());
/* Remove from Browser-Viewer */
if (contains(fBrowserViewer.getInput(), deletedNews))
fBrowserViewer.remove(deletedNews.toArray());
}
/* Ask Group */
if (fGrouping.needsRefresh(INews.class, events, true))
fFeedView.refresh(false, false);
/* News got Updated */
if (updatedNews != null) {
/* Update in Table-Viewer */
if (fFeedView.isTableViewerVisible())
fTableViewer.update(updatedNews.toArray(), null);
/* Update in Browser-Viewer */
if (contains(fBrowserViewer.getInput(), updatedNews))
fBrowserViewer.update(updatedNews.toArray(), null);
}
}
});
}
/* News got Deleted */
@Override
public void entitiesDeleted(final Set<NewsEvent> events) {
JobRunner.runInUIThread(fFeedView.getEditorControl(), new Runnable() {
public void run() {
List<INews> deletedNews = null;
/* Filter News which are from a different Feed or invisible */
for (NewsEvent event : events) {
INews news = event.getEntity();
if (news.isVisible() && isInputRelatedTo(news, EventType.REMOVE)) {
if (deletedNews == null)
deletedNews = new ArrayList<INews>();
deletedNews.add(news);
synchronized (NewsContentProvider.this) {