当前位置: 首页>>代码示例>>Java>>正文


Java MenuManager类代码示例

本文整理汇总了Java中org.eclipse.jface.action.MenuManager的典型用法代码示例。如果您正苦于以下问题:Java MenuManager类的具体用法?Java MenuManager怎么用?Java MenuManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MenuManager类属于org.eclipse.jface.action包,在下文中一共展示了MenuManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTopLevelElementsEntryNoDuplicates

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * Tests that the Top Level Elements
 */
@Test
public void testTopLevelElementsEntryNoDuplicates() {
	IActionBars actionBars = projectExplorer.getViewSite().getActionBars();
	IMenuManager menuManager = actionBars.getMenuManager();

	int topLevelElementsEntriesFound = 0;

	for (IContributionItem item : menuManager.getItems()) {
		if (item instanceof MenuManager) {
			String escapedMenuText = LegacyActionTools.removeMnemonics(((MenuManager) item).getMenuText());
			if (escapedMenuText.equals("Top Level Elements")) {
				topLevelElementsEntriesFound++;
			}
		}
	}

	assertEquals("There was more than one 'Top Level Elements' entry in the navigator action bar.",
			topLevelElementsEntriesFound, 1);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:SelectAllProjectExplorer_PluginUITest.java

示例2: assertContextMenuNoActionDuplicates

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * Asserts that the context menu for the current navigator selection does not contain any duplicates.
 *
 * That is, two menu items that represent an action of the same class.
 */
private void assertContextMenuNoActionDuplicates() {
	MenuManager menu = new MenuManager();
	projectExplorer.getNavigatorActionService().fillContextMenu(menu);
	List<ActionContributionItem> actionContributions = Arrays.asList(menu.getItems()).stream()
			.filter(i -> i instanceof ActionContributionItem)
			.map(i -> ((ActionContributionItem) i))
			.collect(Collectors.toList());

	Map<String, ActionContributionItem> contributionNameMap = new HashMap<>();

	for (ActionContributionItem item : actionContributions) {
		ActionContributionItem mapItem = contributionNameMap.putIfAbsent(item.getAction().getText(), item);
		if (mapItem != null) {
			IAction mapAction = mapItem.getAction();
			IAction otherAction = item.getAction();

			// Double check if action is of the same type
			if (mapAction.getClass().equals(otherAction.getClass())) {
				fail("Action '" + mapAction.getClass().getSimpleName()
						+ "' is contributed twice to the context menu: "
						+ mapAction.toString() + " " + otherAction.toString());
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:31,代码来源:SelectAllProjectExplorer_PluginUITest.java

示例3: getContextMenuContributions

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * Returns the menu contribution titles of the project navigator context menu.
 *
 * This only includes {@link ActionContributionItem}s and {@link MenuManager}s.
 */
private List<String> getContextMenuContributions() {
	MenuManager menu = new MenuManager();
	projectExplorer.getNavigatorActionService().fillContextMenu(menu);
	return Arrays.asList(menu.getItems()).stream()
			.map(i -> {
				if (i instanceof ActionContributionItem) {
					// use action name
					return ((ActionContributionItem) i).getAction().getText();
				} else if (i instanceof MenuManager) {
					// use sub-menu title
					return ((MenuManager) i).getMenuText();
				} else {
					// null for other types of contributions
					return null;
				}
			})
			.filter(t -> null != t)
			// remove mnemonics (e.g. Close &Project -> Close Project))
			.map(text -> LegacyActionTools.removeMnemonics(text))
			.collect(Collectors.toList());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:SelectAllProjectExplorer_PluginUITest.java

示例4: createContextMenuFor

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * 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 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:ProtocolEditor.java

示例5: createContextMenuFor

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * 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 NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] {
            LocalTransfer.getInstance (),
            LocalSelectionTransfer.getTransfer (),
            FileTransfer.getInstance (),
            ItemTransfer.getInstance ()
    };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:ChartEditor.java

示例6: createContextMenuFor

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * 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 -->
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" );
    contextMenu.add ( new Separator ( "additions" ) );
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( this.editingDomain, viewer ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:21,代码来源:ChartConfiguratorView.java

示例7: populateManager

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.MenuManager}s containing
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> collection, by inserting them before the specified contribution
 * item <code>contributionID</code>.
 * If <code>contributionID</code> is <code>null</code>, they are simply added.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void populateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions, String contributionID )
{
    if ( submenuActions != null )
    {
        for ( Map.Entry<String, Collection<IAction>> entry : submenuActions.entrySet () )
        {
            MenuManager submenuManager = new MenuManager ( entry.getKey () );
            if ( contributionID != null )
            {
                manager.insertBefore ( contributionID, submenuManager );
            }
            else
            {
                manager.add ( submenuManager );
            }
            populateManager ( submenuManager, entry.getValue (), null );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:30,代码来源:DetailViewActionBarContributor.java

示例8: depopulateManager

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:DetailViewActionBarContributor.java

示例9: BaseFolderImplementation

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
public BaseFolderImplementation ( final int index, final String label, final MenuManager mgr )
{
    this.summaryInformation = new SummaryInformation ( Collections.<String, DataValue> emptyMap () );
    this.index = index;
    this.label = label;
    this.mgr = mgr;

    this.dumpAction = new Action ( "Dump summaries for: " + this.label ) {
        @Override
        public void run ()
        {
            BaseFolderImplementation.this.summaryInformation.dump ( System.out );
        };
    };
    this.contribution = new ActionContributionItem ( this.dumpAction );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:BaseFolderImplementation.java

示例10: createTextMenu

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * Create the context menu for the text widget.
 * 
 * @since 3.4
 */
private void createTextMenu() {
	final MenuManager textManager = new MenuManager();
	textManager.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(),
			null, IWorkbenchCommandConstants.EDIT_COPY, CommandContributionItem.STYLE_PUSH)));
	textManager.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(),
			null, IWorkbenchCommandConstants.EDIT_SELECT_ALL, CommandContributionItem.STYLE_PUSH)));
	text.setMenu(textManager.createContextMenu(text));
	text.addDisposeListener(new DisposeListener() {

		public void widgetDisposed(DisposeEvent e) {
			textManager.dispose();
		}
	});

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:21,代码来源:CustomAboutDialog.java

示例11: createContextMenuFor

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * 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" );
    contextMenu.add ( new Separator ( "additions" ) );
    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 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:MemoryEditor.java

示例12: createActions

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
/**
 * Create the actions
 */
private void createActions() {
	final IContributionManager man = getViewSite().getActionBars().getToolBarManager();

	final Action restart = new Action("Clear", Activator.getImageDescriptor("icons/layers-stack.png")) {
		@Override
		public void run() {
			clear();
		}
	};
	man.add(restart);

	final MenuManager menuMan = new MenuManager();
	menuMan.add(restart);

	text.setMenu(menuMan.createContextMenu(text));
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:20,代码来源:ValidateResultsView.java

示例13: createViewMenu

import org.eclipse.jface.action.MenuManager; //导入依赖的package包/类
private void createViewMenu(MenuManager menuManager) {
	MenuManager viewMenu = createMenu(menuManager, MenuConstants.VIEW);
	menuManager.add(viewMenu);
	viewMenu.setVisible(true);

	if (actionFactory == null) {
		actionFactory = new ActionFactory(this);
	}
	
	viewMenu.add(actionFactory.getAction(GridViewAction.class.getName()));
	viewMenu.add(actionFactory.getAction(FormattedViewAction.class.getName()));
	viewMenu.add(actionFactory.getAction(UnformattedViewAction.class.getName()));
	viewMenu.add(new Separator());
	viewMenu.add(actionFactory.getAction(ReloadAction.class.getName()));
	viewDataPreferencesVO = getViewDataPreferencesFromPreferenceFile();
	viewMenu.add(actionFactory.getAction(PreferencesAction.class.getName()));
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:18,代码来源:DebugDataViewer.java


注:本文中的org.eclipse.jface.action.MenuManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。