/* Update Image */
fToolBarManager.find(GROUP_ACTION).update(IAction.IMAGE);
}
private void hookContextualMenu() {
MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
/* New Menu */
MenuManager newMenu = new MenuManager(Messages.BookMarkExplorer_NEW);
manager.add(newMenu);
/* New BookMark */
Action newBookmarkAction = new Action(Messages.BookMarkExplorer_BOOKMARK) {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
IFolder parent = getParent(selection);
IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
new NewBookMarkAction(fViewSite.getShell(), parent, position).run(null);
}
@Override
public ImageDescriptor getImageDescriptor() {
return OwlUI.BOOKMARK;
}
};
newBookmarkAction.setId("org.rssowl.ui.actions.NewBookMark"); //$NON-NLS-1$
newBookmarkAction.setActionDefinitionId("org.rssowl.ui.actions.NewBookMark"); //$NON-NLS-1$
newMenu.add(newBookmarkAction);
/* New NewsBin */
Action newNewsBinAction = new Action(Messages.BookMarkExplorer_NEWSBIN) {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
IFolder parent = getParent(selection);
IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
new NewNewsBinAction(fViewSite.getShell(), parent, position).run(null);
}
@Override
public ImageDescriptor getImageDescriptor() {
return OwlUI.NEWSBIN;
}
};
newNewsBinAction.setId("org.rssowl.ui.actions.NewNewsBin"); //$NON-NLS-1$
newNewsBinAction.setActionDefinitionId("org.rssowl.ui.actions.NewNewsBin"); //$NON-NLS-1$
newMenu.add(newNewsBinAction);
/* New Saved Search */
Action newSavedSearchAction = new Action(Messages.BookMarkExplorer_SAVED_SEARCH) {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
IFolder parent = getParent(selection);
IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
new NewSearchMarkAction(fViewSite.getShell(), parent, position).run(null);
}
@Override
public ImageDescriptor getImageDescriptor() {
return OwlUI.SEARCHMARK;
}
};
newSavedSearchAction.setId("org.rssowl.ui.actions.NewSearchMark"); //$NON-NLS-1$
newSavedSearchAction.setActionDefinitionId("org.rssowl.ui.actions.NewSearchMark"); //$NON-NLS-1$
newMenu.add(newSavedSearchAction);
/* New Folder */
newMenu.add(new Separator());
Action newFolderAction = new Action(Messages.BookMarkExplorer_FOLDER) {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
IFolder parent = getParent(selection);
IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
new NewFolderAction(fViewSite.getShell(), parent, position).run(null);
}
@Override
public ImageDescriptor getImageDescriptor() {
return OwlUI.FOLDER;
}
};
newFolderAction.setId("org.rssowl.ui.actions.NewFolder"); //$NON-NLS-1$
newFolderAction.setActionDefinitionId("org.rssowl.ui.actions.NewFolder"); //$NON-NLS-1$
newMenu.add(newFolderAction);
manager.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
/* Mark Read */
manager.add(new Separator(OwlUI.M_MARK));
/* Search News */
manager.add(new Separator());
manager.add(new SearchInTypeAction(fViewSite.getWorkbenchWindow(), fViewer));
manager.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
/* Share */
final IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
if (getBookMark(selection) != null) {
manager.add(new Separator("share")); //$NON-NLS-1$
MenuManager shareMenu = new MenuManager(Messages.BookMarkExplorer_SHARING, OwlUI.SHARE, "sharebookmark"); //$NON-NLS-1$
manager.add(shareMenu);
List<ShareProvider> providers = Controller.getDefault().getShareProviders();
for (final ShareProvider provider : providers) {
if (provider.isEnabled()) {
shareMenu.add(new Action(provider.getName()) {
@Override
public void run() {
if (SendLinkAction.ID.equals(provider.getId())) {
IActionDelegate action = new SendLinkAction();
action.selectionChanged(null, selection);
action.run(null);
} else {
IBookMark bookmark = getBookMark(selection);
if (bookmark != null) {
String shareLink = provider.toShareUrl(bookmark);
new OpenInBrowserAction(new StructuredSelection(shareLink)).run();
}
}
};
@Override
public ImageDescriptor getImageDescriptor() {
if (StringUtils.isSet(provider.getIconPath()))
return OwlUI.getImageDescriptor(provider.getPluginId(), provider.getIconPath());
return super.getImageDescriptor();
};
@Override
public boolean isEnabled() {
return !selection.isEmpty();
};
@Override
public String getActionDefinitionId() {
return SendLinkAction.ID.equals(provider.getId()) ? SendLinkAction.ID : super.getActionDefinitionId();
}
@Override
public String getId() {
return SendLinkAction.ID.equals(provider.getId()) ? SendLinkAction.ID : super.getId();
}
});
}
}
/* Configure Providers */
shareMenu.add(new Separator());
shareMenu.add(new Action(Messages.BookMarkExplorer_CONFIGURE) {
@Override
public void run() {
PreferencesUtil.createPreferenceDialogOn(fViewer.getTree().getShell(), SharingPreferencesPage.ID, null, null).open();
};
});