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


Java ActionContributionItem类代码示例

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


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

示例1: changeIcon

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
private static void changeIcon(final IMenuManager menu, final IContributionItem item,
		final ImageDescriptor image) {
	if (item instanceof ActionContributionItem) {
		((ActionContributionItem) item).getAction().setImageDescriptor(image);
	} else if (item instanceof CommandContributionItem) {
		final CommandContributionItemParameter data = ((CommandContributionItem) item).getData();
		data.commandId = ((CommandContributionItem) item).getCommand().getId();
		data.icon = image;
		final CommandContributionItem newItem = new CommandContributionItem(data);
		newItem.setId(item.getId());
		menu.insertAfter(item.getId(), newItem);
		menu.remove(item);
		item.dispose();
	} else if (item instanceof ActionSetContributionItem) {
		changeIcon(menu, ((ActionSetContributionItem) item).getInnerItem(), image);
	} else if (item instanceof MenuManager) {
		((MenuManager) item).setImageDescriptor(image);
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:20,代码来源:CleanupHelper.java

示例2: assertContextMenuNoActionDuplicates

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的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.ActionContributionItem; //导入依赖的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: depopulateManager

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
    * <!-- end-user-doc -->
 * @generated
 */
   protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem)contributionItem).getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:30,代码来源:SmarthomeActionBarContributor.java

示例5: depopulateManager

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem)contributionItem).getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
开发者ID:cetic,项目名称:SimQRI,代码行数:30,代码来源:MetamodelActionBarContributor.java

示例6: depopulateManager

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager,
		Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem) contributionItem)
						.getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem) contributionItem)
						.getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:33,代码来源:ChartActionBarContributor.java

示例7: BaseFolderImplementation

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的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

示例8: getPasteContribution

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
private ActionContributionItem getPasteContribution(IContributionItem[] items) {
	for (IContributionItem contributionItem : items) {
		if (StringUtils.equals(contributionItem.getId(),PASTE_ACTION_ID)) {
			return (ActionContributionItem) contributionItem;
		}
	}
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:9,代码来源:CustomEditActionProvider.java

示例9: depopulateManager

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
    if (actions != null) {
        IContributionItem[] items = manager.getItems();
        for (int i = 0; i < items.length; i++) {
            // Look into SubContributionItems
            //
            IContributionItem contributionItem = items[i];
            while (contributionItem instanceof SubContributionItem) {
                contributionItem = ((SubContributionItem) contributionItem).getInnerItem();
            }

            // Delete the ActionContributionItems with matching action.
            //
            if (contributionItem instanceof ActionContributionItem) {
                IAction action = ((ActionContributionItem) contributionItem).getAction();
                if (actions.contains(action)) {
                    manager.remove(contributionItem);
                }
            }
        }
    }
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:31,代码来源:GenconfActionBarContributor.java

示例10: setToolbarButtonTextMode

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
private void setToolbarButtonTextMode() {
    final boolean hideText = getHideTextOnButtonsOption();

    final String toggleButtonText = hideText ? Messages.getString("PendingChangesView.ShowToolbarText") //$NON-NLS-1$
        : Messages.getString("PendingChangesView.HideToolbarText"); //$NON-NLS-1$

    toggleButtonTextAction.setText(toggleButtonText);

    final int contributionMode = hideText ? 0 : ActionContributionItem.MODE_FORCE_TEXT;

    workspaceActionContribution.setMode(contributionMode);
    checkinActionContribution.setMode(contributionMode);
    shelveActionContribution.setMode(contributionMode);
    unshelveActionContribution.setMode(contributionMode);
    resolveConflictsActionContribution.setMode(contributionMode);

    getViewSite().getActionBars().getToolBarManager().update(false);
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:19,代码来源:PendingChangesView.java

示例11: setCheckedItem

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
private void setCheckedItem(final IMenuManager menuManager) {
    for (final IContributionItem item : menuManager.getItems()) {
        if (item instanceof ActionContributionItem) {
            /*
             * Actions at the top level are navigation actions. Set the
             * check mark for the action associated with the current
             * navigation item. Clear the check mark for all others.
             */
            final ActionContributionItem actionContributionItem = (ActionContributionItem) item;
            final String actionID = actionContributionItem.getAction().getId();

            actionContributionItem.getAction().setChecked(
                actionID != null && actionID.equals(currentNavItem.getID()));
        }
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:17,代码来源:TeamExplorerControl.java

示例12: getSubActionMenu

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
protected Menu getSubActionMenu(final Control parent) {
    if (subActionMenu != null) {
        return subActionMenu;
    }

    subActionMenu = new Menu(parent);

    for (final Iterator<IAction> it = subActions.iterator(); it.hasNext();) {
        final IAction subAction = it.next();
        final ActionContributionItem aci = new ActionContributionItem(subAction);
        aci.fill(subActionMenu, -1);
        final MenuItem menuItem = subActionMenu.getItem(subActionMenu.getItemCount() - 1);
        menuItem.addSelectionListener(menuItemSelectionListener);
    }

    return subActionMenu;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:18,代码来源:ToolbarPulldownAction.java

示例13: fireAuthEnable

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
public void fireAuthEnable( boolean enabled){
   IToolBarManager toolbar = this.getViewSite().getActionBars().getToolBarManager();
   IContributionItem[] items = toolbar.getItems();

   for (IContributionItem it : items) {
      if (it instanceof ActionContributionItem) {
         ActionContributionItem aci = (ActionContributionItem) it;
         if (aci.getAction() instanceof AuthenticationAction) {
            AuthenticationAction aa = (AuthenticationAction) aci.getAction();
            String img = null;
            if (enabled) {
               img = CoreImages.AUTH_ENABLED;
            } else {
               img = CoreImages.AUTH;
            }
            aa.setImageDescriptor(ImageDescriptor.createFromImage(ResourceUtils.getImage(CoreConstants.PLUGIN_UI, img)));
         }
      }
   }
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:21,代码来源:HdViewPart.java

示例14: fireProxyEnable

import org.eclipse.jface.action.ActionContributionItem; //导入依赖的package包/类
public void fireProxyEnable( boolean enabled){
   IToolBarManager toolbar = this.getViewSite().getActionBars().getToolBarManager();
   IContributionItem[] items = toolbar.getItems();
   for (IContributionItem it : items) {
      if (it instanceof ActionContributionItem) {
         ActionContributionItem aci = (ActionContributionItem) it;
         if (aci.getAction() instanceof ProxyAction) {
            ProxyAction aa = (ProxyAction) aci.getAction();
            String img = null;
            if (enabled) {
               img = CoreImages.PROXY_ENABLED;
            } else {
               img = CoreImages.PROXY;
            }
            aa.setImageDescriptor(ImageDescriptor.createFromImage(ResourceUtils.getImage(CoreConstants.PLUGIN_UI, img)));
         }
      }
   }
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:20,代码来源:HdViewPart.java


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