當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。