本文整理汇总了Java中org.eclipse.core.commands.Parameterization类的典型用法代码示例。如果您正苦于以下问题:Java Parameterization类的具体用法?Java Parameterization怎么用?Java Parameterization使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameterization类属于org.eclipse.core.commands包,在下文中一共展示了Parameterization类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callRuleGenerationCommand
import org.eclipse.core.commands.Parameterization; //导入依赖的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;
}
}
示例2: execute
import org.eclipse.core.commands.Parameterization; //导入依赖的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;
}
}
示例3: createParameter
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
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;
}
示例4: ExecuteWithParams
import org.eclipse.core.commands.Parameterization; //导入依赖的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$
}
}
示例5: execute
import org.eclipse.core.commands.Parameterization; //导入依赖的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$
}
}
示例6: ExecuteWithParams
import org.eclipse.core.commands.Parameterization; //导入依赖的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$
}
}
示例7: convertCommand
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
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[] {} ) );
}
示例8: startHdView
import org.eclipse.core.commands.Parameterization; //导入依赖的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 );
}
}
示例9: executeCommand
import org.eclipse.core.commands.Parameterization; //导入依赖的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 );
}
}
示例10: doExecuteEclipseCommand
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
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);
}
}
示例11: executeCommand
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
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 );
}
}
示例12: generateCombinations
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
/**
* <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;
}
示例13: getParameterizationChecked
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
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);
}
示例14: createList
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
private static List<Parameterization> createList(
final Parameterization inParameterization) {
final ArrayList<Parameterization> out = new ArrayList<Parameterization>(
1);
out.add(inParameterization);
return out;
}
示例15: getCommandList
import org.eclipse.core.commands.Parameterization; //导入依赖的package包/类
/**
* 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()]));
}