Java 类org.eclipse.core.commands.common.NotDefinedException 实例源码

项目:ContentAssist    文件:CommandExecutionManager.java   
/**
 * 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();
    }
}
项目:eclipse-plugin-commander    文件:CommandElement.java   
@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();
}
项目:egradle    文件:LaunchGradleCommandHandler.java   
@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);
}
项目:mesfavoris    文件:BookmarksView.java   
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);
            }
        }
    });
}
项目:hssd    文件:DropEntryHandler.java   
@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;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeAssistAdvancedConfigurationBlock.java   
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;
}
项目:mondo-collab-framework    文件:MACLIncQueryGenerator.java   
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;
    }
}
项目:mondo-collab-framework    文件:MACLPatternImplementation.java   
@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;
    }
}
项目:translationstudio8    文件:KeyController2.java   
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;
}
项目:translationstudio8    文件:KeyController2.java   
/**
 * 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);
}
项目:gef-gwt    文件:BindingManager.java   
/**
 * <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()]);
}
项目:gef-gwt    文件:BindingManager.java   
/**
 * <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));
}
项目:gef-gwt    文件:CommandManager.java   
/**
 * 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();
}
项目:gef-gwt    文件:Command.java   
/**
 * 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);
            }
        }
    }
}
项目:gef-gwt    文件:Command.java   
/**
 * 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;
}
项目:gef-gwt    文件:Command.java   
/**
 * Returns the parameters for this command. This call triggers provides a
 * copy of the array, so excessive calls to this method should be avoided.
 * 
 * @return The parameters for this command. This value might be
 *         <code>null</code>, if the command has no parameters.
 * @throws NotDefinedException
 *             If the handle is not currently defined.
 */
public final IParameter[] getParameters() throws NotDefinedException {
    if (!isDefined()) {
        throw new NotDefinedException(
                "Cannot get the parameters from an undefined command. " //$NON-NLS-1$
                        + id);
    }

    if ((parameters == null) || (parameters.length == 0)) {
        return null;
    }

    final IParameter[] returnValue = new IParameter[parameters.length];
    System.arraycopy(parameters, 0, returnValue, 0, parameters.length);
    return returnValue;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeAssistAdvancedConfigurationBlock.java   
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;
}
项目:tmxeditor8    文件:KeyController2.java   
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;
}
项目:tmxeditor8    文件:KeyController2.java   
/**
 * 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);
}
项目:tmxeditor8    文件:KeyController2.java   
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;
}
项目:tmxeditor8    文件:KeyController2.java   
/**
 * 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);
}
项目:birt    文件:CommandUtils.java   
public static Parameterization createParameter( Command command,
        String parameterId, Object value ) throws NotDefinedException,
        ExecutionException, ParameterValueConversionException
{
    ParameterType parameterType = command.getParameterType( parameterId );
    if ( parameterType == null )
    {
        throw new ExecutionException( "Command does not have a parameter type for the given parameter" ); //$NON-NLS-1$
    }

    IParameter param = command.getParameter( parameterId );
    AbstractParameterValueConverter valueConverter = parameterType.getValueConverter( );
    if ( valueConverter == null )
    {
        throw new ExecutionException( "Command does not have a value converter" ); //$NON-NLS-1$
    }

    String valueString = valueConverter.convertToString( value );
    Parameterization parm = new Parameterization( param, valueString );
    return parm;
}
项目:e4macs    文件:CommandAproposHandler.java   
private void printCommand(String name, Command command, EmacsPlusConsole console) {
    console.printBold(name + SWT.TAB);
    String bindingStrings = CommandHelp.getKeyBindingString(command, true);
    if (bindingStrings != null) {
        console.printContext(A_MSG + bindingStrings + Z_MSG);
    }
    try {
        String desc = command.getDescription();
        if (desc != null) {
            desc = desc.replaceAll(CR, CR + blanks + SWT.TAB);
            console.print(desc + CR);
        } else {
            console.print(CR);
        }
    } catch (NotDefinedException e) {
    }
}
项目:e4macs    文件:CommandBriefKeyHandler.java   
/**
 * @see com.mulgasoft.emacsplus.minibuffer.IMinibufferExecutable#executeResult(org.eclipse.ui.texteditor.ITextEditor, java.lang.Object)
 */
public boolean executeResult(ITextEditor editor, Object minibufferResult) {

    String summary = EMPTY_STR;
    if (minibufferResult != null) {

        IBindingResult bindingR = (IBindingResult) minibufferResult;
        String name = bindingR.getKeyString();
        if (bindingR == null || bindingR.getKeyBinding() == null) {
            summary = String.format(CMD_NO_RESULT, name) + CMD_NO_BINDING;
        } else {
            summary = String.format(CMD_KEY_RESULT,name); 
            Binding binding = bindingR.getKeyBinding();
            try {
                Command com = getCommand(binding);
                if (com != null) {
                    summary += normalizeCommandName(com.getName());
                }
            } catch (NotDefinedException e) {
                // can't happen as the Command will be null or valid
            }
        }
    }
    showResultMessage(editor, summary, false);
    return true;
}
项目:e4macs    文件:RepeatHandler.java   
@Override
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection, ExecutionEvent event) throws BadLocationException {
    RepeatCommandSupport repeat = RepeatCommandSupport.getInstance();
    String id = repeat.getId();

    try {
        Integer count = repeat.getCount();
        Command c = ((ICommandService)editor.getSite().getService(ICommandService.class)).getCommand(id);
        showMessage(editor, (count != 1) ? String.format(UREPEAT, count, c.getName()) : String.format(REPEAT, c.getName()), false);
    } catch (NotDefinedException e) {
        // won't happen
    }       
    Object result = NO_OFFSET;
    result = repeatLast(editor, id, repeat.getParams());
    return (result instanceof Integer ? (Integer)result : NO_OFFSET);
}
项目:e4macs    文件:EmacsPlusUtils.java   
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;
}
项目:e4macs    文件:CommandSupport.java   
/**
 * Get the current set of defined categories corresponding to the included category names
 * 
 * @param ics
 * @return the filtered set of categories
 * 
 * @throws NotDefinedException
 */
