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


Java CommandException类代码示例

本文整理汇总了Java中org.eclipse.core.commands.common.CommandException的典型用法代码示例。如果您正苦于以下问题:Java CommandException类的具体用法?Java CommandException怎么用?Java CommandException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandException类属于org.eclipse.core.commands.common包,在下文中一共展示了CommandException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_IMPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_IMPORT_PARM_WIZARDID,
              SessionImportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ImportSessionHandler.java

示例2: execute

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_EXPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_EXPORT_PARM_WIZARDID,
              SessionExportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ExportSessionHandler.java

示例3: run

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
* Asynchronously executes a {@link Command} in the Eclipse UI thread.
*
* @see Runnable#run()
* @see Display#asyncExec(Runnable)
* @see #runCommand(String)
**/
public void run()
{
    try
    {
    	if (command.isHandled() && command.isEnabled())
    	{
    		command.executeWithChecks(executionEvent);
    	}
    }
    catch (CommandException exception)
    {
        ILog log = MultiTouchPlugin.getDefault().getLog();
        String info = "Unexpected exception while executing " + command; //$NON-NLS-1$
        IStatus status = new Status(IStatus.ERROR, MultiTouchPlugin.PLUGIN_ID, info, exception);
        log.log(status);
    }
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:25,代码来源:CommandRunner.java

示例4: execute

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Object result = null;
	ITextEditor editor = getTextEditor(event);
	extractUniversalCount(event);		// side effect sets up isUniversalPresent
	Binding indent = null;
	// ^U or no binding results in transform behavior
	if (!isUniversalPresent() && (indent = getBinding(editor,indentKey,indentMode)) != null) {
		String id = indent.getParameterizedCommand().getId(); 
		if (id != null && id.matches(indentExp) && !id.equals(IEmacsPlusCommandDefinitionIds.INDENT_FOR_TAB)) {
			try {
				result = executeCommand(id, null, editor);
			} catch (CommandException e) {
			}
		} else {
			super.execute(event);
		}
	} else {
		super.execute(event);
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:26,代码来源:IndentForTabHandler.java

示例5: paste

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * In the console context, use paste as
 * in some consoles (e.g. org.eclipse.debug.internal.ui.views.console.ProcessConsole), updateText
 * will not simulate keyboard input
 *  
 * @param event the ExecutionEvent
 * @param widget The consoles StyledText widget
 */
protected void paste(ExecutionEvent event, StyledText widget) {
		IWorkbenchPart apart = HandlerUtil.getActivePart(event);
		if (apart != null) {
			try {
				IWorkbenchPartSite site = apart.getSite();
				if (site != null) {
					IHandlerService service = (IHandlerService) site.getService(IHandlerService.class);
					if (service != null) {
						service.executeCommand(IEmacsPlusCommandDefinitionIds.EMP_PASTE, null);
						KillRing.getInstance().setYanked(true);
					}
				}
			} catch (CommandException e) {
			}
		}
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:25,代码来源:BaseYankHandler.java

示例6: dispatchId

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * Execute the command id (with universal-argument, if appropriate)
 * 
 * @param id
 * @param event
 * @return execution result
 */
private Object dispatchId(ITextEditor editor, String id, Map<String,Object> params) {
	Object result = null;
	if (id != null) {
		ICommandService ics = (ICommandService) editor.getSite().getService(ICommandService.class);
		if (ics != null) {
			Command command = ics.getCommand(id);
			if (command != null) {
				try {
					result = executeCommand(id, (Map<String,?>)params, null, getThisEditor());
				} catch (CommandException e) {}
			}
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:23,代码来源:EmacsPlusCmdHandler.java

示例7: executeCommand

import org.eclipse.core.commands.common.CommandException; //导入依赖的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;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:20,代码来源:EmacsPlusUtils.java

示例8: consoleDispatch

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
@Override
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	Object result = null;
	IDocument doc = viewer.getDocument();
	try {
		IWorkbenchPartSite site = activePart.getSite();
		if (site != null) {
			IHandlerService service = (IHandlerService) site.getService(IHandlerService.class);
			if (doc != null && service != null) {
				doc.addDocumentListener(KillRing.getInstance());
				String cmdId = getId(event, viewer);
				if (cmdId != null) {
					result = service.executeCommand(cmdId, null);
				}
			}
		}
	} catch (CommandException e) {
		// Shouldn't happen as the Command id will be null or valid
		e.printStackTrace();
	} finally {
		if (doc != null) {
			doc.removeDocumentListener(KillRing.getInstance());
		}
		// clear kill command flag
		KillRing.getInstance().setKill(null, false);
	}
	
	MarkUtils.clearConsoleMark(viewer);
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:34,代码来源:ConsoleCopyCutHandler.java

示例9: execute

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Object result = null;
	ITextEditor editor = getTextEditor(event);
	if (editor != null) {
		try {
			result = executeCommand(IEmacsPlusCommandDefinitionIds.SHOW_WHITESPACE_CHARACTERS,null,editor);
		} catch (CommandException e) {
			// ignore
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:17,代码来源:GlobalWhitespaceHandler.java

示例10: execute

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	ITextEditor editor = getTextEditor(event);
	if (editor != null) {
		KbdMacroSupport support = KbdMacroSupport.getInstance(); 
		// returns true if macro was being defined, else false
		if (!support.endKbdMacro()){
			if (support.hasKbdMacro()) {
				try {
					executeCommand(IEmacsPlusCommandDefinitionIds.KBDMACRO_EXECUTE, null, editor);
				} catch (CommandException e) {}
			}
		}
	}
	return null;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:16,代码来源:KbdMacroEndCallHandler.java

示例11: execute

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Object result = null;
	ITextEditor editor = getTextEditor(event);
	if (editor != null) {
		try {
			;
			result = executeCommand(IEmacsPlusCommandDefinitionIds.LINENUMBER_TOGGLE,null,editor);
		} catch (CommandException e) {
			// ignore
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:18,代码来源:LineModeHandler.java

示例12: getParams

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * Make a parameter map, if it uses one, for this command
 * @param command
 * @param count
 * @param params
 * @return the populated map, or an empty one
 */
private Map<String,Object> getParams(Command command, Map<String,Object> params) {
	try {
		if (command.getParameter(UNIVERSAL) != null) {
			if (params.isEmpty()) {
				params = new HashMap<String, Object>();
			}
			params.put(UNIVERSAL, Integer.toString(getUniversalCount()));
		}
	} catch (CommandException e) {}	// won't happen
	return params;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:19,代码来源:EmacsPlusCmdHandler.java

示例13: executeUniversal

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
void executeUniversal(ITextEditor editor, String id, Event event, int count, boolean isNumeric) 
throws NotDefinedException,	ExecutionException, CommandException {
	String did = null;
	if ((did = getInternalCmd(id)) != null) {
		// Emacs+ internal commands should support +- universal-argument
		EmacsPlusUtils.executeCommand(did, count, event, editor);
	} else if (count != 1 && (isUniversalCmd(id) || (alwaysUniversal && !id.startsWith(EmacsPlusUtils.MULGASOFT)))) {
		// only non-Emacs+ commands should be invoked here
		executeWithDispatch(editor, getUniversalCmd(id), count);
	} else {
		executeCommand(id, event, editor);
	}
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:14,代码来源:EmacsPlusCmdHandler.java

示例14: configureActions

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/** React to selections, button presses, ... */
private void configureActions()
{
    // Start a channel search
    search.addSelectionListener(new SelectionAdapter()
    {
        @Override
        public void widgetSelected(final SelectionEvent e)
        {
            searchForChannels();
        }
    });

    // Channel Table: Allow dragging of PVs with archive
    final Table table = channel_table.getTable();
    new ControlSystemDragSource(table)
    {
        @Override
        public Object getSelection()
        {
            final IStructuredSelection selection = (IStructuredSelection) channel_table.getSelection();
            // To allow transfer of array, the data must be
            // of the actual array type, not Object[]
            final Object[] objs = selection.toArray();
            final ChannelInfo[] channels = Arrays.copyOf(objs, objs.length, ChannelInfo[].class);
            return channels;
        }
    };

    // Double-clicks should have the same effect as context menu -> Data Browser
    getSite().setSelectionProvider(channel_table);
    channel_table.addDoubleClickListener(new IDoubleClickListener()
    {
        @Override
        public void doubleClick(DoubleClickEvent event)
        {
            //casting is needed for RAP
            IHandlerService handlerService = getSite().getService(IHandlerService.class);
            try
            {
                handlerService.executeCommand("org.csstudio.trends.databrowser3.OpenDataBrowserPopup", null);
            } catch (CommandException ex) {
                Activator.getLogger().log(Level.WARNING, "Failed to open data browser", ex); //$NON-NLS-1$
            }
        }
    });

    // Add context menu for object contributions
    final MenuManager menu = new MenuManager();
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    table.setMenu(menu.createContextMenu(table));
    getSite().registerContextMenu(menu, channel_table);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:54,代码来源:SearchView.java

示例15: executeCommand

import org.eclipse.core.commands.common.CommandException; //导入依赖的package包/类
/**
 * Invoke the specified command using the handler service
 * 
 * @param commandId
 * @param event
 * @param editor
 * @return execution result
 * @throws CommandException 
 */
protected Object executeCommand(String commandId,Event event, IEditorPart editor) throws ExecutionException, CommandException {
	return EmacsPlusUtils.executeCommand(commandId, event, editor);
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:13,代码来源:EmacsPlusCmdHandler.java


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