bookmarkFilter.setMenuCreator(new ContextMenuCreator() {
@Override
public Menu createMenu(Control parent) {
Menu menu = new Menu(parent);
/* Filter: None */
final MenuItem showAll = new MenuItem(menu, SWT.RADIO);
showAll.setText(Messages.BookMarkExplorer_SHOW_ALL);
showAll.setSelection(BookMarkFilter.Type.SHOW_ALL == fBookMarkFilter.getType());
menu.setDefaultItem(showAll);
showAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showAll.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_ALL)
doFilter(BookMarkFilter.Type.SHOW_ALL);
}
});
/* Separator */
new MenuItem(menu, SWT.SEPARATOR);
/* Filter: New */
final MenuItem showNew = new MenuItem(menu, SWT.RADIO);
showNew.setText(Messages.BookMarkExplorer_SHOW_NEW);
showNew.setSelection(BookMarkFilter.Type.SHOW_NEW == fBookMarkFilter.getType());
showNew.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showNew.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_NEW)
doFilter(BookMarkFilter.Type.SHOW_NEW);
}
});
/* Filter: Unread */
final MenuItem showUnread = new MenuItem(menu, SWT.RADIO);
showUnread.setText(Messages.BookMarkExplorer_SHOW_UNREAD);
showUnread.setSelection(BookMarkFilter.Type.SHOW_UNREAD == fBookMarkFilter.getType());
showUnread.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showUnread.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_UNREAD)
doFilter(BookMarkFilter.Type.SHOW_UNREAD);
}
});
/* Filter: Sticky */
final MenuItem showSticky = new MenuItem(menu, SWT.RADIO);
showSticky.setText(Messages.BookMarkExplorer_SHOW_STICKY);
showSticky.setSelection(BookMarkFilter.Type.SHOW_STICKY == fBookMarkFilter.getType());
showSticky.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showSticky.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_STICKY)
doFilter(BookMarkFilter.Type.SHOW_STICKY);
}
});
/* Separator */
new MenuItem(menu, SWT.SEPARATOR);
/* Filter: Erroneous */
final MenuItem showErroneous = new MenuItem(menu, SWT.RADIO);
showErroneous.setText(Messages.BookMarkExplorer_SHOW_ERROR);
showErroneous.setSelection(BookMarkFilter.Type.SHOW_ERRONEOUS == fBookMarkFilter.getType());
showErroneous.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showErroneous.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_ERRONEOUS)
doFilter(BookMarkFilter.Type.SHOW_ERRONEOUS);
}
});
/* Filter: Never Visited */
final MenuItem showNeverVisited = new MenuItem(menu, SWT.RADIO);
showNeverVisited.setText(Messages.BookMarkExplorer_SHOW_NEVER_VISITED);
showNeverVisited.setSelection(BookMarkFilter.Type.SHOW_NEVER_VISITED == fBookMarkFilter.getType());
showNeverVisited.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showNeverVisited.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_NEVER_VISITED)
doFilter(BookMarkFilter.Type.SHOW_NEVER_VISITED);
}
});
return menu;
}
});
fToolBarManager.add(bookmarkFilter);
/* Bookmark Group */
fToolBarManager.add(new Separator());
final IAction bookmarkGroup = new Action(Messages.BookMarkExplorer_GROUP_ELEMENTS, IAction.AS_DROP_DOWN_MENU) {
@Override
public void run() {
/* Restore Default */
if (fBookMarkGrouping.getType() != BookMarkGrouping.Type.NO_GROUPING)
doGrouping(BookMarkGrouping.Type.NO_GROUPING);
/* Toggle to previous */
else if (fLastGroupType != null)
doGrouping(fLastGroupType);
/* Show Menu */
else if (fToolBarManager instanceof ToolBarManager)
OwlUI.positionDropDownMenu(this, (ToolBarManager) fToolBarManager);
}
@Override
public ImageDescriptor getImageDescriptor() {
if (fBookMarkGrouping.getType() == BookMarkGrouping.Type.NO_GROUPING)
return OwlUI.getImageDescriptor("icons/etool16/group.gif"); //$NON-NLS-1$
return OwlUI.getImageDescriptor("icons/etool16/group_active.gif"); //$NON-NLS-1$
}
};
bookmarkGroup.setId(GROUP_ACTION);
bookmarkGroup.setMenuCreator(new ContextMenuCreator() {
@Override
public Menu createMenu(Control parent) {
Menu menu = new Menu(parent);
/* Group: None */
final MenuItem noGrouping = new MenuItem(menu, SWT.RADIO);
noGrouping.setText(Messages.BookMarkExplorer_NO_GROUPING);
noGrouping.setSelection(BookMarkGrouping.Type.NO_GROUPING == fBookMarkGrouping.getType());
menu.setDefaultItem(noGrouping);
noGrouping.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (noGrouping.getSelection() && fBookMarkGrouping.getType() != BookMarkGrouping.Type.NO_GROUPING)
doGrouping(BookMarkGrouping.Type.NO_GROUPING);