/** * <p>Returns all <code>MenuItems</code> whose <code>getMenu()</code> returns * the given <code>menu</code>. An empty array is returned if no * <code>MenuItem</code>s refer to the given <code>menu</code>.</p> */ private static MenuItem[] findReferringMenuItems( final Menu menu ) { final List menuItems = new ArrayList(); Decorations parent = menu.getParent(); WidgetTreeVisitor.accept( parent, new AllWidgetTreeVisitor() { public boolean doVisit( final Widget widget ) { if( widget instanceof MenuItem ) { MenuItem menuItem = ( MenuItem )widget; if( menuItem.getMenu() == menu ) { menuItems.add( menuItem ); } } // TODO [rh] find a way to cancel visitor after all menus are done? return true; } } ); MenuItem[] result = new MenuItem[ menuItems.size() ]; menuItems.toArray( result ); return result; } }
/** * {@inheritDoc} */ @Override public Menu getMenu(Menu parent) { Menu dropDownMenu = new Menu(parent.getParent(), SWT.DROP_DOWN); int i = 0; for (IContributionItem ci : menuManager.getItems()) { ci.fill(dropDownMenu, i); i++; } return dropDownMenu; }
/** * Constructs a new instance of this class given its parent * (which must be a <code>MenuItem</code>) and sets the style * for the instance so that the instance will be a drop-down * menu on the given parent's parent menu. * * @param parent a menu item which will be the parent of the new instance (cannot be null) * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * * @see SWT#DROP_DOWN * @see Widget#checkSubclass * @see Widget#getStyle */ public Menu( MenuItem parent ) { this( checkNull( parent ).getParent().getParent(), SWT.DROP_DOWN ); }
private void registerE4Support() { if (menuModel.getWidget() == null && menu.getMenu() != null) { MenuService.registerMenu(menu.getMenu().getParent(), menuModel, context); } } // getMenuId() added by Dan Rubel (dan_rubel@instantiations.com)
@Override public void renderInitialization( Menu menu ) throws IOException { RemoteObject remoteObject = createRemoteObject( menu , TYPE ); remoteObject.setHandler( new MenuOperationHandler( menu ) ); remoteObject.set( "parent", getId( menu.getParent() ) ); remoteObject.set( "style", createJsonArray( getStyles( menu, ALLOWED_STYLES ) ) ); // Always listen to Show events in order to notify potential Arm listeners on menu items if( !isMenuBar( menu ) ) { remoteObject.listen( PROP_SHOW_LISTENER, true ); } }
public void menuAboutToShow(IMenuManager manager) { if (!(manager instanceof MenuManager)) { return; } MenuManager menuManager = (MenuManager) manager; final MMenu menuModel = renderer.getMenuModel(menuManager); final Menu menu = menuManager.getMenu(); if (menuModel != null && menuManager != null) { cleanUp(menu, menuModel, menuManager); } if (menuModel instanceof MPopupMenu) { showPopup(menu, (MPopupMenu) menuModel, menuManager); } AbstractPartRenderer obj = rendererFactory.getRenderer(menuModel, menu.getParent()); if (!(obj instanceof MenuManagerRenderer)) { trace("Not the correct renderer: " + obj, menu, menuModel); //$NON-NLS-1$ return; } MenuManagerRenderer renderer = (MenuManagerRenderer) obj; if (menuModel.getWidget() == null) { renderer.bindWidget(menuModel, menuManager.getMenu()); } }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
SWT.error( SWT.ERROR_INVALID_ARGUMENT ); if( menuBar.getParent() != this ) { SWT.error( SWT.ERROR_INVALID_PARENT );
/** * Returns the shell for the given widget. If the widget doesn't represent a * SWT object that manage a shell, <code>null</code> is returned. * * @param widget * the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
@Override public void menuAboutToShow(IMenuManager manager) { if (!(manager instanceof MenuManager)) { return; } MenuManager menuManager = (MenuManager) manager; final MMenu menuModel = renderer.getMenuModel(menuManager); final Menu menu = menuManager.getMenu(); if (menuModel != null) { cleanUp(menuModel, menuManager); } if (menuModel instanceof MPopupMenu) { showPopup(menu, (MPopupMenu) menuModel, menuManager); } AbstractPartRenderer obj = rendererFactory.getRenderer(menuModel, menu.getParent()); if (!(obj instanceof MenuManagerRenderer)) { if (Policy.DEBUG_MENUS) { trace("Not the correct renderer: " + obj, menuManager, menuModel); //$NON-NLS-1$ } return; } MenuManagerRenderer renderer = (MenuManagerRenderer) obj; if (menuModel.getWidget() == null) { renderer.bindWidget(menuModel, menuManager.getMenu()); } }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; } }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @param widget The widget to get the shell for * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @param widget The widget to get the shell for * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; } }