本文整理汇总了Java中org.eclipse.core.commands.Command.executeWithChecks方法的典型用法代码示例。如果您正苦于以下问题:Java Command.executeWithChecks方法的具体用法?Java Command.executeWithChecks怎么用?Java Command.executeWithChecks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.commands.Command
的用法示例。
在下文中一共展示了Command.executeWithChecks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performDrop
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public boolean performDrop(Object data) {
IServiceLocator locator = Helper.getWB();
ICommandService svc = (ICommandService)locator.getService(
ICommandService.class);
Command cmd = svc.getCommand(CMD_ID_MOVE_ENTRY);
Map<String, String> params = new HashMap<>();
params.put("source", data.toString());
TreeNode en = (TreeNode)getCurrentTarget();
EntryData ed = EntryData.of(en);
params.put("target", String.valueOf(ed.entryID()));
try {
cmd.executeWithChecks(
new ExecutionEvent(cmd, params, getCurrentEvent(), null));
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e) {
throw new RuntimeException(e);
}
return true;
}
示例2: doRun
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public void doRun(){
GitBlitViewModel model = getSelectedModel();
if(model instanceof ProjectViewModel){
// Copy url to clipboard
CopyAction cca = new CopyAction(getViewer());
cca.setPrefModel(getPrefModel());
cca.run();
Command cmd = getEGitCommand();
if(cmd == null){
Activator.logError("Can't call EGit. Eclipse command service not avail or EGit not installed.");
return;
}
try{
cmd.executeWithChecks(new ExecutionEvent());
}catch(Exception e){
Activator.logError("Error pasting repository url to EGit", e);
}
}
}
示例3: performFinish
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public boolean performFinish() {
String selectedOption = wizardPage.getSelectedOption();
String commandId = commandOptions.get(selectedOption);
Command selectedCommand = commandService.getCommand(commandId);
try{
selectedCommand.executeWithChecks(new ExecutionEvent());
}
catch(ExecutionException | NotDefinedException
| NotEnabledException | NotHandledException e){
MessageDialog.openError(getShell(), "Error", "The selected Command"
+ " could not be executed successfully.");
return false;
}
return true;
}
示例4: createEvent
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void createEvent(Command command, IPersistentObject po){
IStructuredSelection iStructuredSelection = null;
if (po != null) {
iStructuredSelection = new StructuredSelection(po);
}
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(command.getId().concat(".selection"),
iStructuredSelection);
try {
command.executeWithChecks(
new ExecutionEvent(command, Collections.EMPTY_MAP, this, null));
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e) {
logger.error("cannot executre local edit event", e);
}
}
示例5: executeCommand
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
public Object executeCommand(){
try {
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command cmd = commandService.getCommand(commandId);
if (selection != null) {
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(commandId.concat(".selection"), new StructuredSelection(selection));
}
ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null);
return cmd.executeWithChecks(ee);
} catch (Exception e) {
LoggerFactory.getLogger(getClass())
.error("cannot execute command with id: " + commandId, e);
}
return null;
}
示例6: startEditLocalDocument
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
/**
* If {@link Preferences#P_TEXT_EDIT_LOCAL} is set, the
* <code> ch.elexis.core.ui.command.startEditLocalDocument </code> command is called with the
* provided {@link Brief}, and the provided {@link IViewPart} is hidden.
*
* @param view
* @param brief
* @return returns true if edit local is started and view is hidden
*/
public static boolean startEditLocalDocument(IViewPart view, Brief brief){
if (CoreHub.localCfg.get(Preferences.P_TEXT_EDIT_LOCAL, false) && brief != null) {
// open for editing
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command =
commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(command.getId().concat(".selection"), new StructuredSelection(brief));
try {
command.executeWithChecks(
new ExecutionEvent(command, Collections.EMPTY_MAP, view, null));
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e) {
MessageDialog.openError(view.getSite().getShell(), Messages.TextView_errortitle,
Messages.TextView_errorlocaleditmessage);
}
view.getSite().getPage().hideView(view);
return true;
}
return false;
}
示例7: startLocalEdit
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void startLocalEdit(Brief brief){
if (brief != null) {
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command =
commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(command.getId().concat(".selection"), new StructuredSelection(brief));
try {
command.executeWithChecks(
new ExecutionEvent(command, Collections.EMPTY_MAP, this, null));
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(),
Messages.BriefAuswahl_errorttile,
Messages.BriefAuswahl_erroreditmessage);
}
}
}
示例8: endLocalEdit
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void endLocalEdit(StructuredSelection selection){
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand("ch.elexis.core.ui.command.endLocalDocument"); //$NON-NLS-1$
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(command.getId().concat(".selection"), selection);
try {
command
.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null));
tableViewer.setInput(service.getAll());
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e) {
MessageDialog.openError(getShell(), Messages.LocalDocumentsDialog_errortitle,
Messages.LocalDocumentsDialog_errorendmessage);
}
}
示例9: abortLocalEdit
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void abortLocalEdit(StructuredSelection selection){
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand("ch.elexis.core.ui.command.abortLocalDocument"); //$NON-NLS-1$
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(command.getId().concat(".selection"), selection);
try {
command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null));
tableViewer.setInput(service.getAll());
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException e) {
MessageDialog.openError(getShell(), Messages.LocalDocumentsDialog_errortitle,
Messages.LocalDocumentsDialog_errorabortmessage);
}
}
示例10: executeCommand
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
/**
* Execute the UI command found by the commandId, using the {@link ICommandService}.
*
* @param commandId
* @param selection
* @return
*/
public static Object executeCommand(String commandId, IFinding selection){
try {
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command cmd = commandService.getCommand(commandId);
if(selection != null) {
PlatformUI.getWorkbench().getService(IEclipseContext.class)
.set(commandId.concat(".selection"), new StructuredSelection(selection));
}
ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null);
return cmd.executeWithChecks(ee);
} catch (Exception e) {
LoggerFactory.getLogger(FindingsUiUtil.class)
.error("cannot execute command with id: " + commandId, e);
}
return null;
}
示例11: execute
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command cmd = commandService.getCommand("org.eclipse.ui.window.preferences");
try {
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("preferencePageId", "ch.elexis.prefs.sticker");
ExecutionEvent ev = new ExecutionEvent(cmd, hm, null, null);
cmd.executeWithChecks(ev);
} catch (Exception exception) {
Status status =
new Status(IStatus.WARNING, Activator.PLUGIN_ID,
"Error opening sticker preference page");
StatusManager.getManager().handle(status, StatusManager.SHOW);
}
return null;
}
示例12: earlyStartup
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public void earlyStartup(){
boolean autostart = CoreHub.localCfg.get(Preferences.CFG_AUTOSTART, false);
if (autostart) {
try {
ICommandService commandService =
(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); // NPE
Command cmd = commandService.getCommand(ServerControl.ID);
Map<String, Object> map = new HashMap<String, Object>();
map.put(PARAM_EARLYSTARTUP, "true");
ExecutionEvent ee = new ExecutionEvent(cmd, map, null, null);
cmd.executeWithChecks(ee);
} catch (Exception exception) {
logger.error("Error on autostart", exception);
}
}
}
示例13: setStatus
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void setStatus(String statusId){
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getService(ICommandService.class);
Command command =
commandService.getCommand("at.medevit.elexis.agenda.ui.command.setStatus");
HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("at.medevit.elexis.agenda.ui.command.parameter.statusId", statusId);
ExecutionEvent ev = new ExecutionEvent(command, parameters, null, null);
try {
command.executeWithChecks(ev);
} catch (ExecutionException | NotDefinedException | NotEnabledException
| NotHandledException ex) {
LoggerFactory.getLogger(getClass()).error("Error setting status", ex);
}
}
示例14: runCommand
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
public static void runCommand(String commandId) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
IEvaluationService evaluationService = (IEvaluationService) window.getService(IEvaluationService.class);
try {
Command cmd = commandService.getCommand(commandId);
cmd.executeWithChecks(
new ExecutionEvent(cmd, new HashMap<String, String>(), null, evaluationService.getCurrentState()));
} catch (Exception exception) {
log.log(Level.SEVERE, "Could not execute command " + commandId, exception);
}
}
示例15: execute
import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final Command c =
WorkbenchHelper.getService(ICommandService.class).getCommand("org.eclipse.equinox.p2.ui.sdk.update");
if (c != null) {
try {
return c.executeWithChecks(event);
} catch (NotDefinedException | NotEnabledException | NotHandledException e) {}
}
return null;
}