JobRunner.runInBackgroundThread(new Runnable() {
public void run() {
if (fInput == null)
return;
IMark mark = fInput.getMark();
/* Trigger a reload if this is the first time open */
if (mark instanceof IBookMark) {
IBookMark bookmark = (IBookMark) mark;
if ((bookmark.getLastVisitDate() == null && !fContentProvider.hasCachedNews()))
new ReloadTypesAction(new StructuredSelection(mark), getEditorSite().getShell()).run();
}
/* Trigger reload of not loaded included Bookmarks */
else if (mark instanceof FolderNewsMark) {
IFolder folder = ((FolderNewsMark) mark).getFolder();
List<IBookMark> bookMarksToReload = new ArrayList<IBookMark>();
fillBookMarksToReload(bookMarksToReload, folder);
if (!bookMarksToReload.isEmpty())
new ReloadTypesAction(new StructuredSelection(bookMarksToReload.toArray()), getEditorSite().getShell()).run();
}
/* Mark the Searchmark as visited */
if (mark instanceof ISearchMark) {
DynamicDAO.getDAO(ISearchMarkDAO.class).visited((ISearchMark) mark);
}
/* Mark the newsbin as visited */
else if (mark instanceof INewsBin) {
DynamicDAO.getDAO(INewsBinDAO.class).visited((INewsBin) mark);
}
/* TODO Fixme once IBookMarkDAO.visited() is implemented */
else if (!(mark instanceof FolderNewsMark)) {
mark.setPopularity(mark.getPopularity() + 1);
mark.setLastVisitDate(new Date());
DynamicDAO.save(mark);
}
}
});
}