private void createCommand(MCommand cmdModel) {
   IParameter[] parms = null;
   String id = cmdModel.getElementId();
   String name = localize(cmdModel.getCommandName(), cmdModel);
   String desc = localize(cmdModel.getDescription(), cmdModel);
   List<MCommandParameter> modelParms = cmdModel.getParameters();
   if (modelParms != null && !modelParms.isEmpty()) {
     ArrayList<Parameter> parmList = new ArrayList<>();
     for (MCommandParameter cmdParm : modelParms) {
       ParameterType parameterType = null;
       if (cmdParm.getTypeId() != null && cmdParm.getTypeId().length() > 0) {
         parameterType = commandManager.getParameterType(cmdParm.getTypeId());
       }
       parmList.add(
           new Parameter(
               cmdParm.getElementId(),
               cmdParm.getName(),
               null,
               parameterType,
               cmdParm.isOptional()));
     }
     parms = parmList.toArray(new Parameter[parmList.size()]);
   }
   Category cat = undefinedCategory;
   if (cmdModel.getCategory() != null) {
     cat = commandService.getCategory(cmdModel.getCategory().getElementId());
   }
   commandService.defineCommand(id, name, desc, cat, parms);
 }
 private void registerCommandListener() {
   cmListener =
       new ICommandManagerListener() {
         @SuppressWarnings("restriction")
         @Override
         public void commandManagerChanged(CommandManagerEvent commandManagerEvent) {
           if (commandManagerEvent.isCommandChanged()) {
             if (commandManagerEvent.isCommandDefined()) {
               final String commandId = commandManagerEvent.getCommandId();
               if (findCommand(commandId) != null) {
                 return;
               }
               final Command command =
                   commandManagerEvent.getCommandManager().getCommand(commandId);
               if (command.getHandler() == null) {
                 command.setHandler(HandlerServiceImpl.getHandler(commandId));
               }
               try {
                 MCategory categoryModel = findCategory(command.getCategory().getId());
                 final MCommand createdCommand =
                     createCommand(command, modelService, categoryModel);
                 application.getCommands().add(createdCommand);
               } catch (NotDefinedException e) {
                 Activator.getDefault()
                     .getLogService()
                     .log(0, "Failed to create command " + commandId, e); // $NON-NLS-1$
               }
             }
           }
         }
       };
   commandManager.addCommandManagerListener(cmListener);
 }
 private void unregisterCommandListener() {
   commandManager.removeCommandManagerListener(cmListener);
 }