use of org.eclipse.che.ide.api.command.CommandType in project che by eclipse.
the class EditCommandsViewImpl method renderCategoriesList.
/**
* Render the commands list.
* It also takes into account the name filter and restores the selected command.
*/
private void renderCategoriesList(Map<CommandType, List<CommandImpl>> categories) {
final List<Category<?>> categoriesToRender = new ArrayList<>();
for (CommandType type : categories.keySet()) {
List<CommandImpl> commands = new ArrayList<>();
if (filterTextValue.isEmpty()) {
commands = categories.get(type);
} else {
// filtering List
for (final CommandImpl command : categories.get(type)) {
if (command.getName().contains(filterTextValue)) {
commands.add(command);
}
}
}
Category<CommandImpl> category = new Category<>(type.getId(), commandRenderer, commands, commandEventDelegate);
categoriesToRender.add(category);
}
categoriesList.clear();
categoriesList.render(categoriesToRender, true);
if (selectedCommand != null) {
categoriesList.selectElement(selectedCommand);
if (filterTextValue.isEmpty()) {
selectText(commandName.getElement());
}
} else {
resetView();
}
}
use of org.eclipse.che.ide.api.command.CommandType in project che by eclipse.
the class CommandManagerImpl method create.
@Override
public Promise<CommandImpl> create(String type) {
final CommandType commandType = commandTypeRegistry.getCommandTypeById(type);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(PREVIEW_URL_ATTR, commandType.getPreviewUrlTemplate());
final CommandImpl command = new CommandImpl(getUniqueCommandName(type, null), commandType.getCommandLineTemplate(), type, attributes);
return add(command);
}
use of org.eclipse.che.ide.api.command.CommandType in project che by eclipse.
the class CommandManagerImpl method create.
@Override
public Promise<CommandImpl> create(String desirableName, String commandLine, String type, Map<String, String> attributes) {
final CommandType commandType = commandTypeRegistry.getCommandTypeById(type);
Map<String, String> attr = (attributes != null) ? attributes : new HashMap<String, String>();
attr.put(PREVIEW_URL_ATTR, commandType.getPreviewUrlTemplate());
final CommandImpl command = new CommandImpl(getUniqueCommandName(type, desirableName), commandLine != null ? commandLine : commandType.getCommandLineTemplate(), type, attr);
return add(command);
}
use of org.eclipse.che.ide.api.command.CommandType in project che by eclipse.
the class EditCommandsPresenterTest method setUp.
@Before
public void setUp() {
presenter.editedCommandNameInitial = COMMAND_NAME;
when(commandManager.update(anyString(), anyObject())).thenReturn(commandPromise);
CommandType commandType = mock(CommandType.class);
when(commandType.getId()).thenReturn(COMMAND_TYPE);
List<CommandType> commandTypes = new ArrayList<>(1);
commandTypes.add(commandType);
when(commandTypeRegistry.getCommandTypes()).thenReturn(commandTypes);
when(command.getType()).thenReturn(COMMAND_TYPE);
when(command.getName()).thenReturn(COMMAND_NAME);
List<CommandImpl> commands = new ArrayList<>(1);
commands.add(command);
when(commandManager.getCommands()).thenReturn(commands);
}
Aggregations