Search in sources :

Example 1 with ParameterValuesException

use of org.eclipse.core.commands.ParameterValuesException in project eclipse.platform.ui by eclipse-platform.

the class HandlerTest method defineCommands.

private void defineCommands(IEclipseContext context) {
    ECommandService cs = workbenchContext.get(ECommandService.class);
    Category category = cs.defineCategory(TEST_CAT1, "CAT1", null);
    cs.defineCommand(TEST_ID1, "ID1", null, category, null);
    cs.defineCommand(TEST_ID2, "ID2", null, category, null);
    cs.defineCommand(TEST_ID3, "ID3", null, category, new IParameter[] { new IParameter() {

        @Override
        public boolean isOptional() {
            return true;
        }

        @Override
        public IParameterValues getValues() throws ParameterValuesException {
            return Collections::emptyMap;
        }

        @Override
        public String getName() {
            return ACTIVE_INFO_ID;
        }

        @Override
        public String getId() {
            return ACTIVE_INFO_ID;
        }
    } });
}
Also used : IParameter(org.eclipse.core.commands.IParameter) Category(org.eclipse.core.commands.Category) ParameterValuesException(org.eclipse.core.commands.ParameterValuesException) Collections(java.util.Collections) IParameterValues(org.eclipse.core.commands.IParameterValues) ECommandService(org.eclipse.e4.core.commands.ECommandService)

Example 2 with ParameterValuesException

use of org.eclipse.core.commands.ParameterValuesException in project egradle by de-jcup.

the class LaunchGradleCommandHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        IParameter configparameter = event.getCommand().getParameter(PARAMETER_LAUNCHCONFIG);
        IParameterValues values = configparameter.getValues();
        if (values instanceof LaunchParameterValues) {
            LaunchParameterValues launchParameterValues = (LaunchParameterValues) values;
            taskAttributeOverride = launchParameterValues.getOverriddenTasks();
            launch = launchParameterValues.getLaunch();
            postJob = launchParameterValues.getPostJob();
        } else {
            IDEUtil.logWarning(getClass().getSimpleName() + ":parameter values without being a launch parameter value was used !??! :" + values);
        }
    } catch (NotDefinedException | ParameterValuesException e) {
        throw new IllegalStateException("Cannot fetch command parameter!", e);
    }
    return super.execute(event);
}
Also used : IParameter(org.eclipse.core.commands.IParameter) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) LaunchParameterValues(de.jcup.egradle.eclipse.ide.launch.LaunchParameterValues) ParameterValuesException(org.eclipse.core.commands.ParameterValuesException) IParameterValues(org.eclipse.core.commands.IParameterValues)

Aggregations

IParameter (org.eclipse.core.commands.IParameter)2 IParameterValues (org.eclipse.core.commands.IParameterValues)2 ParameterValuesException (org.eclipse.core.commands.ParameterValuesException)2 LaunchParameterValues (de.jcup.egradle.eclipse.ide.launch.LaunchParameterValues)1 Collections (java.util.Collections)1 Category (org.eclipse.core.commands.Category)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1 ECommandService (org.eclipse.e4.core.commands.ECommandService)1