fBrowser.addLinkHandler(PREVIOUS_NEWS_HANDLER_ID, this);
fBrowser.addLinkHandler(PREVIOUS_UNREAD_NEWS_HANDLER_ID, this);
}
private void hookNewsContextMenu() {
MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
@SuppressWarnings("restriction")
public void menuAboutToShow(IMenuManager manager) {
/* Open */
{
boolean useSeparator = true;
/* Open in FeedView */
if (!fIsEmbedded) {
manager.add(new Separator("internalopen")); //$NON-NLS-1$
if (!fCurrentSelection.isEmpty()) {
manager.appendToGroup("internalopen", new OpenNewsAction(fCurrentSelection, fBrowser.getControl().getShell())); //$NON-NLS-1$
useSeparator = false;
}
}
manager.add(useSeparator ? new Separator("open") : new GroupMarker("open")); //$NON-NLS-1$ //$NON-NLS-2$
/* Show only when internal browser is used */
if (!fCurrentSelection.isEmpty() && !fPreferences.getBoolean(DefaultPreferences.USE_CUSTOM_EXTERNAL_BROWSER) && !fPreferences.getBoolean(DefaultPreferences.USE_DEFAULT_EXTERNAL_BROWSER))
manager.add(new OpenInExternalBrowserAction(fCurrentSelection));
}
/* Attachments */
{
ApplicationActionBarAdvisor.fillAttachmentsMenu(manager, fCurrentSelection, new SameShellProvider(fBrowser.getControl().getShell()), false);
}
/* Mark / Label */
{
manager.add(new Separator("mark")); //$NON-NLS-1$
/* Mark */
MenuManager markMenu = new MenuManager(Messages.NewsBrowserViewer_MARK, "mark"); //$NON-NLS-1$
manager.add(markMenu);
/* Mark as Read */
IAction action = new ToggleReadStateAction(fCurrentSelection);
action.setEnabled(!fCurrentSelection.isEmpty());
markMenu.add(action);
/* Mark All Read */
action = new MarkAllNewsReadAction();
markMenu.add(action);
/* Sticky */
markMenu.add(new Separator());
action = new MakeNewsStickyAction(fCurrentSelection);
action.setEnabled(!fCurrentSelection.isEmpty());
markMenu.add(action);
/* Label */
ApplicationActionBarAdvisor.fillLabelMenu(manager, fCurrentSelection, new SameShellProvider(fBrowser.getControl().getShell()), false);
}
/* Move To / Copy To */
if (!fCurrentSelection.isEmpty()) {
manager.add(new Separator("movecopy")); //$NON-NLS-1$
/* Load all news bins and sort by name */
List<INewsBin> newsbins = new ArrayList<INewsBin>(DynamicDAO.loadAll(INewsBin.class));
Comparator<INewsBin> comparator = new Comparator<INewsBin>() {
public int compare(INewsBin o1, INewsBin o2) {
return o1.getName().compareTo(o2.getName());
};
};
Collections.sort(newsbins, comparator);
/* Move To */
MenuManager moveMenu = new MenuManager(Messages.NewsBrowserViewer_MOVE_TO, "moveto"); //$NON-NLS-1$
manager.add(moveMenu);
for (INewsBin bin : newsbins) {
if (contained(bin, fCurrentSelection))
continue;
moveMenu.add(new MoveCopyNewsToBinAction(fCurrentSelection, bin, true));
}
moveMenu.add(new MoveCopyNewsToBinAction(fCurrentSelection, null, true));
moveMenu.add(new Separator());
moveMenu.add(new AutomateFilterAction(PresetAction.MOVE, fCurrentSelection));
/* Copy To */
MenuManager copyMenu = new MenuManager(Messages.NewsBrowserViewer_COPY_TO, "copyto"); //$NON-NLS-1$
manager.add(copyMenu);
for (INewsBin bin : newsbins) {
if (contained(bin, fCurrentSelection))
continue;
copyMenu.add(new MoveCopyNewsToBinAction(fCurrentSelection, bin, false));
}
copyMenu.add(new MoveCopyNewsToBinAction(fCurrentSelection, null, false));
copyMenu.add(new Separator());
copyMenu.add(new AutomateFilterAction(PresetAction.COPY, fCurrentSelection));
}
/* Share */
{
ApplicationActionBarAdvisor.fillShareMenu(manager, fCurrentSelection, new SameShellProvider(fBrowser.getControl().getShell()), false);