org.eclipse.swt.widgets.Menu Java Examples

The following examples show how to use org.eclipse.swt.widgets.Menu. 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 Project: pentaho-kettle   Author: pentaho   File: RunConfigurationPopupMenuExtension.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object extension )
  throws KettleException {
  Menu popupMenu = null;

  Tree selectionTree = (Tree) extension;
  TreeSelection[] objects = spoonSupplier.get().getTreeObjects( selectionTree );
  TreeSelection object = objects[ 0 ];
  Object selection = object.getSelection();

  if ( selection == RunConfiguration.class ) {
    popupMenu = createRootPopupMenu( selectionTree );
  } else if ( selection instanceof String ) {
    runConfiguration = (String) selection;
    if ( runConfiguration.equalsIgnoreCase( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) {
      return;
    }
    popupMenu = createItemPopupMenu( selectionTree );
  }

  if ( popupMenu != null ) {
    ConstUI.displayMenu( popupMenu, selectionTree );
  } else {
    selectionTree.setMenu( null );
  }
}
 
Example #2
Source Project: hop   Author: project-hop   File: GuiMenuWidgets.java    License: Apache License 2.0 6 votes vote down vote up
public void createMenuWidgets( String root, Shell shell, Menu parent ) {
  // Find the GUI Elements for the given class...
  //
  GuiRegistry registry = GuiRegistry.getInstance();

  // Loop over the GUI elements and create menus all the way down...
  // We used the same ID for root and top level menu
  //
  List<GuiMenuItem> guiMenuItems = registry.findChildGuiMenuItems( root, root );
  if ( guiMenuItems.isEmpty()) {
    System.err.println( "Create menu widgets: no GUI menu items found for root: " + root);
    return;
  }

  // Sort by ID to get a stable UI
  //
  Collections.sort(guiMenuItems);

  for (GuiMenuItem guiMenuItem : guiMenuItems) {
    addMenuWidgets( root, shell, parent, guiMenuItem );
  }
}
 
Example #3
Source Project: neoscada   Author: eclipse   File: ProtocolEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #4
Source Project: tmxeditor8   Author: heartsome   File: MenuItemProviders.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider renameColumnMenuItemProvider(final String label) {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
			menuItem.setText(label);
			menuItem.setEnabled(true);

			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent event) {
					natTable.doCommand(new DisplayColumnRenameDialogCommand(natTable, getNatEventData(event).getColumnPosition()));
				}
			});
		}
	};
}
 
Example #5
Source Project: nebula   Author: eclipse   File: AbstractPictureControl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the menu with "Delete", "Modify" Item.
 *
 * @param parent
 * @return
 */
protected Menu createMenu(Control parent) {
	Menu menu = new Menu(parent);

	// "Delete" menu item.
	deleteItem = new MenuItem(menu, SWT.NONE);
	deleteItem.setText(resources.getString(PICTURE_CONTROL_DELETE));
	deleteItem.addListener(SWT.Selection, e -> {
		// Delete the image.
		AbstractPictureControl.this.handleDeleteImage();
	});

	// "Modify" menu item.
	final MenuItem modifyItem = new MenuItem(menu, SWT.NONE);
	modifyItem.setText(resources.getString(PICTURE_CONTROL_MODIFY));
	modifyItem.addListener(SWT.Selection, e -> {
		// Modify the image.
		AbstractPictureControl.this.handleModifyImage();
	});
	return menu;
}
 
Example #6
Source Project: gwt-eclipse-plugin   Author: gwt-plugins   File: LaunchConfigurationContent.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void createContextMenu() {
  MenuManager menuMgr = new MenuManager("#PopupMenu");
  menuMgr.setRemoveAllWhenShown(true);
  menuMgr.addMenuListener(new IMenuListener() {
    @Override
    public void menuAboutToShow(IMenuManager manager) {
      populateBrowserActions(launchConfiguration, manager);
      manager.add(new Separator());

      manager.add(new Action("&Copy") {
        @Override
        public void run() {
          copySelectionToClipboard();
        }
      });
    }
  });
  Menu menu = menuMgr.createContextMenu(viewer.getControl());
  viewer.getControl().setMenu(menu);
}
 
