List of usage examples for org.eclipse.jface.action IAction getMenuCreator
IMenuCreator getMenuCreator();
From source file:name.schedenig.eclipse.grepconsole.actions.AddExpressionAction.java
License:Open Source License
/** * Updates the currently selected text.// w ww . j av a 2s .co m * * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @Override public void selectionChanged(IAction action, ISelection selection) { if (action.getMenuCreator() != this) { action.setMenuCreator(this); } selected = null; if (selection instanceof ITextSelection) { ITextSelection ts = (ITextSelection) selection; if (ts.getStartLine() == ts.getEndLine() && ts.getText() != null && ts.getText().length() > 0) { selected = ts.getText(); } } action.setEnabled(selected != null); if (menu != null) { updateMenu(); } }
From source file:org.carrot2.workbench.core.helpers.DropDownMenuAction.java
License:Open Source License
/** * Show a menu for the given action.//from ww w . j a va2 s. c o m */ public static void showMenu(IAction action, Event e) { final IMenuCreator mc = action.getMenuCreator(); if (mc != null && e != null) { final ToolItem ti = (ToolItem) e.widget; if (ti != null && ti instanceof ToolItem) { final Menu m = mc.getMenu((ti).getParent()); if (m != null) { final Rectangle b = ti.getBounds(); final Point p = ti.getParent().toDisplay(new Point(b.x, b.y + b.height)); m.setLocation(p.x, p.y); m.setVisible(true); } } } }
From source file:org.eclipse.birt.report.designer.internal.ui.swt.custom.TabbedPropertyTitle.java
License:Open Source License
private void handleWidgetSelection(Event e, ToolItem item) { boolean selection = item.getSelection(); int style = item.getStyle(); IAction action = (IAction) actionMap.get(item); if ((style & (SWT.TOGGLE | SWT.CHECK)) != 0) { if (action.getStyle() == IAction.AS_CHECK_BOX) { action.setChecked(selection); }/*from w w w. jav a 2 s . c om*/ } else if ((style & SWT.RADIO) != 0) { if (action.getStyle() == IAction.AS_RADIO_BUTTON) { action.setChecked(selection); } } else if ((style & SWT.DROP_DOWN) != 0) { if (e.detail == 4) { // on drop-down button if (action.getStyle() == IAction.AS_DROP_DOWN_MENU) { IMenuCreator mc = action.getMenuCreator(); ToolItem ti = (ToolItem) item; if (mc != null) { Menu m = mc.getMenu(ti.getParent()); if (m != null) { Point point = ti.getParent().toDisplay(new Point(e.x, e.y)); m.setLocation(point.x, point.y); // waiting m.setVisible(true); return; // we don't fire the action } } } } } action.runWithEvent(e); }
From source file:org.openmaji.implementation.tool.eclipse.editor.kinetic.KINeticContextMenuProvider.java
License:Open Source License
protected void buildLifeCycleItems(IMenuManager menu) { IAction actionLifeCycleState = getRegistry().getAction(LifeCycleAction.ID_LIFE_CYCLE_STATE); Action action = new Action("Life Cycle State") { };//from www.ja v a 2 s . co m action.setMenuCreator(actionLifeCycleState.getMenuCreator()); menu.appendToGroup(ActionConstants.GROUP_LIFECYCLESTATE, new ActionContributionItem(action)); }