Search in sources :

Example 16 with CommandImpl

use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.

the class EditCommandsPresenter method onRemoveClicked.

@Override
public void onRemoveClicked() {
    final CommandImpl selectedCommand = view.getSelectedCommand();
    if (selectedCommand == null) {
        return;
    }
    final ConfirmCallback confirmCallback = new ConfirmCallback() {

        @Override
        public void accepted() {
            commandManager.remove(selectedCommand.getName()).then(new Operation<Void>() {

                @Override
                public void apply(Void arg) throws OperationException {
                    view.selectNeighborCommand(selectedCommand);
                    commandProcessingCallback = getCommandProcessingCallback();
                    refreshView();
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError arg) throws OperationException {
                    dialogFactory.createMessageDialog("Error", arg.getMessage(), null).show();
                }
            });
        }
    };
    ConfirmDialog confirmDialog = dialogFactory.createConfirmDialog(machineLocale.editCommandsViewRemoveTitle(), machineLocale.editCommandsRemoveConfirmation(selectedCommand.getName()), confirmCallback, null);
    confirmDialog.show();
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog)

Example 17 with CommandImpl

use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.

the class EditCommandsPresenter method onNameChanged.

@Override
public void onNameChanged() {
    final CommandImpl selectedCommand = view.getSelectedCommand();
    if (selectedCommand == null || !selectedCommand.equals(editedCommand)) {
        return;
    }
    selectedCommand.setName(view.getCommandName());
    view.setCancelButtonState(isViewModified());
    view.setSaveButtonState(isViewModified());
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl)

Example 18 with CommandImpl

use of org.eclipse.che.ide.api.command.CommandImpl 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 19 with CommandImpl

use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.

the class EditCommandsViewImpl method selectNeighborCommand.

@Override
public void selectNeighborCommand(CommandImpl command) {
    final CommandImpl commandToSelect;
    final List<CommandImpl> commandsOfType = categories.get(getTypeById(command.getType()));
    int selectedCommandIndex = commandsOfType.indexOf(command);
    if (commandsOfType.size() < 2 || selectedCommandIndex == -1) {
        commandToSelect = null;
    } else {
        if (selectedCommandIndex > 0) {
            selectedCommandIndex--;
        } else {
            selectedCommandIndex++;
        }
        commandToSelect = commandsOfType.get(selectedCommandIndex);
    }
    if (commandToSelect != null) {
        selectCommand(commandToSelect);
    } else {
        resetView();
    }
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl)

Example 20 with CommandImpl

use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.

the class ExecuteSelectedCommandAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    CommandImpl command = selectCommandAction.getSelectedCommand();
    Machine machine = selectCommandAction.getSelectedMachine();
    if (command != null && machine != null) {
        commandManager.executeCommand(command, machine);
    }
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) Machine(org.eclipse.che.api.core.model.machine.Machine)

Aggregations

CommandImpl (org.eclipse.che.ide.api.command.CommandImpl)28 OperationException (org.eclipse.che.api.promises.client.OperationException)9 CommandType (org.eclipse.che.ide.api.command.CommandType)6 ArrayList (java.util.ArrayList)5 PromiseError (org.eclipse.che.api.promises.client.PromiseError)5 Test (org.junit.Test)5 TestResult (org.eclipse.che.api.testing.shared.TestResult)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Operation (org.eclipse.che.api.promises.client.Operation)3 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)3 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)3 Matchers.anyString (org.mockito.Matchers.anyString)3 MatchResult (com.google.gwt.regexp.shared.MatchResult)2 Machine (org.eclipse.che.api.core.model.machine.Machine)2 ChoiceDialog (org.eclipse.che.ide.api.dialogs.ChoiceDialog)2 URL (com.google.gwt.http.client.URL)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1