Search in sources :

Example 16 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project erlide_eclipse by erlang.

the class UserRefacContribution method getContributionItems.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected IContributionItem[] getContributionItems() {
    final List<UserRefactoringInfo> refacs = UserRefactoringsManager.getInstance().getElementary();
    final IContributionItem[] items = new IContributionItem[refacs.size()];
    int i = 0;
    for (final UserRefactoringInfo info : refacs) {
        final CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench(), info.getCallback(), "org.erlide.wrangler.refactoring.gen_refac", CommandContributionItem.STYLE_PUSH);
        param.label = info.getLabel();
        param.parameters = new HashMap();
        param.parameters.put("org.erlide.wrangler.refactoring.gen_refac.callback", info.getCallback());
        param.parameters.put("org.erlide.wrangler.refactoring.gen_refac.name", info.getLabel());
        items[i] = new CommandContributionItem(param);
        i++;
    }
    return items;
}
Also used : HashMap(java.util.HashMap) IContributionItem(org.eclipse.jface.action.IContributionItem) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) UserRefactoringInfo(org.erlide.wrangler.refactoring.backend.UserRefactoringInfo)

Example 17 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project vorto by eclipse.

the class PopulateGeneratorsMenu method constructCommandForGenerator.

@SuppressWarnings("unchecked")
private CommandContributionItem constructCommandForGenerator(ExtensionMetaData extensionMetaData) {
    String extensionIdentifier = extensionMetaData.getExtensionIdentifier();
    if (StringUtils.isNotEmpty(extensionIdentifier)) {
        CommandContributionItemParameter generatorCommand = new CommandContributionItemParameter(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), "org.eclipse.vorto.codegen.dynamic.menu.contribution.item.id", "org.eclipse.vorto.codegen.generator.command.id", SWT.NONE);
        CommandContributionItem generatorContributionItem;
        generatorCommand.label = extensionMetaData.getMenuLabel();
        String iconPath = extensionMetaData.getIconPath();
        Bundle bundle = Platform.getBundle(extensionMetaData.getGeneratorPluginId());
        if (iconPath == null) {
            // Load the defaults
            iconPath = "icons/generate.gif";
            bundle = Platform.getBundle(Activator.PLUGIN_ID);
        }
        IPath path = new Path(iconPath);
        generatorCommand.icon = ImageDescriptor.createFromURL(FileLocator.find(bundle, path, null));
        generatorCommand.parameters = new HashMap<String, String>();
        generatorCommand.parameters.put("org.eclipse.vorto.codegen.generator.commandParameter", extensionIdentifier);
        generatorContributionItem = new CommandContributionItem(generatorCommand);
        return generatorContributionItem;
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Bundle(org.osgi.framework.Bundle) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 18 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project liferay-ide by liferay.

the class LaunchWorkspaceMenu method createContributionItems.

@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
    MenuManager menu = new MenuManager("Launch Workspace");
    IContributionItem[] workspaceHistoryItems = _buildWorkspaceHistory(serviceLocator);
    for (IContributionItem workspaceHistoryItem : workspaceHistoryItems) {
        if (workspaceHistoryItem instanceof CommandContributionItem) {
            CommandContributionItem commandItem = (CommandContributionItem) workspaceHistoryItem;
            if ("Other...".equals(commandItem.getData().label)) {
                menu.add(new Separator());
            }
        }
        menu.add(workspaceHistoryItem);
    }
    additions.addContributionItem(menu, null);
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) MenuManager(org.eclipse.jface.action.MenuManager) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) Separator(org.eclipse.jface.action.Separator)

Example 19 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project liferay-ide by liferay.

the class LaunchWorkspaceMenu method _newLaunchWorkspaceCommand.

@SuppressWarnings("unchecked")
private IContributionItem _newLaunchWorkspaceCommand(IServiceLocator serviceLocator, String label, String workspaceLocation) {
    CommandContributionItemParameter parameter = new CommandContributionItemParameter(serviceLocator, "", LaunchWorkspaceHandler.COMMAND_ID, CommandContributionItem.STYLE_PUSH);
    if (workspaceLocation != null) {
        parameter.parameters = new HashMap<>();
        parameter.parameters.put(LaunchWorkspaceHandler.PARAM_WORKSPACE_LOCATION, workspaceLocation);
    }
    parameter.label = label;
    CommandContributionItem launchWorkspaceCommand = new CommandContributionItem(parameter);
    launchWorkspaceCommand.setVisible(true);
    return launchWorkspaceCommand;
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 20 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project core by jcryptool.

the class AlgorithmView method createContributionItem.

private CommandContributionItem createContributionItem(final String commandId, final ImageDescriptor icon, final String tooltip) {
    CommandContributionItemParameter param = new CommandContributionItemParameter(serviceLocator, null, commandId, SWT.PUSH);
    if (icon != null)
        param.icon = icon;
    if (tooltip != null && !tooltip.equals(""))
        param.tooltip = tooltip;
    CommandContributionItem item = new CommandContributionItem(param);
    return (item);
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Aggregations

CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)31 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)25 IContributionItem (org.eclipse.jface.action.IContributionItem)10 HashMap (java.util.HashMap)7 ArrayList (java.util.ArrayList)4 Separator (org.eclipse.jface.action.Separator)3 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)2 MenuManager (org.eclipse.jface.action.MenuManager)2 IMenuService (org.eclipse.ui.menus.IMenuService)2 UserRefactoringInfo (org.erlide.wrangler.refactoring.backend.UserRefactoringInfo)2 DBException (org.jkiss.dbeaver.DBException)2 DatabaseLoadService (org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService)2 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)2 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DecimalFormat (java.text.DecimalFormat)1 java.util (java.util)1 List (java.util.List)1