Example #7
Source Project: xtext-eclipse   Author: eclipse   File: EmbeddedEditorActions.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected void initialize() {
	createFocusAndDisposeListeners();

	createActions();

	// create context menu
	MenuManager manager = new MenuManager(null, null);
	manager.setRemoveAllWhenShown(true);
	manager.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager mgr) {
			fillContextMenu(mgr);
		}
	});

	StyledText text = viewer.getTextWidget();
	Menu menu = manager.createContextMenu(text);
	text.setMenu(menu);
	
	List<ActionActivationCode> activationCodes = Lists.newArrayList();
	setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_RIGHT_TAB,'\t', -1, SWT.NONE);
	setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
	viewer.getTextWidget().addVerifyKeyListener(new ActivationCodeTrigger(allActions, activationCodes));
}
 
Example #8
Source Project: neoscada   Author: eclipse   File: VisualInterfaceEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example #9
Source Project: APICloud-Studio   Author: apicloudcom   File: SwitchThemesPulldownContributionItem.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void fill(Menu menu, int index)
{
	IThemeManager manager = ThemePlugin.getDefault().getThemeManager();
	List<String> themeNames = new ArrayList<String>(manager.getThemeNames());
	// sort ignoring case
	Collections.sort(themeNames, new Comparator<String>()
	{
		public int compare(String o1, String o2)
		{
			return o1.compareToIgnoreCase(o2);
		}
	});
	for (String name : themeNames)
	{
		IContributionItem item = new SwitchThemeContributionItem(manager, name);
		item.fill(menu, menu.getItemCount());
	}
}
 
Example #10
Source Project: Pydev   Author: fabioz   File: SWTUtil.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source Project: elexis-3-core   Author: elexis   File: NatTableWrapper.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void addContextMenu(String string, IWorkbenchPartSite iWorkbenchPartSite){
	
	MenuManager mgr = new MenuManager();
	Menu popupmenu = new PopupMenuBuilder(natTable, mgr).build();
	iWorkbenchPartSite.registerContextMenu(string, mgr, null);
	
	natTable.addConfiguration(new AbstractUiBindingConfiguration() {
		
		@Override
		public void configureUiBindings(UiBindingRegistry uiBindingRegistry){
			uiBindingRegistry.registerMouseDownBinding(
				new MouseEventMatcher(SWT.NONE, null, MouseEventMatcher.RIGHT_BUTTON),
				new PopupMenuAction(popupmenu));
		}
	});
}
 
Example #12
Source Project: saros   Author: saros-project   File: StartSessionWithProjects.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final Menu menu, final int index) {
  final List<JID> contacts =
      SelectionRetrieverFactory.getSelectionRetriever(JID.class).getSelection();

  final IProject[] projects = getSortedWorkspaceProjects();

  if (projects.length == 0) {
    createNoProjectsMenuItem(menu, 0);
    return;
  }

  int idx;

  for (idx = 0; idx < projects.length; idx++)
    createProjectMenuItem(menu, idx, projects[idx], contacts);

  if (idx > 1) {
    new MenuItem(menu, SWT.SEPARATOR, idx++);
    createMultipleProjectMenuItem(menu, idx);
  }
}
 
Example #13
Source Project: tmxeditor8   Author: heartsome   File: MenuItemProviders.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider clearToggleFilterRowMenuItemProvider(final String menuLabel) {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
			menuItem.setText(menuLabel);
			menuItem.setImage(GUIHelper.getImage("toggle_filter"));
			menuItem.setEnabled(true);

			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new ToggleFilterRowCommand());
				}
			});
		}
	};
}
 
Example #14
Source Project: slr-toolkit   Author: sebastiangoetz   File: BibtexEntryView.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void hookContextMenu() {
	MenuManager menuMgr = new MenuManager("#PopupMenu");
	menuMgr.setRemoveAllWhenShown(true);
	menuMgr.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager) {
			IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
			if(s.getFirstElement() instanceof DocumentImpl) {
				fillContextMenu(manager);
			}
		}
	});
	Menu menu = menuMgr.createContextMenu(viewer.getControl());
	viewer.getControl().setMenu(menu);
	getSite().registerContextMenu(menuMgr, viewer);
}
 
