org.eclipse.core.commands.IParameter Java Examples
The following examples show how to use
org.eclipse.core.commands.IParameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandUtils.java From birt with Eclipse Public License 1.0 | 6 votes |
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; }
Example #2
Source File: KbdMacroDefineHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Define the Command to be used when executing the named kbd macro * * @param editor * @param id - the full command id * @param name - the short name * @param category - the category to use in the definition * @return the Command */ Command defineKbdMacro(ITextEditor editor, String id, String name, String category) { Command command = null; if (id != null) { // Now create the executable command ICommandService ics = (editor != null ) ? (ICommandService) editor.getSite().getService(ICommandService.class) : (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); command = ics.getCommand(id); IParameter[] parameters = null; try { // kludge: Eclipse has no way to dynamically define a parameter, so grab it from a known command IParameter p = ics.getCommand(PARAMETER_CMD).getParameter(PARAMETER); parameters = new IParameter[] { p }; } catch (Exception e) { } command.define(name, String.format(KBD_DESCRIPTION,name), ics.getCategory(category), parameters); command.setHandler(new KbdMacroNameExecuteHandler(name)); } return command; }
Example #3
Source File: ConfigurationHelper.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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[] {} ) ); }
Example #4
Source File: CodeAssistAdvancedConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
ModelElement(CompletionProposalCategory category, PreferenceModel model) { fCategory= category; ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class); fCommand= commandSvc.getCommand("org.eclipse.jdt.ui.specific_content_assist.command"); //$NON-NLS-1$ IParameter type; try { type= fCommand.getParameters()[0]; } catch (NotDefinedException x) { Assert.isTrue(false); type= null; } fParam= type; fPreferenceModel= model; }
Example #5
Source File: CommandSupport.java From e4macs with Eclipse Public License 1.0 | 5 votes |
public TreeMap<String, Command> getCommandList(IEditorPart editor, boolean all) { ICommandService ics = (ICommandService) editor.getSite().getService(ICommandService.class); Command[] commands = ics.getDefinedCommands(); commandTree = new TreeMap<String, Command>(); try { HashSet<Category>catHash = (all ? null : getCategories(ics)); boolean isOk = all; for (int i = 0; i < commands.length; i++) { if (!isOk && catHash.contains(commands[i].getCategory())) { IParameter[] params = commands[i].getParameters(); isOk = commands[i].isHandled(); // if the command has parameters, they must all be optional if (isOk && params != null) { for (int j = 0; j < params.length; j++) { if (!(isOk = params[j].isOptional())) { break; } } } } if (isOk) { commandTree.put(fixName(commands[i].getName()), commands[i]); } isOk = all; } } catch (NotDefinedException e) {} // getContexts(editor); return commandTree; }
Example #6
Source File: ICEExtensionContributionFactory.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * The constructor */ public ICEExtensionContributionFactory() { parameters = new ArrayList<IParameter>(); }