use of org.eclipse.jface.action.IMenuManager in project cubrid-manager by CUBRID.
the class PerspectiveChangedListener method hidePerspectiveHide.
public void hidePerspectiveHide(PerspectiveChangeEvent event) {
WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
ICoolBarManager coolBarManager = window.getCoolBarManager2();
IMenuManager menuManager = window.getMenuBarManager();
ActionAdvisor.getInstance().hideToolbar(coolBarManager);
ActionAdvisor.getInstance().hideMenu(menuManager);
}
}
use of org.eclipse.jface.action.IMenuManager in project sling by apache.
the class JcrPropertiesView method hookContextMenu.
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
JcrPropertiesView.this.fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
IWorkbenchPartSite site = getSite();
if (site != null) {
site.registerContextMenu(menuMgr, viewer);
}
}
use of org.eclipse.jface.action.IMenuManager 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.IMenuManager in project meclipse by flaper87.
the class MeclipseView method hookContextMenu.
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty()) {
MeclipseView.this.fillContextMenu(manager);
return;
}
TreeObject obj = (TreeObject) selection.getFirstElement();
manager.add(new Separator());
obj.fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, viewer);
}
use of org.eclipse.jface.action.IMenuManager in project translationstudio8 by heartsome.
the class WorkingSetRootModeActionGroup method fillActionBars.
/*
* (non-Javadoc)
*
* @see ActionGroup#fillActionBars(IActionBars)
*/
public void fillActionBars(IActionBars actionBars) {
if (hasContributedToViewMenu)
return;
IMenuManager topLevelSubMenu = new MenuManager(WorkbenchNavigatorMessages.actions_WorkingSetRootModeActionGroup_Top_Level_Element_);
addActions(topLevelSubMenu);
actionBars.getMenuManager().insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, topLevelSubMenu);
hasContributedToViewMenu = true;
}
Aggregations