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