});
fToolBarManager.add(bookmarkFilter);
/* Bookmark Group */
fToolBarManager.add(new Separator());
final IAction bookmarkGroup = new Action("Group Bookmarks", IAction.AS_DROP_DOWN_MENU) {
@Override
public void run() {
/* Restore Default */
if (fBookMarkGrouping.getType() != BookMarkGrouping.Type.NO_GROUPING)
doGrouping(BookMarkGrouping.Type.NO_GROUPING);
/* Show Menu */
else
getMenuCreator().getMenu(fToolBarManager.getControl()).setVisible(true);
}
@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 IMenuCreator() {
public void dispose() {}
public Menu getMenu(Control parent) {
Menu menu = new Menu(parent);
/* Group: None */
final MenuItem noGrouping = new MenuItem(menu, SWT.RADIO);
noGrouping.setText("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);
}
});
/* Separator */
new MenuItem(menu, SWT.SEPARATOR);
/* Group: By Last Visit */
final MenuItem groupByLastVisit = new MenuItem(menu, SWT.RADIO);
groupByLastVisit.setText("Group by Last Visit");
groupByLastVisit.setSelection(BookMarkGrouping.Type.GROUP_BY_LAST_VISIT == fBookMarkGrouping.getType());
groupByLastVisit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (groupByLastVisit.getSelection() && fBookMarkGrouping.getType() != BookMarkGrouping.Type.GROUP_BY_LAST_VISIT)
doGrouping(BookMarkGrouping.Type.GROUP_BY_LAST_VISIT);
}
});
/* Group: By Popularity */
final MenuItem groupByPopularity = new MenuItem(menu, SWT.RADIO);
groupByPopularity.setText("Group by Popularity");
groupByPopularity.setSelection(BookMarkGrouping.Type.GROUP_BY_POPULARITY == fBookMarkGrouping.getType());
groupByPopularity.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (groupByPopularity.getSelection() && fBookMarkGrouping.getType() != BookMarkGrouping.Type.GROUP_BY_POPULARITY)
doGrouping(BookMarkGrouping.Type.GROUP_BY_POPULARITY);
}
});
return menu;
}
public Menu getMenu(Menu parent) {
return null;
}
});
fToolBarManager.add(bookmarkGroup);
/* BookmarkSet Navigation - TODO Consider showing dynamically */
fToolBarManager.add(new Separator());
IAction previousSet = new Action("Previous Bookmark-Set") {
@Override
public void run() {
int index = getIndexOfRootFolder(fSelectedBookMarkSet);
changeSet(getRootFolderAt(index - 1));
}
@Override
public boolean isEnabled() {
int index = getIndexOfRootFolder(fSelectedBookMarkSet);
return index > 0 && fRootFolders.size() > 1;
}
};
previousSet.setId(PREVIOUS_SET_ACTION);
previousSet.setImageDescriptor(OwlUI.getImageDescriptor("icons/etool16/backward.gif")); //$NON-NLS-1$
previousSet.setDisabledImageDescriptor(OwlUI.getImageDescriptor("icons/dtool16/backward.gif")); //$NON-NLS-1$
fToolBarManager.add(previousSet);
IAction nextSet = new Action("Next Bookmark-Set") {
@Override
public void run() {
int index = getIndexOfRootFolder(fSelectedBookMarkSet);
changeSet(getRootFolderAt(index + 1));
}
@Override
public boolean isEnabled() {
int index = getIndexOfRootFolder(fSelectedBookMarkSet);
return index < (fRootFolders.size() - 1) && fRootFolders.size() > 1;
}
};
nextSet.setId(NEXT_SET_ACTION);
nextSet.setImageDescriptor(OwlUI.getImageDescriptor("icons/etool16/forward.gif")); //$NON-NLS-1$
nextSet.setDisabledImageDescriptor(OwlUI.getImageDescriptor("icons/dtool16/forward.gif")); //$NON-NLS-1$
fToolBarManager.add(nextSet);
/* Allow Contributions */
fToolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}