else
selection = StructuredSelection.EMPTY;
/* Open */
{
manager.add(new Separator("open"));
/* Open News in Browser */
manager.add(new Action("Open in Browser") {
@Override
public void run() {
new OpenInBrowserAction(selection).run();
}
@Override
public boolean isEnabled() {
return !selection.isEmpty();
}
});
/* Open Externally - Show only when internal browser is used */
if (!selection.isEmpty() && !preferences.getBoolean(DefaultPreferences.USE_CUSTOM_EXTERNAL_BROWSER) && !preferences.getBoolean(DefaultPreferences.USE_DEFAULT_EXTERNAL_BROWSER))
manager.add(new OpenInExternalBrowserAction(selection));
}
/* Mark / Label */
{
manager.add(new Separator("mark"));
/* Mark */
{
MenuManager markMenu = new MenuManager("Mark", "mark");
manager.add(markMenu);
/* Mark as Read */
IAction action = new MarkNewsReadAction(selection);
action.setEnabled(!selection.isEmpty());
markMenu.add(action);
/* Mark All Read */
action = new MarkAllNewsReadAction();
action.setEnabled(activeFeedView != null);
markMenu.add(action);
/* Sticky */
markMenu.add(new Separator());
action = new MakeNewsStickyAction(selection);
action.setEnabled(!selection.isEmpty());
markMenu.add(action);
}
/* Label */
{
Collection<ILabel> labels = DynamicDAO.loadAll(ILabel.class);
MenuManager labelMenu = new MenuManager("Label");
manager.add(labelMenu);
/* Retrieve Labels that all selected News contain */
Set<ILabel> selectedLabels = ModelUtils.getLabelsForAll(selection);
IAction removeAllLabels = new Action("Remove All Labels") {
@Override
public void run() {
Collection<ILabel> labels = DynamicDAO.loadAll(ILabel.class);
new LabelAction(labels, selection, false).run();
}
};
removeAllLabels.setEnabled(!labels.isEmpty());
labelMenu.add(removeAllLabels);
labelMenu.add(new Separator());
for (final ILabel label : labels) {
IAction labelAction = new Action(label.getName(), IAction.AS_CHECK_BOX) {
@Override
public void run() {
Set<ILabel> labels = new HashSet<ILabel>(1);
labels.add(label);
new LabelAction(labels, selection, isChecked()).run();
}
};
labelAction.setChecked(selectedLabels.contains(label));
labelMenu.add(labelAction);
}
labelMenu.add(new Separator());
labelMenu.add(new Action("Organize...") {
@Override
public void run() {
PreferencesUtil.createPreferenceDialogOn(getActionBarConfigurer().getWindowConfigurer().getWindow().getShell(), ManageLabelsPreferencePage.ID, null, null).open();
}
});
}
}
/* Edit */
{
manager.add(new Separator("edit"));
/* Copy Link */
manager.add(new Action("Copy Link") {
@Override
public void run() {
IActionDelegate action = new CopyLinkAction();
action.selectionChanged(null, selection);
action.run(null);
}
@Override
public boolean isEnabled() {
return !selection.isEmpty();
}
});
/* Send Link */
manager.add(new Action("Send Link") {
@Override
public void run() {
IActionDelegate action = new SendLinkAction();
action.selectionChanged(null, selection);
action.run(null);
}
@Override
public boolean isEnabled() {
return !selection.isEmpty();
}
});
}
/* Update */
{
manager.add(new Separator("reload"));
/* Update */
manager.add(new Action("Update") {
@Override
public void run() {
IActionDelegate action = new ReloadTypesAction();
action.selectionChanged(null, selection);
action.run(null);
}
@Override
public ImageDescriptor getImageDescriptor() {
return OwlUI.getImageDescriptor("icons/elcl16/reload.gif");
}
@Override
public ImageDescriptor getDisabledImageDescriptor() {
return OwlUI.getImageDescriptor("icons/dlcl16/reload.gif");
}
@Override
public boolean isEnabled() {
return !selection.isEmpty();
}
});
/* Update All */
manager.add(new ReloadAllAction());
}
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});
}