Java 类org.eclipse.core.commands.Parameterization 实例源码

项目:mondo-collab-framework    文件:MACLIncQueryGenerator.java   
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;
    }
}
项目:mondo-collab-framework    文件:MACLPatternImplementation.java   
@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;
    }
}
项目:birt    文件:CommandUtils.java   
public static Parameterization createParameter( Command command,
        String parameterId, Object value ) throws NotDefinedException,
        ExecutionException, ParameterValueConversionException
{
    ParameterType parameterType = command.getParameterType( parameterId );
    if ( parameterType == null )
    {
        throw new ExecutionException( "Command does not have a parameter type for the given parameter" ); //$NON-NLS-1$
    }

    IParameter param = command.getParameter( parameterId );
    AbstractParameterValueConverter valueConverter = parameterType.getValueConverter( );
    if ( valueConverter == null )
    {
        throw new ExecutionException( "Command does not have a value converter" ); //$NON-NLS-1$
    }

    String valueString = valueConverter.convertToString( value );
    Parameterization parm = new Parameterization( param, valueString );
    return parm;
}
项目:elexis-3-core    文件:ErstelleRnnCommand.java   
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$
    }
}
项目:elexis-3-core    文件:Handler.java   
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$
    }
}
项目:elexis-3-base    文件:ExportCommand.java   
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$
    }
}
项目:neoscada    文件:ConfigurationHelper.java   
private static ParameterizedCommand convertCommand ( final IConfigurationElement commandElement ) throws NotDefinedException, InvalidRegistryObjectException
{
    final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class );
    final Command command = commandService.getCommand ( commandElement.getAttribute ( "id" ) ); //$NON-NLS-1$
    final List<Parameterization> parameters = new ArrayList<Parameterization> ();
    for ( final IConfigurationElement parameter : commandElement.getChildren ( "parameter" ) ) //$NON-NLS-1$
    {
        final IParameter name = command.getParameter ( parameter.getAttribute ( "name" ) ); //$NON-NLS-1$
        final String value = parameter.getAttribute ( "value" ); //$NON-NLS-1$
        parameters.add ( new Parameterization ( name, value ) );
    }
    return new ParameterizedCommand ( command, parameters.toArray ( new Parameterization[] {} ) );
}
项目:neoscada    文件:TrendControlImage.java   
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 );
    }
}
项目:neoscada    文件:SymbolContext.java   
/**
 * 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 );
    }
}
项目:org.csstudio.display.builder    文件:RCPUtil.java   
private final static void doExecuteEclipseCommand(String commandId, String... parameters)
{
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    final IHandlerService handlerService = window.getService(IHandlerService.class);
    try
    {
        if (parameters.length % 2 != 0)
            throw new IllegalArgumentException("Parameterized commands must have "
                    + "an equal number of keys and values");

        if (parameters.length == 0)
            handlerService.executeCommand(commandId, null);
        else
        {
            final ICommandService commandService = window.getService(ICommandService.class);
            final Parameterization[] params = new Parameterization[parameters.length / 2];
            final Command c = commandService.getCommand(commandId);
            for (int i = 0; i < parameters.length / 2; i++)
            {
                final String key = parameters[2 * i];
                final String value = parameters[2 * i + 1];
                final IParameter p = c.getParameter(key);
                final Parameterization pp = new Parameterization(p, value);
                params[i] = pp;
            }
            final ParameterizedCommand pc = new ParameterizedCommand(c, params);
            handlerService.executeCommand(pc, null);
        }
    }
    catch (Exception ex)
    {
        logger.log(Level.WARNING, "Failed to execute eclipse command '" + commandId + "' " + Arrays.toString(parameters), ex);
    }
}
项目:birt    文件:CommandUtils.java   
public static Object executeCommand( String commandId, Map paramMap )
        throws NotDefinedException, ExecutionException,
        ParameterValueConversionException, NotEnabledException,
        NotHandledException
{
    Command cmd = CommandUtils.getCommand( commandId );
    List paramList = new ArrayList( );
    if ( paramMap != null )
    {
        for ( Iterator iter = paramMap.entrySet( ).iterator( ); iter.hasNext( ); )
        {
            Map.Entry entry = (Entry) iter.next( );
            String paramId = entry.getKey( ).toString( );
            Object value = entry.getValue( );
            if ( value != null )
            {
                paramList.add( createParameter( cmd, paramId, value ) );
            }
        }
    }
    if ( paramList.size( ) > 0 )
    {
        ParameterizedCommand paramCommand = new ParameterizedCommand( cmd,
                (Parameterization[]) paramList.toArray( new Parameterization[paramList.size( )] ) );

        return getHandlerService( ).executeCommand( paramCommand, null );
    }
    else
    {
        return getHandlerService( ).executeCommand( commandId, null );
    }
}
项目:relations    文件:CommandHelper.java   
/**
 * <p>
 * Generates all the possible combinations of command parameterizations for
 * the given command. If the command has no parameters, then this is simply
 * a parameterized version of that command. If a parameter is optional, both
 * the included and not included cases are considered.
 * </p>
 * <p>
 * If one of the parameters cannot be loaded due to a
 * <code>ParameterValuesException</code>, then it is simply ignored.
 * </p>
 *
 * @param inCommand
 *            {@link Command} The command for which the parameter
 *            combinations should be generated; must not be
 *            <code>null</code>.
 * @return A collection of <code>ParameterizedCommand</code> instances
 *         representing all of the possible combinations. This value is
 *         never empty and it is never <code>null</code>.
 * @throws NotDefinedException
 *             If the command is not defined.
 */