private HashSet<Category> getCategories(ICommandService ics) throws NotDefinedException 
{
    if (catHash.isEmpty() && catIncludes != null) {
        Category[] cats = ics.getDefinedCategories();
        for (int i = 0; i < cats.length; i++) {
            for (int j = 0; j < catIncludes.length; j++) {
                if (catIncludes[j].equals(cats[i].getId())) {
                    catHash.add(cats[i]);
                    break;
                }
            }
        }
    }
    return catHash;
}
项目:LinGUIne    文件:SelectCommandWizard.java   
@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;
}
项目:relations    文件:CategoryPatternFilter.java   
@Override
protected boolean isLeafMatch(final Viewer inViewer,
        final Object inElement) {
    if (filterCategories) {
        final ParameterizedCommand inCmd = getCommand(inElement);
        try {
            if (inCmd != null
                    && inCmd.getCommand().getCategory() == uncategorized) {
                return false;
            }
        }
        catch (final NotDefinedException e) {
            return false;
        }
    }
    return super.isLeafMatch(inViewer, inElement);
}
项目:relations    文件:KeyController.java   
protected void changeScheme(final SchemeElement inOldScheme,
        final SchemeElement inNewScheme) {
    if (inNewScheme == null || inNewScheme
            .getModelObject() == bindingManager.getActiveScheme()) {
        return;
    }
    try {
        bindingManager
                .setActiveScheme((Scheme) inNewScheme.getModelObject());
        bindingModel.refresh(getContextModel());
        bindingModel.setSelectedElement(null);
    }
    catch (final NotDefinedException exc) {
        log.error(exc, exc.getMessage());
    }
}
项目:elexis-3-core    文件:DocumentLocalEditHandler.java   
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);
    }
}
项目:elexis-3-core    文件:EditLocalDocumentUtil.java   
/**
 * 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;
}
项目:elexis-3-core    文件:XrefExtension.java   
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);
        }
    }
}
项目:elexis-3-core    文件:LocalDocumentsDialog.java   
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);
    }
}
项目:elexis-3-core    文件:LocalDocumentsDialog.java   
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);
    }
}
项目:elexis-3-base    文件:OutboxSendHandler.java   
private boolean openSendMailDlg(Patient patient, List<?> iOutboxElements,
    ICommandService commandService,
    String attachmentsString)
    throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException{
    Command sendMailCommand =
        commandService.getCommand("ch.elexis.core.mail.ui.sendMail");

    HashMap<String, String> params = new HashMap<String, String>();
    params.put("ch.elexis.core.mail.ui.sendMail.attachments", attachmentsString);
    if (patient != null) {
        params.put("ch.elexis.core.mail.ui.sendMail.subject",
            "Patient: " + patient.getLabel());
    }

    ParameterizedCommand parametrizedCommmand =
        ParameterizedCommand.generateCommand(sendMailCommand, params);

    Object obj = PlatformUI.getWorkbench().getService(IHandlerService.class)
        .executeCommand(parametrizedCommmand, null);
    return Boolean.TRUE.equals(obj);
}
项目:elexis-3-base    文件:SetStatusContributionItem.java   
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);
    }
}
项目:neoscada    文件:ConfigurationHelper.java   
private static ParameterizedCommand convertCommand ( final IConfigurationElement commandElement ) throws NotDefinedException, InvalidRegistryObjectException
{
    final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class );
    final Command command = commandService.getCommand ( commandElement.getAttribute ( "id" ) ); //$NON-NLS-1$
    final List<Parameterization> parameters = new ArrayList<Parameterization> ();
    for ( final IConfigurationElement parameter : commandElement.getChildren ( "parameter" ) ) //$NON-NLS-1$
    {
        final IParameter name = command.getParameter ( parameter.getAttribute ( "name" ) ); //$NON-NLS-1$
        final String value = parameter.getAttribute ( "value" ); //$NON-NLS-1$
        parameters.add ( new Parameterization ( name, value ) );
    }
    return new ParameterizedCommand ( command, parameters.toArray ( new Parameterization[] {} ) );
}
项目:eclipse-plugin-commander    文件:CommandProvider.java   
@SuppressWarnings("unchecked")
private Collection<ParameterizedCommand> getCombinations(Command command) {
    try {
        return ParameterizedCommand.generateCombinations(command);
    } catch (NotDefinedException e) {}
    return null;
}
项目:eclipse-plugin-commander    文件:CommandElement.java   
@Override
public String getSortLabel() {
    try {
        return parameterizedCommand.getName();
    } catch (NotDefinedException e) {
        return parameterizedCommand.getId();
    }
}