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


Java IHandlerService.executeCommand方法代码示例

本文整理汇总了Java中org.eclipse.ui.handlers.IHandlerService.executeCommand方法的典型用法代码示例。如果您正苦于以下问题:Java IHandlerService.executeCommand方法的具体用法?Java IHandlerService.executeCommand怎么用?Java IHandlerService.executeCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.handlers.IHandlerService的用法示例。


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

示例1: execute

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_IMPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_IMPORT_PARM_WIZARDID,
              SessionImportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ImportSessionHandler.java

示例2: execute

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_EXPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_EXPORT_PARM_WIZARDID,
              SessionExportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ExportSessionHandler.java

示例3: callRuleGenerationCommand

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private boolean callRuleGenerationCommand(EPackage ePack, PatternInstance pattern, IPath iPath) {
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	ICommandService commandService = serviceLocator.getService(ICommandService.class);
	IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
	Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation.rule");
	try {
		IParameter parameter = command.getParameter(MACLCommandContext.ID);
		String contextId = UUID.randomUUID().toString();
		Activator.put(contextId, context);
		Parameterization parameterization = new Parameterization(parameter, contextId);
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
		return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
		
	} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
		return false;
	}
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:18,代码来源:MACLIncQueryGenerator.java

示例4: execute

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
@Override
public boolean execute(EPackage ePack, PatternInstance pattern, IPath iPath) {
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	ICommandService commandService = serviceLocator.getService(ICommandService.class);
	IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
	Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation");
	try {
		IParameter parameter = command.getParameter(MACLCommandContext.ID);
		MACLCommandContext context = new MACLCommandContext(ePack, pattern, iPath);
		String contextId = UUID.randomUUID().toString();
		Activator.put(contextId, context);
		Parameterization parameterization = new Parameterization(parameter, contextId);
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
		return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
		
	} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
		return false;
	}
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:20,代码来源:MACLPatternImplementation.java

示例5: paste

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
/**
 * In the console context, use paste as
 * in some consoles (e.g. org.eclipse.debug.internal.ui.views.console.ProcessConsole), updateText
 * will not simulate keyboard input
 *  
 * @param event the ExecutionEvent
 * @param widget The consoles StyledText widget
 */
