Optional<CommandType> commandType = typeRegistry.getCommandTypeById(commandTypeId); newName = "new";
/** * Pops up a command type chooser dialog at the position relative to the browser's client area. * * @param left the left position, in pixels * @param top the top position, in pixels * @return promise that will be resolved with a chosen {@link CommandType} or rejected in case * command type selection has been cancelled */ public Promise<CommandType> show(int left, int top) { final List<CommandType> commandTypes = new ArrayList<>(commandTypeRegistry.getCommandTypes()); if (commandTypes.size() == 1) { return promiseProvider.resolve(commandTypes.get(0)); } commandTypes.sort(comparing(CommandType::getDisplayName)); view.setCommandTypes(commandTypes); view.show(left, top); return promiseProvider.create( Executor.create( (ExecutorBody<CommandType>) (resolve, reject) -> { resolveFunction = resolve; rejectFunction = reject; })); }
@Override public Promise<CommandImpl> createCommand( String goalId, String typeId, @Nullable String name, @Nullable String commandLine, Map<String, String> attributes, ApplicableContext context) { final Map<String, String> attr = new HashMap<>(attributes); attr.put(COMMAND_GOAL_ATTRIBUTE_NAME, goalId); final Optional<CommandType> commandType = commandTypeRegistry.getCommandTypeById(typeId); commandType.ifPresent( type -> attr.put( COMMAND_PREVIEW_URL_ATTRIBUTE_NAME, commandType.get().getPreviewUrlTemplate())); final String commandLineTemplate = commandType.map(CommandType::getCommandLineTemplate).orElse(""); return createCommand( new CommandImpl( commandNameGenerator.generate(typeId, name), commandLine != null ? commandLine : commandLineTemplate, typeId, attr, context)); }
/** Returns the icon for the given command type ID or {@code null} if none. */ @Nullable public SVGResource getCommandTypeIcon(String typeId) { final Optional<CommandType> commandType = commandTypeRegistry.getCommandTypeById(typeId); if (commandType.isPresent()) { final Icon icon = iconRegistry.getIconIfExist("command.type." + commandType.get().getId()); if (icon != null) { final SVGImage svgImage = icon.getSVGImage(); if (svgImage != null) { return icon.getSVGResource(); } } } return null; }
if (commandTypeRegistry.getCommandTypeById(type).isPresent()) { final String processName = process.getName(); final Optional<CommandImpl> commandOptional =