当前位置: 首页>>代码示例>>Java>>正文


Java Command.executeWithChecks方法代码示例

本文整理汇总了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;
}
 
开发者ID:insweat,项目名称:hssd,代码行数:25,代码来源:DropEntryHandler.java

示例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);
		}
	}
}
 
开发者ID:baloise,项目名称:egitblit,代码行数:23,代码来源:CloneAction.java

示例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;
}
 
开发者ID:Pro-Nouns,项目名称:LinGUIne,代码行数:20,代码来源:SelectCommandWizard.java

示例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);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:17,代码来源:DocumentLocalEditHandler.java

示例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;
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:19,代码来源:ContributionAction.java

示例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;
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:33,代码来源:EditLocalDocumentUtil.java

示例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);
		}
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:21,代码来源:XrefExtension.java

示例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);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:18,代码来源:LocalDocumentsDialog.java

示例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);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:17,代码来源:LocalDocumentsDialog.java

示例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;
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:26,代码来源:FindingsUiUtil.java

示例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;
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:20,代码来源:OpenStickerPreferencePage.java

示例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);
		}
	}
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:23,代码来源:EarlyStartup.java

示例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);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:17,代码来源:SetStatusContributionItem.java

示例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);
    }
}
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:13,代码来源:RCPUtils.java

示例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;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:12,代码来源:UpdateHandler.java


注:本文中的org.eclipse.core.commands.Command.executeWithChecks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。