本文整理汇总了Java中org.eclipse.core.commands.ParameterizedCommand.generateCommand方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterizedCommand.generateCommand方法的具体用法?Java ParameterizedCommand.generateCommand怎么用?Java ParameterizedCommand.generateCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.commands.ParameterizedCommand
的用法示例。
在下文中一共展示了ParameterizedCommand.generateCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParameterizedCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
public ParameterizedCommand getParameterizedCommand() {
IWorkbenchWindow activeWorkbenchWindow = Activator.getDefault()
.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
ICommandService commandService = (ICommandService) activeWorkbenchWindow
.getService(ICommandService.class);
if (commandService != null) {
ParameterizedCommand parameterizedCommand = ParameterizedCommand
.generateCommand(commandService.getCommand(_commandID),
_params);
return parameterizedCommand;
}
}
return null;
}
示例2: executeCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) {
if (workbench == null) {
workbench = PlatformUI.getWorkbench();
}
// get command
ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class);
Command command = commandService != null ? commandService.getCommand(commandName) : null;
// get handler service
//IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class);
//TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open");
IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class);
if (command != null && handlerService != null) {
ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params);
try {
handlerService.executeCommand(paramCommand, null);
} catch (Exception e) {
Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true);
}
}
}
示例3: getCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
public ParameterizedCommand getCommand() {
IWorkbenchWindow activeWorkbenchWindow = Activator.getDefault()
.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
ICommandService commandService = (ICommandService) activeWorkbenchWindow
.getService(ICommandService.class);
if (commandService != null) {
// commandService.
ParameterizedCommand parameterizedCommand = ParameterizedCommand
.generateCommand(commandService.getCommand(_commandID),
_params);
return parameterizedCommand;
}
}
return null;
}
示例4: createCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
/**
* Build a command from the executable extension information.
*
* @param commandService
* to get the Command object
* @param commandId
* the command id for this action
* @param parameterMap
*/
private void createCommand(ICommandService commandService,
String commandId, Map parameterMap) {
Command cmd = commandService.getCommand(commandId);
if (!cmd.isDefined()) {
WorkbenchPlugin.log("Command " + commandId + " is undefined"); //$NON-NLS-1$//$NON-NLS-2$
return;
}
if (parameterMap == null) {
parameterizedCommand = new ParameterizedCommand(cmd, null);
return;
}
parameterizedCommand = ParameterizedCommand.generateCommand(cmd,
parameterMap);
}
示例5: executeCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的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;
}
示例6: executeCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
public static void executeCommand(String commandId, Map<String, Object> parameters) {
// Locals
ParameterizedCommand customizeCommand = null;
Command command = null;
try {
//
command = ((ICommandService) PlatformUI.getWorkbench()
.getService(ICommandService.class))
.getCommand(commandId);
// Generate customize command
customizeCommand = ParameterizedCommand.generateCommand(command, parameters);
// Execute the customize command
((IHandlerService) PlatformUI.getWorkbench()
.getService(IHandlerService.class))
.executeCommand(customizeCommand, null);
}
catch (Exception e) {
e.printStackTrace();
}
}
示例7: executeWithParams
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的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);
}
}
示例8: executeWithParams
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的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);
}
}
示例9: executeWithParams
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的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);
}
}
示例10: openSendMailDlg
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
private boolean openSendMailDlg(Patient patient, List<?> iOutboxElements,
ICommandService commandService,
String attachmentsString)
throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException{
Command sendMailCommand =
commandService.getCommand("ch.elexis.core.mail.ui.sendMail");
HashMap<String, String> params = new HashMap<String, String>();
params.put("ch.elexis.core.mail.ui.sendMail.attachments", attachmentsString);
if (patient != null) {
params.put("ch.elexis.core.mail.ui.sendMail.subject",
"Patient: " + patient.getLabel());
}
ParameterizedCommand parametrizedCommmand =
ParameterizedCommand.generateCommand(sendMailCommand, params);
Object obj = PlatformUI.getWorkbench().getService(IHandlerService.class)
.executeCommand(parametrizedCommmand, null);
return Boolean.TRUE.equals(obj);
}
示例11: modifyBindingsForAddChangeSet
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
private void modifyBindingsForAddChangeSet(final KbaChangeSet changeSet,
final KeyBindings bindings, final Scheme scheme) {
for (KbaBinding toAdd : changeSet.getBindingList()) {
Command commandToAdd = commandService.getCommand(toAdd.getCid());
if (!commandToAdd.isDefined()) {
log.logWarning("Command '" + toAdd.getCid() + "' does not exist. Skipping.");
continue;
}
ParameterizedCommand parameterizedCommandToAdd =
ParameterizedCommand.generateCommand(commandToAdd, toAdd.getParameters());
KeySequence triggerSequence;
try {
triggerSequence = KeySequence.getInstance(toAdd.getKeySequence());
} catch (ParseException e) {
log.logError(e, "Invalid key sequence: %s", toAdd.getKeySequence());
throw new RuntimeException(e);
}
bindings.addIfNotPresent(
scheme,
changeSet.getPlatform(),
changeSet.getContextId(),
triggerSequence,
parameterizedCommandToAdd);
}
}
示例12: execute
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
/**
*
* Execute command with parameters.
*
* @param id : command id
* @param param : array of parameters
*/
public boolean execute(String id, IEclipseContext staticContext, Map<String, String> param){
Command command = commandService.getCommand(id);
if(command == null){
logger.warning("execute("+ id +"): Command with specified ID was not found!");
return false;
}
try {
if(command.getParameters() == null){
return execute(id);
}
}
catch (NotDefinedException e1) {
e1.printStackTrace();
}
ParameterizedCommand pc = ParameterizedCommand.generateCommand(command, param);
if(pc == null){
logger.warning("execute("+ id +"): Can not create parameterized command!");
return false;
}
if(staticContext == null){
if(handlerService.canExecute(pc)){
handlerService.executeHandler(pc);
return true;
}
}
else{
if(handlerService.canExecute(pc, staticContext)){
handlerService.executeHandler(pc, staticContext);
return true;
}
}
return false;
}
示例13: executeParameterizedCommand
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
/**
* Attempts to execute the command with the given Id using the given params.
*/
private void executeParameterizedCommand(String commandId,
HashMap<String, String> params){
Command command = commandService.getCommand(commandId);
ParameterizedCommand parameterizedCmd = ParameterizedCommand.
generateCommand(command, params);
handlerService.executeHandler(parameterizedCmd);
}
示例14: execute
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
Brief brief = (Brief) ElexisEventDispatcher.getSelected(Brief.class);
if (brief != null) {
List<File> attachments = new ArrayList<File>();
Optional<File> tmpFile = getTempFile(brief);
if (tmpFile.isPresent()) {
attachments.add(tmpFile.get());
ICommandService commandService = (ICommandService) HandlerUtil
.getActiveWorkbenchWindow(event).getService(ICommandService.class);
try {
String attachmentsString = getAttachmentsString(attachments);
Command sendMailCommand =
commandService.getCommand("ch.elexis.core.mail.ui.sendMail");
HashMap<String, String> params = new HashMap<String, String>();
params.put("ch.elexis.core.mail.ui.sendMail.attachments", attachmentsString);
Patient patient = ElexisEventDispatcher.getSelectedPatient();
if (patient != null) {
params.put("ch.elexis.core.mail.ui.sendMail.subject",
"Patient: " + patient.getLabel());
}
ParameterizedCommand parametrizedCommmand =
ParameterizedCommand.generateCommand(sendMailCommand, params);
PlatformUI.getWorkbench().getService(IHandlerService.class)
.executeCommand(parametrizedCommmand, null);
} catch (Exception ex) {
throw new RuntimeException("ch.elexis.core.mail.ui.sendMail not found", ex);
}
}
removeTempAttachments(attachments);
}
return null;
}
示例15: createXDM
import org.eclipse.core.commands.ParameterizedCommand; //导入方法依赖的package包/类
private Object createXDM(Patient patient, ICommandService commandService,
String attachmentsString)
throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException{
Command xdmCommand = commandService
.getCommand("at.medevit.elexis.ehc.ui.vacdoc.CreateXdmHandler");
if (xdmCommand.isDefined()) {
HashMap<String, String> params = new HashMap<String, String>();
params.put("at.medevit.elexis.ehc.ui.vacdoc.tmp.dir",
attachmentsFolder.getAbsolutePath());
params.put("at.medevit.elexis.ehc.ui.vacdoc.attachments",
attachmentsString);
if (patient != null) {
params.put("at.medevit.elexis.ehc.ui.vacdoc.patient.id", patient.getId());
}
ParameterizedCommand parametrizedCommmand =
ParameterizedCommand.generateCommand(xdmCommand, params);
if (parametrizedCommmand != null) {
Object obj = PlatformUI.getWorkbench().getService(IHandlerService.class)
.executeCommand(parametrizedCommmand, null);
return obj;
}
}
else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Fehler",
"Es wurde kein Plugin zum erstellen von XDM Dateien gefunden.");
}
return null;
}