Java Code Examples for org.eclipse.swt.widgets.Menu#setVisible()
The following examples show how to use
org.eclipse.swt.widgets.Menu#setVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FindBarDecorator.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
void showOptions(boolean useMousePos) { Menu menu = new Menu(UIUtils.getActiveShell(), SWT.POP_UP); for (FindBarOption option : fFindBarOptions) { option.createMenuItem(menu); } Point location; if (useMousePos) { Display current = UIUtils.getDisplay(); location = current.getCursorLocation(); } else { Rectangle bounds = options.getBounds(); location = options.getParent().toDisplay(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2); } menu.setLocation(location); menu.setVisible(true); }
Example 2
Source File: ConstUi.java From hop with Apache License 2.0 | 5 votes |
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 ); }
Example 3
Source File: ProjectFileDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
private void showViewMenu( ) { Menu menu = menuManager.createContextMenu( getShell( ) ); Rectangle bounds = toolItem.getBounds( ); Point topLeft = new Point( bounds.x, bounds.y + bounds.height ); topLeft = toolBar.toDisplay( topLeft ); menu.setLocation( topLeft.x, topLeft.y ); menu.setVisible( true ); }
Example 4
Source File: DropDownAction.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void runWithEvent(final Event event) { if (event.widget instanceof ToolItem) { final ToolItem toolItem = (ToolItem) event.widget; final Control control = toolItem.getParent(); @SuppressWarnings("hiding") final Menu menu = getMenu(control); final Rectangle bounds = toolItem.getBounds(); final Point topLeft = new Point(bounds.x, bounds.y + bounds.height); menu.setLocation(control.toDisplay(topLeft)); menu.setVisible(true); } }
Example 5
Source File: ShowHistoryAction.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void runWithEvent(Event event) { if (event.widget instanceof ToolItem) { final ToolItem toolItem = (ToolItem) event.widget; final Control control = toolItem.getParent(); final Menu menu = getMenuCreator().getMenu(control); final Rectangle bounds = toolItem.getBounds(); final Point topLeft = new Point(bounds.x, bounds.y + bounds.height); menu.setLocation(control.toDisplay(topLeft)); menu.setVisible(true); } }
Example 6
Source File: ConstUI.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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 ); }
Example 7
Source File: StandardEditorSystemMenu.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void show(Control parent, Point displayCoordinates, IPresentablePart currentSelection) { restore.update(); move.setTarget(currentSelection); move.update(); minimize.update(); maximize.update(); close.setTarget(currentSelection); closeOthers.setTarget(currentSelection); closeAll.update(); Menu aMenu = menuManager.createContextMenu(parent); menuManager.update(true); aMenu.setLocation(displayCoordinates.x, displayCoordinates.y); aMenu.setVisible(true); }
Example 8
Source File: XFindPanel.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public void showHistoryMenu() { if (bHistory.isEnabled()) { final MenuManager manager = new MenuManager(); fillHistoryMenu(manager); final Menu menu = manager.createContextMenu(toolBar); // menu.setLocation(toolBar.getDisplay().getCursorLocation()); menu.setLocation(getToolItemLocation(bHistory)); menu.setVisible(true); } }
Example 9
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 5 votes |
private void showViewMenu() { Menu menu = menuManager.createContextMenu(getShell()); Rectangle bounds = toolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = toolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
Example 10
Source File: StandardEditorSystemMenu.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void show(Control parent, Point displayCoordinates, IPresentablePart currentSelection) { restore.update(); move.setTarget(currentSelection); move.update(); minimize.update(); maximize.update(); close.setTarget(currentSelection); closeOthers.setTarget(currentSelection); closeAll.update(); Menu aMenu = menuManager.createContextMenu(parent); menuManager.update(true); aMenu.setLocation(displayCoordinates.x, displayCoordinates.y); aMenu.setVisible(true); }
Example 11
Source File: OpenWithQuickMenu.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
private void show( Control focusControl, Point location ) { Menu quickMenu = new Menu( focusControl.getShell() ); OpenWithMenu openWithMenu = new OpenWithMenu( workbenchPage, file ); openWithMenu.fill( quickMenu, 0 ); quickMenu.setLocation( location ); quickMenu.addListener( SWT.Hide, createMenuCloseListener( openWithMenu ) ); quickMenu.setVisible( true ); }
Example 12
Source File: ParameterExpandBar.java From gama with GNU General Public License v3.0 | 5 votes |
void onContextualMenu(final Event event) { final int x = event.x; final int y = event.y; for (int i = 0; i < itemCount; i++) { final ParameterExpandItem item = items[i]; final boolean hover = item.x <= x && x < item.x + item.width && item.y <= y && y < item.y + bandHeight; if (!hover) { continue; } if (underlyingObjects != null) { ignoreMouseUp = true; final Point p = toDisplay(x, y); final Map<String, Runnable> menuContents = underlyingObjects.handleMenu(item.getData(), p.x, p.y); if (menuContents == null) { return; } else { final Menu menu = new Menu(getShell(), SWT.POP_UP); for (final Map.Entry<String, Runnable> entry : menuContents.entrySet()) { final MenuItem menuItem = new MenuItem(menu, SWT.PUSH); menuItem.setText(entry.getKey()); menuItem.addListener(SWT.Selection, e -> entry.getValue().run()); } menu.setLocation(p.x, p.y); menu.setVisible(true); while (!menu.isDisposed() && menu.isVisible()) { if (!WorkbenchHelper.getDisplay().readAndDispatch()) { WorkbenchHelper.getDisplay().sleep(); } } menu.dispose(); } } } }
Example 13
Source File: ResourceFileFolderSelectionDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
private void showViewMenu( ) { Menu menu = menuManager.createContextMenu( getShell( ) ); Rectangle bounds = toolItem.getBounds( ); Point topLeft = new Point( bounds.x, bounds.y + bounds.height ); topLeft = toolBar.toDisplay( topLeft ); menu.setLocation( topLeft.x, topLeft.y ); menu.setVisible( true ); }
Example 14
Source File: TabbedPropertyTitle.java From birt with Eclipse Public License 1.0 | 4 votes |
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 ); } } 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 ); }
Example 15
Source File: HopGuiPipelineGraph.java From hop with Apache License 2.0 | 4 votes |
private void addCandidateAsHop( int mouseX, int mouseY ) { boolean forward = startHopTransform != null; TransformMeta fromTransform = candidate.getFromTransform(); TransformMeta toTransform = candidate.getToTransform(); if ( fromTransform.equals( toTransform ) ) { return; // Don't add } // See what the options are. // - Does the source transform has multiple stream options? // - Does the target transform have multiple input stream options? // List<IStream> streams = new ArrayList<>(); ITransformIOMeta fromIoMeta = fromTransform.getTransform().getTransformIOMeta(); List<IStream> targetStreams = fromIoMeta.getTargetStreams(); if ( forward ) { streams.addAll( targetStreams ); } ITransformIOMeta toIoMeta = toTransform.getTransform().getTransformIOMeta(); List<IStream> infoStreams = toIoMeta.getInfoStreams(); if ( !forward ) { streams.addAll( infoStreams ); } if ( forward ) { if ( fromIoMeta.isOutputProducer() && toTransform.equals( currentTransform ) ) { streams.add( new Stream( StreamType.OUTPUT, fromTransform, BaseMessages .getString( PKG, "HopGui.Hop.MainOutputOfTransform" ), StreamIcon.OUTPUT, null ) ); } if ( fromTransform.supportsErrorHandling() && toTransform.equals( currentTransform ) ) { streams.add( new Stream( StreamType.ERROR, fromTransform, BaseMessages.getString( PKG, "HopGui.Hop.ErrorHandlingOfTransform" ), StreamIcon.ERROR, null ) ); } } else { if ( toIoMeta.isInputAcceptor() && fromTransform.equals( currentTransform ) ) { streams.add( new Stream( StreamType.INPUT, toTransform, BaseMessages.getString( PKG, "HopGui.Hop.MainInputOfTransform" ), StreamIcon.INPUT, null ) ); } if ( fromTransform.supportsErrorHandling() && fromTransform.equals( currentTransform ) ) { streams.add( new Stream( StreamType.ERROR, fromTransform, BaseMessages.getString( PKG, "HopGui.Hop.ErrorHandlingOfTransform" ), StreamIcon.ERROR, null ) ); } } // Targets can be dynamically added to this transform... // if ( forward ) { streams.addAll( fromTransform.getTransform().getOptionalStreams() ); } else { streams.addAll( toTransform.getTransform().getOptionalStreams() ); } // Show a list of options on the canvas... // if ( streams.size() > 1 ) { // Show a pop-up menu with all the possible options... // Menu menu = new Menu( canvas ); for ( final IStream stream : streams ) { MenuItem item = new MenuItem( menu, SWT.NONE ); item.setText( Const.NVL( stream.getDescription(), "" ) ); item.setImage( getImageFor( stream ) ); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { addHop( stream ); } } ); } menu.setLocation( canvas.toDisplay( mouseX, mouseY ) ); menu.setVisible( true ); return; } if ( streams.size() == 1 ) { addHop( streams.get( 0 ) ); } else { return; } /* * * if (pipelineMeta.findPipelineHop(candidate) == null) { spoon.newHop(pipelineMeta, candidate); } if (startErrorHopTransform) { * addErrorHop(); } if (startTargetHopStream != null) { // Auto-configure the target in the source transform... // * startTargetHopStream.setTransformMeta(candidate.getToTransform()); * startTargetHopStream.setTransformName(candidate.getToTransform().getName()); startTargetHopStream = null; } */ candidate = null; selectedTransforms = null; startHopTransform = null; endHopLocation = null; startErrorHopTransform = false; // redraw(); }
Example 16
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void showMenu(ToolBar toolBar) { Menu menu= getMenuManager().createContextMenu(toolBar); menu.setLocation(toolBar.toDisplay(0, toolBar.getSize().y)); fIsMenuUp= true; menu.setVisible(true); }
Example 17
Source File: JaretTable.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
private void dispContextMenu(Menu contextMenu, int x, int y) { Shell shell = Display.getCurrent().getActiveShell(); Point coords = Display.getCurrent().map(this, shell, x, y); contextMenu.setLocation(coords.x + shell.getLocation().x, coords.y + shell.getLocation().y); contextMenu.setVisible(true); }
Example 18
Source File: TimeGraphControl.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
@Override public void menuDetected(MenuDetectEvent e) { if (null == fTimeProvider) { return; } /* * This flag indicates if menu was prevented from being shown below and * therefore must be made visible on callback from mouseUp(). */ boolean pendingEventCallback = fPendingMenuDetectEvent != null; Point p = toControl(e.x, e.y); if (e.detail == SWT.MENU_MOUSE && isOverTimeSpace(p.x, p.y)) { if (fPendingMenuDetectEvent == null) { /* * Feature in Linux. The MenuDetectEvent is received before mouseDown. Store the * event and trigger it later just before handling mouseUp. This allows for the * method to detect if mouse is used to drag zoom. */ fPendingMenuDetectEvent = e; /* * Prevent the platform to show the menu when returning. The menu will be shown * (see below) when this method is called again during mouseUp(). */ e.doit = false; return; } fPendingMenuDetectEvent = null; if (fDragState != DRAG_ZOOM || !isInDragZoomMargin()) { /* * Don't show the menu on mouseUp() if a drag zoom is in progress with a drag * range outside of the drag zoom margin, or if any other drag operation, or * none, is in progress. */ e.doit = false; return; } } else { if (fDragState != DRAG_NONE) { /* * Don't show the menu on keyboard menu or mouse menu outside of the time space * if any drag operation is in progress. */ e.doit = false; return; } } int idx = getItemIndexAtY(p.y); if (idx >= 0 && idx < fItemData.fExpandedItems.length) { Item item = fItemData.fExpandedItems[idx]; ITimeGraphEntry entry = item.fEntry; /* Send menu event for the time graph entry */ e.doit = true; e.data = entry; fireMenuEventOnTimeGraphEntry(e); Menu menu = getMenu(); if (pendingEventCallback && e.doit && (menu != null)) { menu.setVisible(true); } /* Send menu event for time event */ if (entry.hasTimeEvents()) { ITimeEvent event = Utils.findEvent(entry, getTimeAtX(p.x), 2); if (event != null) { e.doit = true; e.data = event; fireMenuEventOnTimeEvent(e); menu = getMenu(); if (pendingEventCallback && e.doit && (menu != null)) { menu.setVisible(true); } } } } }
Example 19
Source File: RenameInformationPopup.java From typescript.java with MIT License | 4 votes |
private void showMenu(ToolBar toolBar) { Menu menu= getMenuManager().createContextMenu(toolBar); menu.setLocation(toolBar.toDisplay(0, toolBar.getSize().y)); fIsMenuUp= true; menu.setVisible(true); }
Example 20
Source File: CTree.java From nebula with Eclipse Public License 2.0 | 4 votes |
protected void handleMouseEvents(Event event) { CTreeItem item = null; if (event.widget == body) { item = getItem(event.x, event.y); } else if (event.item instanceof CTreeItem) { item = (CTreeItem) event.item; } switch (event.type) { case SWT.MouseDoubleClick: if(item != null && (selectOnToggle || !item.isToggle(event.x, event.y))) { fireSelectionEvent(true); } break; case SWT.MouseDown: if(!hasFocus) setFocus(); if(item == null) { if(event.widget == body) { item = getItem(event.x, event.y); } else if(event.item instanceof CTreeItem) { item = (CTreeItem) event.item; } } switch(event.button) { // TODO - popup menu: not just for mouse down events! case 3: Menu menu = getMenu(); if ((menu != null) && ((menu.getStyle() & SWT.POP_UP) != 0)) { menu.setVisible(true); } case 1: if(selectOnToggle || !item.isToggle(event.x, event.y)) { if(selectOnTreeToggle || !item.isTreeToggle(event.x,event.y)) { if((event.stateMask & SWT.SHIFT) != 0) { if(shiftSel == null) { if(selection.isEmpty()) selection.add(item); shiftSel = (CTreeItem) selection.get(selection.size() - 1); } setSelection(shiftSel, item); } else if((event.stateMask & SWT.CONTROL) != 0) { toggleSelection(item); shiftSel = null; } else { setSelection(item); shiftSel = null; } } } break; } break; case SWT.MouseMove: // TODO: make toggles more dynamic break; case SWT.MouseUp: if(item.isToggle(event.x,event.y)) { boolean open = item.isOpen(event.x,event.y); if(item.isTreeToggle(event.x,event.y)) { // visibleItems = null; item.setExpanded(!open); fireTreeEvent(item, !open); } else { item.getCell(event.x, event.y).setOpen(!open); } } break; } }