use of org.eclipse.jface.action.GroupMarker in project bndtools by bndtools.
the class RepositoriesView method createContextMenu.
void createContextMenu() {
MenuManager mgr = new MenuManager();
Menu menu = mgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
getSite().registerContextMenu(mgr, viewer);
mgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
try {
manager.removeAll();
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (!selection.isEmpty()) {
final Object firstElement = selection.getFirstElement();
if (firstElement instanceof Actionable) {
final RepositoryPlugin rp = getRepositoryPlugin(firstElement);
//
// Use the Actionable interface to fill the menu
// Should extend this to allow other menu entries
// from the view, but currently there are none
//
final Actionable act = (Actionable) firstElement;
Map<String, Runnable> actions = act.actions();
if (actions != null) {
for (final Entry<String, Runnable> e : actions.entrySet()) {
String label = e.getKey();
boolean enabled = true;
boolean checked = false;
String description = null;
Matcher m = LABEL_PATTERN.matcher(label);
if (m.matches()) {
if (m.group(1) != null)
enabled = false;
if (m.group(2) != null)
checked = true;
label = m.group(3);
description = m.group(4);
}
Action a = new Action(label.replace("&", "&&")) {
@Override
public void run() {
Job backgroundJob = new Job("Repository Action '" + getText() + "'") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
e.getValue().run();
if (rp != null && rp instanceof Refreshable)
Central.refreshPlugin((Refreshable) rp);
} catch (final Exception e) {
IStatus status = new Status(IStatus.ERROR, Plugin.PLUGIN_ID, "Error executing: " + getName(), e);
Plugin.getDefault().getLog().log(status);
}
monitor.done();
return Status.OK_STATUS;
}
};
backgroundJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
viewer.getTree().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
viewer.refresh();
}
});
}
}
});
backgroundJob.setUser(true);
backgroundJob.setPriority(Job.SHORT);
backgroundJob.schedule();
}
};
a.setEnabled(enabled);
if (description != null)
a.setDescription(description);
a.setChecked(checked);
manager.add(a);
}
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}
use of org.eclipse.jface.action.GroupMarker in project dbeaver by serge-rider.
the class BaseTextEditor method editorContextMenuAboutToShow.
@Override
protected void editorContextMenuAboutToShow(IMenuManager menu) {
// super.editorContextMenuAboutToShow(menu);
menu.add(new GroupMarker(GROUP_SQL_ADDITIONS));
menu.add(new GroupMarker(GROUP_SQL_EXTRAS));
menu.add(new Separator());
menu.add(new Separator(ITextEditorActionConstants.GROUP_COPY));
menu.add(new Separator(ITextEditorActionConstants.GROUP_PRINT));
menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
menu.add(new Separator(ITextEditorActionConstants.GROUP_FIND));
menu.add(new Separator(IWorkbenchActionConstants.GROUP_ADD));
menu.add(new Separator(ITextEditorActionConstants.GROUP_UNDO));
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_SAVE));
menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
menu.add(new Separator());
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator());
menu.add(new GroupMarker(GROUP_SQL_PREFERENCES));
if (isEditable()) {
addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.UNDO);
addAction(menu, ITextEditorActionConstants.GROUP_SAVE, ITextEditorActionConstants.SAVE);
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.CUT);
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.PASTE);
IAction action = getAction(ITextEditorActionConstants.QUICK_ASSIST);
if (action != null && action.isEnabled()) {
addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.QUICK_ASSIST);
}
} else {
addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
}
IAction preferencesAction = getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES);
if (preferencesAction != null) {
menu.appendToGroup(GROUP_SQL_PREFERENCES, preferencesAction);
}
for (IActionContributor ac : actionContributors) {
ac.contributeActions(menu);
}
}
use of org.eclipse.jface.action.GroupMarker in project dbeaver by serge-rider.
the class ERDEditorContextMenuProvider method buildContextMenu.
/**
* @see ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void buildContextMenu(IMenuManager menu) {
if (editor.isLoaded()) {
ISelection selection = editor.getGraphicalViewer().getSelection();
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
editor.fillPartContextMenu(menu, (IStructuredSelection) selection);
}
menu.add(new Separator());
editor.fillAttributeVisibilityMenu(menu);
menu.add(new DiagramLayoutAction(editor));
menu.add(new Separator());
menu.add(new Separator(GEFActionConstants.GROUP_UNDO));
menu.add(new Separator(GEFActionConstants.GROUP_COPY));
// menu.add(ActionUtils.makeCommandContribution(editor.getSite(), IWorkbenchCommandConstants.EDIT_COPY));
menu.add(new Separator(GEFActionConstants.GROUP_PRINT));
menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
menu.add(new Separator(GEFActionConstants.GROUP_VIEW));
menu.add(new Separator(GEFActionConstants.GROUP_FIND));
menu.add(new Separator(GEFActionConstants.GROUP_REST));
menu.add(new Separator(GEFActionConstants.GROUP_SAVE));
menu.add(new Separator());
menu.add(new GroupMarker(NavigatorCommands.GROUP_TOOLS));
menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS));
menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS_END));
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new GroupMarker(IActionConstants.MB_ADDITIONS_END));
}
}
use of org.eclipse.jface.action.GroupMarker in project dbeaver by serge-rider.
the class ValueViewerPanel method fillToolBar.
private void fillToolBar(final IContributionManager contributionManager) {
contributionManager.add(new Separator());
if (valueManager != null) {
try {
valueManager.contributeActions(contributionManager, previewController, valueEditor);
} catch (Exception e) {
log.error("Can't contribute value manager actions", e);
}
}
contributionManager.add(new GroupMarker(IValueManager.GROUP_ACTIONS_ADDITIONAL));
if (valueEditor != null && !valueEditor.isReadOnly()) {
contributionManager.add(ActionUtils.makeCommandContribution(presentation.getController().getSite(), ValueViewCommandHandler.CMD_SAVE_VALUE));
contributionManager.add(new Action("Auto-apply value", Action.AS_CHECK_BOX) {
{
setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.AUTO_SAVE));
}
@Override
public boolean isChecked() {
return DBWorkbench.getPlatform().getPreferenceStore().getBoolean(ResultSetPreferences.RS_EDIT_AUTO_UPDATE_VALUE);
}
@Override
public void run() {
boolean newValue = !isChecked();
DBWorkbench.getPlatform().getPreferenceStore().setValue(ResultSetPreferences.RS_EDIT_AUTO_UPDATE_VALUE, newValue);
presentation.getController().updatePanelActions();
}
});
}
}
use of org.eclipse.jface.action.GroupMarker in project yamcs-studio by yamcs.
the class YamcsStudioActionBarAdvisor method fillAppToolBar.
protected void fillAppToolBar(IToolBarManager appToolBar) {
appToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));
appToolBar.add(new NewWizardDropDownAction(window));
appToolBar.add(save);
appToolBar.add(saveAll);
appToolBar.add(new GroupMarker(COOL_GROUP_PROCESSOR_INFO));
appToolBar.add(new GroupMarker(COOL_GROUP_BOOKMARK_SHORTCUTS));
appToolBar.add(new GroupMarker(COOL_GROUP_PROCESSOR_CONTROLS));
appToolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
}
Aggregations