public static Collection<ParameterizedCommand> generateCombinations(
        final Command inCommand) throws NotDefinedException {
    final IParameter[] lParameters = inCommand.getParameters();
    if (lParameters == null) {
        return Collections
                .singleton(new ParameterizedCommand(inCommand, null));
    }

    final Collection<List<Parameterization>> lExpansion = expandParameters(
            0, lParameters);
    final Collection<ParameterizedCommand> outCombinations = new ArrayList<ParameterizedCommand>(
            lExpansion.size());
    final Iterator<List<Parameterization>> lExpansionItr = lExpansion
            .iterator();
    while (lExpansionItr.hasNext()) {
        final List<Parameterization> lCombination = lExpansionItr.next();
        if (lCombination == null) {
            outCombinations.add(new ParameterizedCommand(inCommand, null));
        } else {
            while (lCombination.remove(null)) {
                // Just keep removing while there are null entries left.
            }
            if (lCombination.isEmpty()) {
                outCombinations
                        .add(new ParameterizedCommand(inCommand, null));
            } else {
                final Parameterization[] lParameterizations = lCombination
                        .toArray(new Parameterization[lCombination.size()]);
                outCombinations.add(new ParameterizedCommand(inCommand,
                        lParameterizations));
            }
        }
    }

    return outCombinations;
}
项目:relations    文件:CommandHelper.java   
private static Parameterization getParameterizationChecked(
        final List<List<Parameterization>> inParameterizations,
        final int inIndex) {
    final List<Parameterization> outValues = inParameterizations
            .get(inIndex);
    return outValues == null ? null : outValues.get(0);
}
项目:relations    文件:CommandHelper.java   
private static List<Parameterization> createList(
        final Parameterization inParameterization) {
    final ArrayList<Parameterization> out = new ArrayList<Parameterization>(
            1);
    out.add(inParameterization);
    return out;
}
项目:d-case_editor    文件:AttributeDialog.java   
/**
 * Retrieve the command with a command id.
 * 
 * @param id a command id
 * @return the command
 */
