當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。