Search in sources :

Example 21 with CommandImpl

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

the class RunCommandAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    if (event.getParameters() == null) {
        Log.error(getClass(), localizationConstant.runCommandEmptyParamsMessage());
        return;
    }
    String name = event.getParameters().get(NAME_PARAM_ID);
    if (name == null) {
        Log.error(getClass(), localizationConstant.runCommandEmptyNameMessage());
        return;
    }
    final CommandImpl command = selectCommandAction.getCommandByName(name);
    if (command != null) {
        commandManager.executeCommand(command, appContext.getDevMachine().getDescriptor());
    }
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl)

Example 22 with CommandImpl

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

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

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

the class TestServiceClient method getOrCreateTestCompileCommand.

public Promise<CommandImpl> getOrCreateTestCompileCommand() {
    List<CommandImpl> commands = commandManager.getCommands();
    for (CommandImpl command : commands) {
        if (command.getName() != null && command.getName().startsWith("test-compile") && "mvn".equals(command.getType())) {
            return promiseProvider.resolve(command);
        }
    }
    for (CommandImpl command : commands) {
        if ("build".equals(command.getName()) && "mvn".equals(command.getType())) {
            String commandLine = command.getCommandLine();
            MatchResult result = mavenCleanBuildPattern.exec(commandLine);
            if (result != null) {
                String testCompileCommandLine = mavenCleanBuildPattern.replace(commandLine, "$1mvn test-compile $2");
                return commandManager.create("test-compile", testCompileCommandLine, "mvn", new HashMap<String, String>());
            }
        }
    }
    return promiseProvider.resolve(null);
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 25 with CommandImpl

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

the class TestServiceClientTest method reuseExistingCompileCommand.

@Test
public void reuseExistingCompileCommand() {
    CommandImpl existingCompileCommand = new CommandImpl("test-compile", "mvn test-compile -f ${current.project.path}", "mvn");
    when(commandManager.getCommands()).thenReturn(asList(new CommandImpl("run", "mvn run -f ${current.project.path}", "mvn"), new CommandImpl("build", "mvn clean install -f ${current.project.path}", "mvn"), existingCompileCommand));
    testServiceClient.getOrCreateTestCompileCommand();
    verify(promiseProvider).resolve(existingCompileCommand);
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) Test(org.junit.Test)

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