Example #15
Source Project: bonita-studio   Author: bonitasoft   File: AbstractMenuContributionItem.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("restriction")
protected MenuItem createMenu(Menu parent, String command, Optional<Image> image) {
    MenuItem item = new MenuItem(parent, SWT.NONE);
    ParameterizedCommand parameterizedCommand = createParametrizedCommand(command);
    try {
        item.setText(parameterizedCommand.getName());
    } catch (NotDefinedException e) {
        BonitaStudioLog.error(
                String.format("The command '%s' doesn't have any name defined.", parameterizedCommand.getId()), e);
        item.setText(parameterizedCommand.getId());
    }
    item.addListener(SWT.Selection, e -> {
        if (eHandlerService.canExecute(parameterizedCommand)) {
            eHandlerService.executeHandler(parameterizedCommand);
        } else {
            throw new RuntimeException(String.format("Can't execute command %s", parameterizedCommand.getId()));
        }
    });
    item.setEnabled(true);
    appendShortcut(parameterizedCommand, item);
    image.ifPresent(item::setImage);
    return item;
}
 
Example #16
Source Project: pmTrans   Author: juanerasmoe   File: MenuManager.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private MenuItem addConfigurableMenuItem(Menu menu, final String orgText,
		final String acceleratorKey, SelectionListener listener) {
	char accelerator = Config.getInstance().getString(acceleratorKey)
			.toUpperCase().charAt(0);
	int acc = SWT.MOD1 + (accelerator == ' ' ? SWT.SPACE : accelerator);
	String text = orgText + " \t Ctrl+"
			+ (accelerator == ' ' ? "[space]" : accelerator);

	final MenuItem item = addMenuItem(menu, text, acc, listener);

	Config.getInstance().addPropertyChangeListener(
			new IPropertyChangeListener() {
				public void propertyChange(PropertyChangeEvent arg0) {
					if (arg0.getProperty().equals(acceleratorKey))
						updateAccelerator(item, orgText, Config
								.getInstance().getString(acceleratorKey)
								.toUpperCase().charAt(0));
				}
			});

	return item;
}
 
Example #17
Source Project: gama   Author: gama-platform   File: OutputsMenu.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void outputSubMenu(final Menu main, final IScope scope, final IOutputManager manager,
		final IDisplayOutput output) {
	final MenuItem item = new MenuItem(main, SWT.CASCADE);
	item.setText(output.getOriginalName());
	final Menu sub = new Menu(item);
	item.setMenu(sub);
	if (output.isOpen()) {
		// menuItem(sub, e -> output.close(), null, "Close");
		if (output.isPaused())
			menuItem(sub, e -> output.setPaused(false), null, "Resume");
		else
			menuItem(sub, e -> output.setPaused(true), null, "Pause");
		menuItem(sub, e -> output.update(), null, "Refresh");
		if (output.isSynchronized())
			menuItem(sub, e -> output.setSynchronized(false), null, "Unsynchronize");
		else
			menuItem(sub, e -> output.setSynchronized(true), null, "Synchronize");
	} else
		menuItem(sub, e -> manager.open(scope, output), null, "Reopen");

}
 
Example #18
Source Project: APICloud-Studio   Author: apicloudcom   File: SWTUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source Project: saros   Author: saros-project   File: StartSessionWithProjects.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** Creates a menu entry which shares projects with the given Contacts. */
private MenuItem createProjectMenuItem(
    final Menu parentMenu, final int index, final IProject project, final List<JID> contacts) {

  final MenuItem menuItem = new MenuItem(parentMenu, SWT.NONE, index);

  menuItem.setText(workbenchLabelProvider.getText(project));
  menuItem.setImage(workbenchLabelProvider.getImage(project));

  menuItem.addSelectionListener(
      new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          CollaborationUtils.startSession(
              Collections.<IResource>singletonList(project), contacts);
        }
      });

  return menuItem;
}
 
Example #20
Source Project: gama   Author: gama-platform   File: AgentsMenu.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static MenuItem cascadingAgentMenuItem(final Menu parent, final IAgent agent, final String title,
		final MenuAction... actions) {
	final MenuItem result = new MenuItem(parent, SWT.CASCADE);
	result.setText(title);
	Image image;
	if (agent instanceof SimulationAgent) {
		final SimulationAgent sim = (SimulationAgent) agent;
		image = GamaIcons.createTempRoundColorIcon(GamaColors.get(sim.getColor()));
	} else {
		image = GamaIcons.create(IGamaIcons.MENU_AGENT).image();
	}
	result.setImage(image);
	final Menu agentMenu = new Menu(result);
	result.setMenu(agentMenu);
	createMenuForAgent(agentMenu, agent, agent instanceof ITopLevelAgent, true, actions);
	return result;
}
 
Example #21
Source Project: arx   Author: arx-deidentifier   File: MainMenu.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param shell
 * @param controller
 * @param items
 */