protected void paste(ExecutionEvent event, StyledText widget) {
		IWorkbenchPart apart = HandlerUtil.getActivePart(event);
		if (apart != null) {
			try {
				IWorkbenchPartSite site = apart.getSite();
				if (site != null) {
					IHandlerService service = (IHandlerService) site.getService(IHandlerService.class);
					if (service != null) {
						service.executeCommand(IEmacsPlusCommandDefinitionIds.EMP_PASTE, null);
						KillRing.getInstance().setYanked(true);
					}
				}
			} catch (CommandException e) {
			}
		}
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:25,代码来源:BaseYankHandler.java

示例6: executeCommand

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private static Object executeCommand(String commandId, Map<String,?> parameters, Event event, ICommandService ics, IHandlerService ihs)
throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException, CommandException {
	Object result = null;
	if (ics != null && ihs != null) {
		Command command = ics.getCommand(commandId);
		if (command != null) {
			try {
				MarkUtils.setIgnoreDispatchId(true);
				ParameterizedCommand pcommand = ParameterizedCommand.generateCommand(command, parameters);
				if (pcommand != null) {
					result = ihs.executeCommand(pcommand, event);
				}
			} finally {
				MarkUtils.setIgnoreDispatchId(false);
			}		
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:20,代码来源:EmacsPlusUtils.java

示例7: executeWithParams

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public static void executeWithParams(PersistentObject parameter){
	try {
		// get the command
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
		Command cmd = cmdService.getCommand(EditEigenleistungUi.COMMANDID);
		// create the parameter
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put(EditEigenleistungUi.PARAMETERID, parameter);
		// build the parameterized command
		ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param);
		// execute the command
		IHandlerService handlerService =
			(IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getService(IHandlerService.class);
		handlerService.executeCommand(pc, null);
	} catch (Exception ex) {
		throw new RuntimeException(EditEigenleistungUi.COMMANDID, ex);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:21,代码来源:EditEigenleistungUi.java

示例8: executeWithParams

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public static void executeWithParams(PersistentObject parameter){
	try {
		// get the command
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
		Command cmd = cmdService.getCommand(EditEigenartikelUi.COMMANDID);
		// create the parameter
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put(EditEigenartikelUi.PARAMETERID, parameter);
		// build the parameterized command
		ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param);
		// execute the command
		IHandlerService handlerService =
			(IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getService(IHandlerService.class);
		handlerService.executeCommand(pc, null);
	} catch (Exception ex) {
		throw new RuntimeException(EditEigenleistungUi.COMMANDID, ex);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:21,代码来源:EditEigenartikelUi.java

示例9: ExecuteWithParams

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public static Object ExecuteWithParams(IViewSite origin, Tree<?> tSelection){
	IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class);
	ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class);
	try {
		Command command = cmdService.getCommand(ID);
		Parameterization px =
			new Parameterization(command.getParameter("ch.elexis.RechnungErstellen.parameter"), //$NON-NLS-1$
				new TreeToStringConverter().convertToString(tSelection));
		ParameterizedCommand parmCommand =
			new ParameterizedCommand(command, new Parameterization[] {
				px
			});
		
		return handlerService.executeCommand(parmCommand, null);
		
	} catch (Exception ex) {
		throw new RuntimeException("add.command not found"); //$NON-NLS-1$
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:20,代码来源:ErstelleRnnCommand.java

示例10: execute

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private static Object execute(IViewSite origin, String commandID, Map<String, Object> params){
	if (origin == null) {
		log.error("origin is null");
		return null;
	}
	IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class);
	ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class);
	try {
		Command command = cmdService.getCommand(commandID);
		String name = StringTool.unique("CommandHandler"); //$NON-NLS-1$
		paramMap.put(name, params);
		Parameterization px = new Parameterization(new DefaultParameter(), name);
		ParameterizedCommand parmCommand =
			new ParameterizedCommand(command, new Parameterization[] {
				px
		});
		
		return handlerService.executeCommand(parmCommand, null);
		
	} catch (Exception ex) {
		throw new RuntimeException("add.command not found"); //$NON-NLS-1$
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:24,代码来源:Handler.java

示例11: executeWithParams

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public static void executeWithParams(PersistentObject parameter){
	try {
		// get the command
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
		Command cmd = cmdService.getCommand(COMMANDID);
		// create the parameter
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put(PARAMETERID, parameter);
		// build the parameterized command
		ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param);
		// execute the command
		IHandlerService handlerService =
			(IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getService(IHandlerService.class);
		handlerService.executeCommand(pc, null);
	} catch (Exception ex) {
		throw new RuntimeException(COMMANDID, ex);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:21,代码来源:EditLabItemUi.java

示例12: ExecuteWithParams

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public static Object ExecuteWithParams(IViewSite origin, String bereich, String from,
	String until){
	IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class);
	ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class);
	try {
		Command command = cmdService.getCommand(ID);
		Parameterization px1 =
			new Parameterization(
				command.getParameter("ch.elexis.agenda.param.resource"), bereich); //$NON-NLS-1$
		
		Parameterization px2 =
			new Parameterization(command.getParameter("ch.elexis.agenda.param.from"), from); //$NON-NLS-1$
		Parameterization px3 =
			new Parameterization(command.getParameter("ch.elexis.agenda.param.until"), until); //$NON-NLS-1$
		ParameterizedCommand parmCommand =
			new ParameterizedCommand(command, new Parameterization[] {
				px1, px2, px3
			});
		
		return handlerService.executeCommand(parmCommand, null);
		
	} catch (Exception ex) {
		throw new RuntimeException(" export command not found"); //$NON-NLS-1$
	}
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:26,代码来源:ExportCommand.java

示例13: executeCommand

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private void executeCommand ( final ParameterizedCommand command ) throws PartInitException
{
    final IHandlerService handlerService = (IHandlerService)getWorkbenchWindow ().getService ( IHandlerService.class );
    if ( command.getCommand ().isDefined () )
    {
        try
        {
            handlerService.executeCommand ( command, null );
        }
        catch ( final Exception e )
        {
            throw new RuntimeException ( e );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:16,代码来源:AlarmNotifier.java

示例14: startHdView

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
protected void startHdView ()
{
    try
    {
        final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class );
        final IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench ().getService ( IHandlerService.class );

        final Command command = commandService.getCommand ( "org.eclipse.scada.ui.chart.view.commands.OpenParametersChartView" ); //$NON-NLS-1$

        final Parameterization[] parameterizations = new Parameterization[4];
        parameterizations[0] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.connectionId" ), this.connectionId ); //$NON-NLS-1$
        parameterizations[1] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.itemId" ), this.itemId ); //$NON-NLS-1$
        if ( this.queryString == null || this.queryString.isEmpty () )
        {
            parameterizations[2] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.queryTimespec" ), "2400000:600000" ); //$NON-NLS-1$ //$NON-NLS-2$
        }
        else
        {
            parameterizations[2] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.queryTimespec" ), this.queryString ); //$NON-NLS-1$ 
        }
        parameterizations[3] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.itemType" ), "hd" ); //$NON-NLS-1$ //$NON-NLS-2$

        final ParameterizedCommand parameterCommand = new ParameterizedCommand ( command, parameterizations );

        handlerService.executeCommand ( parameterCommand, null );
    }
    catch ( final Exception e )
    {
        logger.debug ( "Failed to open view", e );
        StatusManager.getManager ().handle ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.TrendControlImage_TrendError, e ), StatusManager.BLOCK );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:33,代码来源:TrendControlImage.java

示例15: executeCommand

import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
/**
 * Execute an Eclipse command
 *
 * @param commandId
 *            the command to execute
 * @param eventData
 *            the parameter event data (depends on the command)
 */
public void executeCommand ( final String commandId, final Map<String, String> eventData )
{
    try
    {
        final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class );
        final IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench ().getService ( IHandlerService.class );

        final Command command = commandService.getCommand ( commandId );

        final Parameterization[] parameterizations = new Parameterization[eventData.size ()];

        int i = 0;
        for ( final Map.Entry<String, String> entry : eventData.entrySet () )
        {
            parameterizations[i] = new Parameterization ( command.getParameter ( entry.getKey () ), entry.getValue () );
            i++;
        }
        final ParameterizedCommand parameterCommand = new ParameterizedCommand ( command, parameterizations );

        handlerService.executeCommand ( parameterCommand, null );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to execute command", e );
        StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.BLOCK );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:36,代码来源:SymbolContext.java


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