Search in sources :

Example 6 with CommandType

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();
    }
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) Category(org.eclipse.che.ide.ui.list.Category) CommandType(org.eclipse.che.ide.api.command.CommandType) ArrayList(java.util.ArrayList)

Example 7 with CommandType

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);
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandType(org.eclipse.che.ide.api.command.CommandType) HashMap(java.util.HashMap)

Example 8 with CommandType

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);
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandType(org.eclipse.che.ide.api.command.CommandType)

Example 9 with CommandType

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);
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandType(org.eclipse.che.ide.api.command.CommandType) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Aggregations

CommandType (org.eclipse.che.ide.api.command.CommandType)9 CommandImpl (org.eclipse.che.ide.api.command.CommandImpl)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 SpanElement (com.google.gwt.dom.client.SpanElement)1 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)1 Event (com.google.gwt.user.client.Event)1 EventListener (com.google.gwt.user.client.EventListener)1 KeyboardEvent (elemental.events.KeyboardEvent)1 List (java.util.List)1 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)1 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)1 MachineProcessDto (org.eclipse.che.api.machine.shared.dto.MachineProcessDto)1 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)1 Icon (org.eclipse.che.ide.api.icon.Icon)1 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)1 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)1