public MainMenu(final Shell shell, final Controller controller, final List<MainMenuItem> items) {
    super(controller);

    // Create Menu
    this.menu = new Menu(shell, SWT.BAR);
    
    // Create items
    this.createItems(menu, items);

    // Set menu bar
    shell.setMenuBar(this.menu);
    
    // Enhance experience on OSX
    SWTUtil.fixOSXMenu(controller);
    
    // Initialize
    this.update(new ModelEvent(this, ModelPart.MODEL, null));
}
 
Example #22
Source Project: tmxeditor8   Author: heartsome   File: MenuItemProviders.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider createColumnGroupMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
			columnStyleEditor.setText("Create column group");
			columnStyleEditor.setEnabled(true);

			columnStyleEditor.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new OpenCreateColumnGroupDialog(natTable.getShell()));
				}
			});
		}
	};
}
 
Example #23
Source Project: pentaho-kettle   Author: pentaho   File: ConnectionPopupMenuExtension.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object extension )
  throws KettleException {
  Menu popupMenu = null;

  Tree selectionTree = (Tree) extension;
  TreeSelection[] objects = spoonSupplier.get().getTreeObjects( selectionTree );
  TreeSelection object = objects[ 0 ];
  Object selection = object.getSelection();

  if ( selection == VFSConnectionDetails.class ) {
    popupMenu = createRootPopupMenu( selectionTree );
  } else if ( selection instanceof ConnectionTreeItem ) {
    vfsConnectionTreeItem = (ConnectionTreeItem) selection;
    popupMenu = createItemPopupMenu( selectionTree );
  }

  if ( popupMenu != null ) {
    ConstUI.displayMenu( popupMenu, selectionTree );
  } else {
    selectionTree.setMenu( null );
  }
}
 
Example #24
Source Project: neoscada   Author: eclipse   File: NativeTabProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public NativeTabProvider ( final Composite box )
{
    this.folder = new TabFolder ( box, SWT.NONE );
    this.folder.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );

    this.mgr = new MenuManager ();
    final Menu menu = this.mgr.createContextMenu ( this.folder );
    this.folder.setMenu ( menu );
}
 
Example #25
Source Project: BiglyBT   Author: BiglySoftware   File: SBC_TorrentDetailsView.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void menuWillBeShown(MdiEntry entry, Menu menuTree) {
	// todo: This even work?
	TableView<?> tv = SelectedContentManager.getCurrentlySelectedTableView();
	menuTree.setData("TableView", tv);
	DownloadManager manager = DataSourceUtils.getDM(((BaseMdiEntry) entry).getDatasourceCore());
	if (manager != null) {
		menuTree.setData("downloads", new DownloadManager[] {
			manager
		});
	}
	menuTree.setData("is_detailed_view", Boolean.TRUE);

	MenuFactory.buildTorrentMenu(menuTree);
}
 
Example #26
Source Project: xds-ide   Author: excelsior-oss   File: XFindPanel.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void showSettings() {
        final MenuManager manager = new MenuManager();
        fillSettingsMenu(manager);
        final Menu menu = manager.createContextMenu(toolBar);

//        menu.setLocation(toolBar.getDisplay().getCursorLocation());
        menu.setLocation(getToolItemLocation(bSettings));
        
        menu.setVisible(true);
    }
 
Example #27
Source Project: gama   Author: gama-platform   File: EditorMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 *
 */
private void createFoldingToggle(final Menu menu) {
	final MenuItem folding = new MenuItem(menu, SWT.CHECK);
	folding.setText(" Fold code sections");
	folding.setImage(GamaIcons.create("toggle.folding").image());
	folding.setSelection(getEditor().isRangeIndicatorEnabled());
	folding.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent e) {
			getEditor().getAction("FoldingToggle").run();
		}
	});

}
 
Example #28
Source Project: birt   Author: eclipse   File: ProjectFileDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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 #29
Source Project: neoscada   Author: eclipse   File: EclipseTabProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public EclipseTabProvider ( final Composite parent )
{
    this.folder = new CTabFolder ( parent, SWT.TOP | SWT.FLAT | SWT.BORDER );
    this.folder.setTabHeight ( 24 );
    this.folder.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );

    this.mgr = new MenuManager ();
    final Menu menu = this.mgr.createContextMenu ( this.folder );
    this.folder.setMenu ( menu );
}
 
Example #30
Source Project: xds-ide   Author: excelsior-oss   File: XFindPanel.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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);
        }
    }