本文整理汇总了Java中org.eclipse.core.commands.common.NotDefinedException类的典型用法代码示例。如果您正苦于以下问题:Java NotDefinedException类的具体用法?Java NotDefinedException怎么用?Java NotDefinedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotDefinedException类属于org.eclipse.core.commands.common包,在下文中一共展示了NotDefinedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preExecute
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* Receives a command that is about to execute.
* @param commandId the identifier of the command that is about to execute
* @param event the event that will be passed to the <code>execute</code> method
*/
@Override
public void preExecute(String commandId, ExecutionEvent event) {
long time = Time.getCurrentTime();
String path = recorder.getActiveInputFilePath();
ExecutionMacro macro = new ExecutionMacro(time, "Exec", path, commandId);
recorder.recordExecutionMacro(macro);
try {
String id = event.getCommand().getCategory().getId();
if (id.endsWith("category.refactoring")) {
recorder.setParentMacro(macro);
TriggerMacro trigger = new TriggerMacro(time, "Refactoring", path, TriggerMacro.Kind.BEGIN);
recorder.recordTriggerMacro(trigger);
}
} catch (NotDefinedException e) {
e.printStackTrace();
}
}
示例2: getLabel
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
@Override
public String getLabel() {
final StringBuilder label = new StringBuilder();
try {
Command command = parameterizedCommand.getCommand();
label.append(parameterizedCommand.getName());
if (command.getDescription() != null && command.getDescription().length() != 0) {
label.append(separator).append(command.getDescription());
}
} catch (NotDefinedException e) {
label.append(parameterizedCommand.getId());
}
return label.toString();
}
示例3: execute
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
IParameter configparameter = event.getCommand().getParameter(PARAMETER_LAUNCHCONFIG);
IParameterValues values = configparameter.getValues();
if (values instanceof LaunchParameterValues){
LaunchParameterValues launchParameterValues = (LaunchParameterValues) values;
taskAttributeOverride = launchParameterValues.getOverriddenTasks();
launch = launchParameterValues.getLaunch();
postJob = launchParameterValues.getPostJob();
}else{
IDEUtil.logWarning(getClass().getSimpleName()+":parameter values without being a launch parameter value was used !??! :"+ values);
}
} catch (NotDefinedException | ParameterValuesException e) {
throw new IllegalStateException("Cannot fetch command parameter!", e);
}
return super.execute(event);
}
示例4: hookDoubleClickAction
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
private void hookDoubleClickAction() {
bookmarksTreeViewer.addDoubleClickListener(event -> {
ISelection selection = bookmarksTreeViewer.getSelection();
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
Bookmark bookmark = Adapters.adapt(firstElement, Bookmark.class);
if (bookmark instanceof BookmarkFolder) {
bookmarksTreeViewer.setExpandedState(firstElement, !bookmarksTreeViewer.getExpandedState(firstElement));
} else {
// sometimes, selection and part in the command handler are not set to the boomarks view when we double-click on a bookmark
getSite().getWorkbenchWindow().getActivePage().activate(this);
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
try {
handlerService.executeCommand(COMMAND_ID_GOTO_FAVORI, null);
} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) {
StatusHelper.logError("Could not go to bookmark", e);
}
}
});
}
示例5: performDrop
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的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;
}
示例6: getKeyboardShortcut
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
private static String getKeyboardShortcut(ParameterizedCommand command) {
IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
fgLocalBindingManager.setBindings(bindingService.getBindings());
try {
Scheme activeScheme= bindingService.getActiveScheme();
if (activeScheme != null)
fgLocalBindingManager.setActiveScheme(activeScheme);
} catch (NotDefinedException e) {
JavaPlugin.log(e);
}
TriggerSequence[] bindings= fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
if (bindings.length > 0)
return bindings[0].format();
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:CodeAssistAdvancedConfigurationBlock.java
示例7: callRuleGenerationCommand
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
private boolean callRuleGenerationCommand(EPackage ePack, PatternInstance pattern, IPath iPath) {
IServiceLocator serviceLocator = PlatformUI.getWorkbench();
ICommandService commandService = serviceLocator.getService(ICommandService.class);
IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation.rule");
try {
IParameter parameter = command.getParameter(MACLCommandContext.ID);
String contextId = UUID.randomUUID().toString();
Activator.put(contextId, context);
Parameterization parameterization = new Parameterization(parameter, contextId);
ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
return false;
}
}
示例8: execute
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
@Override
public boolean execute(EPackage ePack, PatternInstance pattern, IPath iPath) {
IServiceLocator serviceLocator = PlatformUI.getWorkbench();
ICommandService commandService = serviceLocator.getService(ICommandService.class);
IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation");
try {
IParameter parameter = command.getParameter(MACLCommandContext.ID);
MACLCommandContext context = new MACLCommandContext(ePack, pattern, iPath);
String contextId = UUID.randomUUID().toString();
Activator.put(contextId, context);
Parameterization parameterization = new Parameterization(parameter, contextId);
ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
return false;
}
}
示例9: loadModelBackend
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
private static BindingManager loadModelBackend(IServiceLocator locator) {
IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
try {
Scheme modelActiveScheme = null;
for (int i = 0; i < definedSchemes.length; i++) {
final Scheme scheme = definedSchemes[i];
final Scheme copy = bindingManager.getScheme(scheme.getId());
copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
if (definedSchemes[i] == bindingService.getActiveScheme()) {
modelActiveScheme = copy;
}
}
bindingManager.setActiveScheme(modelActiveScheme);
} catch (final NotDefinedException e) {
StatusManager.getManager()
.handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
"Keys page found an undefined scheme", e)); //$NON-NLS-1$
}
bindingManager.setLocale(bindingService.getLocale());
bindingManager.setPlatform(bindingService.getPlatform());
bindingManager.setBindings(bindingService.getBindings());
return bindingManager;
}
示例10: setDefaultBindings
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* Sets the bindings to default.
* @param bindingService
* @throws NotDefinedException
*/
public void setDefaultBindings(IBindingService bindingService, List<String> lstRemove) throws NotDefinedException {
// Fix the scheme in the local changes.
final String defaultSchemeId = bindingService.getDefaultSchemeId();
final Scheme defaultScheme = fBindingManager.getScheme(defaultSchemeId);
try {
fBindingManager.setActiveScheme(defaultScheme);
} catch (final NotDefinedException e) {
// At least we tried....
}
// Restore any User defined bindings
Binding[] bindings = fBindingManager.getBindings();
for (int i = 0; i < bindings.length; i++) {
ParameterizedCommand pCommand = bindings[i].getParameterizedCommand();
String commandId = null;
if (pCommand != null) {
commandId = pCommand.getCommand().getId();
}
if (bindings[i].getType() == Binding.USER || (commandId != null && lstRemove.contains(commandId))) {
fBindingManager.removeBinding(bindings[i]);
}
}
bindingModel.refresh(contextModel, lstRemove);
saveBindings(bindingService);
}
示例11: getSchemeIds
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* <p>
* Ascends all of the parents of the scheme until no more parents are found.
* </p>
* <p>
* This method completes in <code>O(n)</code>, where <code>n</code> is the
* height of the context tree.
* </p>
*
* @param schemeId
* The id of the scheme for which the parents should be found;
* may be <code>null</code>.
* @return The array of scheme ids (<code>String</code>) starting with
* <code>schemeId</code> and then ascending through its ancestors.
*/
private final String[] getSchemeIds(String schemeId) {
final List strings = new ArrayList();
while (schemeId != null) {
strings.add(schemeId);
try {
schemeId = getScheme(schemeId).getParentId();
} catch (final NotDefinedException e) {
Policy.getLog().log(
new Status(IStatus.ERROR, Policy.JFACE, IStatus.OK,
"Failed ascending scheme parents", //$NON-NLS-1$
e));
return new String[0];
}
}
return (String[]) strings.toArray(new String[strings.size()]);
}
示例12: setActiveScheme
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* <p>
* Selects one of the schemes as the active scheme. This scheme must be
* defined.
* </p>
* <p>
* This method completes in <code>O(n)</code>, where <code>n</code> is the
* height of the context tree.
* </p>
*
* @param scheme
* The scheme to become active; must not be <code>null</code>.
* @throws NotDefinedException
* If the given scheme is currently undefined.
*/
public final void setActiveScheme(final Scheme scheme)
throws NotDefinedException {
if (scheme == null) {
throw new NullPointerException("Cannot activate a null scheme"); //$NON-NLS-1$
}
if ((scheme == null) || (!scheme.isDefined())) {
throw new NotDefinedException(
"Cannot activate an undefined scheme. " //$NON-NLS-1$
+ scheme.getId());
}
if (Util.equals(activeScheme, scheme)) {
return;
}
activeScheme = scheme;
activeSchemeIds = getSchemeIds(activeScheme.getId());
clearSolution();
fireBindingManagerChanged(new BindingManagerEvent(this, false, null,
true, null, false, false, false));
}
示例13: getHelpContextId
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* Gets the help context identifier for a particular command. The command's
* handler is first checked for a help context identifier. If the handler
* does not have a help context identifier, then the help context identifier
* for the command is returned. If neither has a help context identifier,
* then <code>null</code> is returned.
*
* @param command
* The command for which the help context should be retrieved;
* must not be <code>null</code>.
* @return The help context identifier to use for the given command; may be
* <code>null</code>.
* @throws NotDefinedException
* If the given command is not defined.
* @since 3.2
*/
public final String getHelpContextId(final Command command)
throws NotDefinedException {
// Check if the command is defined.
if (!command.isDefined()) {
throw new NotDefinedException("The command is not defined. " //$NON-NLS-1$
+ command.getId());
}
// Check the handler.
final IHandler handler = command.getHandler();
if (handler != null) {
// final String helpContextId = (String) helpContextIdsByHandler
// .get(handler);
// if (helpContextId != null) {
// return helpContextId;
// }
}
// Simply return whatever the command has as a help context identifier.
return command.getHelpContextId();
}
示例14: fireNotDefined
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* Notifies the execution listeners for this command that an attempt to
* execute has failed because the command is not defined.
*
* @param e
* The exception that is about to be thrown; never
* <code>null</code>.
* @since 3.2
*/
private final void fireNotDefined(final NotDefinedException e) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
Tracing.printTrace("COMMANDS", "execute" + Tracing.SEPARATOR //$NON-NLS-1$ //$NON-NLS-2$
+ "not defined: id=" + getId() + "; exception=" + e); //$NON-NLS-1$ //$NON-NLS-2$
}
if (executionListeners != null) {
final Object[] listeners = executionListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final Object object = listeners[i];
if (object instanceof IExecutionListenerWithChecks) {
final IExecutionListenerWithChecks listener = (IExecutionListenerWithChecks) object;
listener.notDefined(getId(), e);
}
}
}
}
示例15: getParameter
import org.eclipse.core.commands.common.NotDefinedException; //导入依赖的package包/类
/**
* Returns the parameter with the provided id or <code>null</code> if this
* command does not have a parameter with the id.
*
* @param parameterId
* The id of the parameter to retrieve.
* @return The parameter with the provided id or <code>null</code> if this
* command does not have a parameter with the id.
* @throws NotDefinedException
* If the handle is not currently defined.
* @since 3.2
*/
public final IParameter getParameter(final String parameterId)
throws NotDefinedException {
if (!isDefined()) {
throw new NotDefinedException(
"Cannot get a parameter from an undefined command. " //$NON-NLS-1$
+ id);
}
if (parameters == null) {
return null;
}
for (int i = 0; i < parameters.length; i++) {
final IParameter parameter = parameters[i];
if (parameter.getId().equals(parameterId)) {
return parameter;
}
}
return null;
}