private ParameterizedCommand getCommandList(String id) {
    // parameter is not used now.
    List<Parameterization> params = new ArrayList<Parameterization>();

    ICommandService cmdService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    Command cmd = cmdService.getCommand(id);
    return new ParameterizedCommand(
            cmd, (Parameterization[]) params.toArray(new Parameterization[params.size()]));
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeAssistAdvancedConfigurationBlock.java   
String getKeybindingAsString() {
    final Parameterization[] params= { new Parameterization(fParam, fCategory.getId()) };
    final ParameterizedCommand pCmd= new ParameterizedCommand(fCommand, params);
    String key= getKeyboardShortcut(pCmd);
    return key;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeAssistAdvancedConfigurationBlock.java   
String getKeybindingAsString() {
    final Parameterization[] params= { new Parameterization(fParam, fCategory.getId()) };
    final ParameterizedCommand pCmd= new ParameterizedCommand(fCommand, params);
    String key= getKeyboardShortcut(pCmd);
    return key;
}
项目:lunifera-sharky-m2m    文件:DebugSpeechListener.java   
@Override
public void notifySpeech(String speech) {
    System.out.println("Speech recongized: " + speech);

    if (HELLO.equalsIgnoreCase(speech)) {
        showText("Welcome back. What would you like to do?");
    } else if (DEBUG_START.equalsIgnoreCase(speech)) {
        DebugHelper.runLastDebug();
    } else if (STEP_OVER.equalsIgnoreCase(speech)) {
        DebugHelper.stepOver();
    } else if (STEP_INTO.equalsIgnoreCase(speech)) {
        DebugHelper.stepInto();
    } else if (STEP_RETURN.equalsIgnoreCase(speech)) {
        DebugHelper.stepReturn();
    } else if (RESUME.equalsIgnoreCase(speech)) {
        DebugHelper.resume();
    } else if (JAVA_PERSPECTIVE.equalsIgnoreCase(speech)) {
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
                ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
                Command showView = commandService.getCommand("org.eclipse.ui.perspectives.showPerspective");
                try {
                    IParameter persIdParm = showView.getParameter("org.eclipse.ui.perspectives.showPerspective.perspectiveId");

                    Parameterization parm = new Parameterization(persIdParm, "org.eclipse.jdt.ui.JavaPerspective");
                    ParameterizedCommand parmCommand = new ParameterizedCommand(showView, new Parameterization[] { parm });

                    handlerService.executeCommand(parmCommand, null);
                } catch (Exception e) {

                }
            }
        });
    } else if (EXIT.equalsIgnoreCase(speech)) {
        showText("See you soon!");
    } else if (STOP_SPEECH_RECOGNITION.equalsIgnoreCase(speech)) {
        KinectManager.INSTANCE.stopSpeechRecognition();
    } else if (OPEN_TYPE.equalsIgnoreCase(speech)) {
        openTypeDialog();
    }

}
项目:lunifera-sharky-m2m    文件:DebugSpeechListener.java   
@Override
public void notifySpeech(String speech) {
    System.out.println("Speech recongized: " + speech);

    if (HELLO.equalsIgnoreCase(speech)) {
        showText("Welcome back. What would you like to do?");
    } else if (DEBUG_START.equalsIgnoreCase(speech)) {
        DebugHelper.runLastDebug();
    } else if (STEP_OVER.equalsIgnoreCase(speech)) {
        DebugHelper.stepOver();
    } else if (STEP_INTO.equalsIgnoreCase(speech)) {
        DebugHelper.stepInto();
    } else if (STEP_RETURN.equalsIgnoreCase(speech)) {
        DebugHelper.stepReturn();
    } else if (RESUME.equalsIgnoreCase(speech)) {
        DebugHelper.resume();
    } else if (JAVA_PERSPECTIVE.equalsIgnoreCase(speech)) {
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
                ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
                Command showView = commandService.getCommand("org.eclipse.ui.perspectives.showPerspective");
                try {
                    IParameter persIdParm = showView.getParameter("org.eclipse.ui.perspectives.showPerspective.perspectiveId");

                    Parameterization parm = new Parameterization(persIdParm, "org.eclipse.jdt.ui.JavaPerspective");
                    ParameterizedCommand parmCommand = new ParameterizedCommand(showView, new Parameterization[] { parm });

                    handlerService.executeCommand(parmCommand, null);
                } catch (Exception e) {

                }
            }
        });
    } else if (EXIT.equalsIgnoreCase(speech)) {
        showText("See you soon!");
    } else if (STOP_SPEECH_RECOGNITION.equalsIgnoreCase(speech)) {
        KinectManager.INSTANCE.stopSpeechRecognition();
    } else if (OPEN_TYPE.equalsIgnoreCase(speech)) {
        openTypeDialog();
    }

}