public static void displayMenu( Menu menu, Control control ) { Menu oldMenu = control.getMenu(); if ( oldMenu != null && oldMenu != menu ) { oldMenu.setVisible( false ); } // XXX: Stubbing out this line prevents context dialogs from appearing twice // on OS X. Tested on Windows to be sure there is no adverse effect. // Unfortunately, I do *not* understand why this works. I ran it by // mcasters and he didn't know for sure either. // control.setMenu(menu); menu.setVisible( true ); }
public void newFileDropDown() { // Drop down a list below the "New" icon (new.png) // First problem: where is that icon? XulToolbarbutton button = (XulToolbarbutton) this.mainToolbar.getElementById( "file-new" ); Object object = button.getManagedObject(); if ( object instanceof ToolItem ) { // OK, let's determine the location of this widget... // ToolItem item = (ToolItem) object; Rectangle bounds = item.getBounds(); org.eclipse.swt.graphics.Point p = item.getParent().toDisplay( new org.eclipse.swt.graphics.Point( bounds.x, bounds.y ) ); fileMenus.setLocation( p.x, p.y + bounds.height ); fileMenus.setVisible( true ); } }
helperMenu.setLocation( l.x + p.x, l.y + p.y + h ); helperMenu.setDefaultItem( first ); helperMenu.setVisible( true ); } else if ( proposals.size() > 0 ) { int nr = 0; helperMenu.setVisible( true );
@Override public void widgetSelected( SelectionEvent e ) { Menu menu = new Menu( shell ); for ( final PerspectiveData perspectiveData : perspectiveList ) { MenuItem item = new MenuItem( menu, SWT.CHECK ); if ( perspectiveData.isHidden() ) { item.setEnabled( false ); } if ( activePerspective.getId().equals( perspectiveData.getId() ) ) { item.setSelection( true ); } item.setText( perspectiveData.getName() ); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent selectionEvent ) { Spoon.getInstance().loadPerspective( perspectiveData.getId() ); swtToolbar.forceFocus(); } } ); } ToolItem item = (ToolItem) e.widget; Rectangle rect = item.getBounds(); Point pt = item.getParent().toDisplay( new Point( rect.x, rect.y + rect.height ) ); menu.setLocation( pt.x, pt.y ); menu.setVisible( true ); } } );
menu.setVisible( true );
@Override public void menuDetected( MenuDetectEvent event ) { if ( tree.getSelectionCount() < 1 ) { return; } TreeItem treeItem = tree.getSelection()[0]; if ( treeItem != null ) { String[] labels = ConstUI.getTreeStrings( treeItem ); int depth = ConstUI.getTreeLevel( treeItem ); if ( depth == 3 ) { final String metaStoreName = labels[0]; final String namespace = labels[1]; final String elementTypeName = labels[2]; final String elementName = labels[3]; Menu menu = new Menu( tree ); MenuItem removeItem = new MenuItem( menu, SWT.POP_UP ); removeItem.setText( "Remove element" ); removeItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent arg0 ) { removeElement( metaStoreName, namespace, elementTypeName, elementName ); } } ); tree.setMenu( menu ); menu.setVisible( true ); } } } } );
@Override public void widgetSelected( SelectionEvent e ) { if ( e.detail == SWT.DROP_DOWN ) { Menu menu = new Menu( shell, SWT.POP_UP ); MenuItem item1 = new MenuItem( menu, SWT.PUSH ); item1.setText( BaseMessages.getString( PKG, "Spoon.Menu.StopTranformation" ) ); item1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e1 ) { stopTransformation(); } } ); MenuItem item2 = new MenuItem( menu, SWT.PUSH ); item2.setText( BaseMessages.getString( PKG, "Spoon.Menu.SafeStopTranformation" ) ); item2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e2 ) { safeStop(); } } ); menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) ); menu.setVisible( true ); } else { stopTransformation(); } } } );
@Override public void widgetSelected( SelectionEvent e ) { if ( e.detail == SWT.DROP_DOWN ) { Menu menu = new Menu( shell, SWT.POP_UP ); MenuItem item1 = new MenuItem( menu, SWT.PUSH ); item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) ); item1.setAccelerator( SWT.F9 ); item1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e1 ) { runJob(); } } ); MenuItem item2 = new MenuItem( menu, SWT.PUSH ); item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) ); item2.setAccelerator( SWT.F8 ); item2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e2 ) { runOptionsJob(); } } ); menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) ); menu.setVisible( true ); } else { runJob(); } } } );
@Override public void widgetSelected( SelectionEvent e ) { if ( e.detail == SWT.DROP_DOWN ) { Menu menu = new Menu( shell, SWT.POP_UP ); MenuItem item1 = new MenuItem( menu, SWT.PUSH ); item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) ); item1.setAccelerator( SWT.F9 ); item1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e1 ) { runTransformation(); } } ); MenuItem item2 = new MenuItem( menu, SWT.PUSH ); item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) ); item2.setAccelerator( SWT.F8 ); item2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e2 ) { runOptionsTransformation(); } } ); menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) ); menu.setVisible( true ); } else { runTransformation(); } } } );
menu.setVisible( true );
public void setMenuBarVisible( boolean visible ) { mainSpoonContainer.getDocumentRoot().getElementById( "edit" ).setVisible( visible ); mainSpoonContainer.getDocumentRoot().getElementById( "file" ).setVisible( visible ); mainSpoonContainer.getDocumentRoot().getElementById( "view" ).setVisible( visible ); mainSpoonContainer.getDocumentRoot().getElementById( "action" ).setVisible( visible ); mainSpoonContainer.getDocumentRoot().getElementById( "tools" ).setVisible( visible ); mainSpoonContainer.getDocumentRoot().getElementById( "help" ).setVisible( visible ); MenuManager menuManager = getMenuBarManager(); menuManager.getMenu().setVisible( visible ); menuManager.updateAll( true ); }
connectionMenu.setVisible( true );
@Override public void handleEvent( Event event ) { ToolItem item = ( ToolItem )event.widget; Rectangle bounds = item.getBounds(); bounds.y += bounds.height; Point point = pageSwitcher.toDisplay( bounds.x + 10, bounds.y ); pageSwitcherMenu.setLocation( point ); pageSwitcherMenu.setVisible( true ); } }
private void showViewMenu() { Menu menu = fMenuManager.createContextMenu(getShell()); Rectangle bounds = fToolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = fToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
public void widgetSelected(SelectionEvent e) { Menu menu = browseMenu.createContextMenu(getShell()); Rectangle bounds = browseItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = browseToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); } });
@Override public void widgetSelected(SelectionEvent e) { fControl.setFocus(); Rectangle rect= dropDown.getBounds(); Point pt= dropDown.getParent().toDisplay(new Point(rect.x, rect.y)); menu.setLocation(pt.x, pt.y + rect.height); menu.setVisible(true); } });
private void showProposalsMenu() { Control control = getControl(); Rectangle bounds = control.getBounds(); bounds.y += bounds.height + 5; Point point = control.toDisplay( bounds.x, bounds.y ); proposalsMenu.setLocation( point ); proposalsMenu.setVisible( true ); }
@Override public void mouseDown(MouseEvent event) { try{ Point p = status_menu.getDisplay().map( menu_drop, null, event.x, event.y ); status_menu.setLocation( p ); status_menu.setVisible(true); }catch( Throwable e ){ Debug.out( e); } } });
protected void showMenu(ToolBar toolBar) { Menu menu = getMenuManager().createContextMenu(toolBar); menu.setLocation(toolBar.toDisplay(0, toolBar.getSize().y)); iSMenuUp = true; menu.setVisible(true); }
@Override public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) { Control c = buttonUtility.getSkinObject().getControl(); menuDropDown.setLocation(c.getDisplay().getCursorLocation()); menuDropDown.setVisible(!menuDropDown.getVisible()); } });