Search in sources :

Example 11 with Machine

use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.

the class SelectCommandComboBox method updateMachineActions.

private void updateMachineActions() {
    machinesActions.removeAll();
    final DefaultActionGroup actionList = (DefaultActionGroup) actionManager.getAction(GROUP_MACHINES_LIST);
    if (actionList != null) {
        machinesActions.addAll(actionList);
    }
    if (registeredMachineMap.isEmpty()) {
        return;
    }
    final List<Map.Entry<String, Machine>> machineEntryList = new LinkedList(registeredMachineMap.entrySet());
    // defined MachineDto Comparator here
    Collections.sort(machineEntryList, new MachineListEntryComparator());
    String machineCategory = null;
    for (Map.Entry<String, Machine> machineEntry : machineEntryList) {
        final Machine machine = machineEntry.getValue();
        final MachineConfig machineConfig = machine.getConfig();
        if (!this.getMachineCategory(machineConfig).equals(machineCategory)) {
            machineCategory = this.getMachineCategory(machineConfig);
            machinesActions.addSeparator(machineCategory);
        }
        machinesActions.add(machinesListWidget.createAction(machine.getId(), machineConfig.getName()));
    }
    machinesListWidget.updatePopup();
    if (machinesListWidget.getSelectedName() == null && machinesActions.getChildrenCount() > 0) {
        Machine firstMachine = machineEntryList.get(0).getValue();
        if (firstMachine == null) {
            return;
        }
        machinesListWidget.selectElement(firstMachine.getId(), firstMachine.getConfig().getName());
    }
}
Also used : MachineConfig(org.eclipse.che.api.core.model.machine.MachineConfig) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) HashMap(java.util.HashMap) Map(java.util.Map) LinkedList(java.util.LinkedList) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 12 with Machine

use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.

the class SelectCommandComboBox method onMachineRunning.

@Override
public void onMachineRunning(MachineStateEvent event) {
    Machine machine = event.getMachine();
    addMachineAction(machine);
}
Also used : Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 13 with Machine

use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.

the class ProcessesPanelPresenter method getMachines.

private List<MachineEntity> getMachines(Workspace workspace) {
    WorkspaceRuntime workspaceRuntime = workspace.getRuntime();
    if (workspaceRuntime == null) {
        return emptyList();
    }
    List<? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
    List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
    for (Machine machine : runtimeMachines) {
        if (machine instanceof MachineDto) {
            MachineEntity machineEntity = entityFactory.createMachine((MachineDto) machine);
            machines.add(machineEntity);
        }
    }
    return machines;
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) WorkspaceRuntime(org.eclipse.che.api.core.model.workspace.WorkspaceRuntime) ArrayList(java.util.ArrayList) ExtendedMachine(org.eclipse.che.api.core.model.workspace.ExtendedMachine) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 14 with Machine

use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.

the class DevelopmentCategoryPresenter method onRestoreTargetFields.

@Override
public boolean onRestoreTargetFields(DevelopmentMachineTarget target) {
    if (target == null) {
        return false;
    }
    final Machine machine = this.getMachineByName(target.getName());
    if (machine == null) {
        return false;
    }
    target.setOwner(machine.getOwner());
    target.setType(machine.getConfig().getType());
    target.setSourceType(machine.getConfig().getSource().getType());
    target.setSourceContent(machine.getConfig().getSource().getContent());
    target.setSource(machine.getConfig().getSource().getLocation());
    return true;
}
Also used : Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 15 with Machine

use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.

the class TestServiceClient method runTestsAfterCompilation.

Promise<TestResult> runTestsAfterCompilation(String projectPath, String testFramework, Map<String, String> parameters, StatusNotification statusNotification, Promise<CommandImpl> compileCommand) {
    return compileCommand.thenPromise(command -> {
        final Machine machine;
        if (command == null) {
            machine = null;
        } else {
            machine = appContext.getDevMachine().getDescriptor();
        }
        if (machine == null) {
            if (statusNotification != null) {
                statusNotification.setContent("Executing the tests without preliminary compilation.");
            }
            return sendTests(projectPath, testFramework, parameters);
        }
        if (statusNotification != null) {
            statusNotification.setContent("Compiling the project before starting the test session.");
        }
        return promiseFromExecutorBody(new ExecutorBody<TestResult>() {

            boolean compiled = false;

            @Override
            public void apply(final ResolveFunction<TestResult> resolve, RejectFunction reject) {
                macroProcessor.expandMacros(command.getCommandLine()).then(new Operation<String>() {

                    @Override
                    public void apply(String expandedCommandLine) throws OperationException {
                        CommandImpl expandedCommand = new CommandImpl(command.getName(), expandedCommandLine, command.getType(), command.getAttributes());
                        final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machine);
                        final String machineId = machine.getId();
                        processesPanelPresenter.addCommandOutput(machineId, console);
                        execAgentCommandManager.startProcess(machineId, expandedCommand).then(startResonse -> {
                            if (!startResonse.getAlive()) {
                                reject.apply(promiseFromThrowable(new Throwable(PROJECT_BUILD_NOT_STARTED_MESSAGE)));
                            }
                        }).thenIfProcessStartedEvent(console.getProcessStartedOperation()).thenIfProcessStdErrEvent(evt -> {
                            if (evt.getText().contains("BUILD SUCCESS")) {
                                compiled = true;
                            }
                            console.getStdErrOperation().apply(evt);
                        }).thenIfProcessStdOutEvent(evt -> {
                            if (evt.getText().contains("BUILD SUCCESS")) {
                                compiled = true;
                            }
                            console.getStdOutOperation().apply(evt);
                        }).thenIfProcessDiedEvent(evt -> {
                            console.getProcessDiedOperation().apply(evt);
                            if (compiled) {
                                if (statusNotification != null) {
                                    statusNotification.setContent(EXECUTING_TESTS_MESSAGE);
                                }
                                sendTests(projectPath, testFramework, parameters).then(new Operation<TestResult>() {

                                    @Override
                                    public void apply(TestResult result) throws OperationException {
                                        resolve.apply(result);
                                    }
                                });
                            } else {
                                reject.apply(promiseFromThrowable(new Throwable(PROJECT_BUILD_FAILED_MESSAGE)));
                            }
                        });
                    }
                });
            }
        });
    });
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandManager(org.eclipse.che.ide.api.command.CommandManager) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) AsyncRequestFactory(org.eclipse.che.ide.rest.AsyncRequestFactory) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) Inject(com.google.inject.Inject) HashMap(java.util.HashMap) Executor(org.eclipse.che.api.promises.client.js.Executor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Promise(org.eclipse.che.api.promises.client.Promise) ExecutorBody(org.eclipse.che.api.promises.client.js.Executor.ExecutorBody) AppContext(org.eclipse.che.ide.api.app.AppContext) Map(java.util.Map) RejectFunction(org.eclipse.che.api.promises.client.js.RejectFunction) URL(com.google.gwt.http.client.URL) HTTPHeader(org.eclipse.che.ide.rest.HTTPHeader) Operation(org.eclipse.che.api.promises.client.Operation) CommandConsoleFactory(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandConsoleFactory) DtoUnmarshallerFactory(org.eclipse.che.ide.rest.DtoUnmarshallerFactory) DtoFactory(org.eclipse.che.ide.dto.DtoFactory) OperationException(org.eclipse.che.api.promises.client.OperationException) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) PromiseProvider(org.eclipse.che.api.promises.client.PromiseProvider) MatchResult(com.google.gwt.regexp.shared.MatchResult) Machine(org.eclipse.che.api.core.model.machine.Machine) ExecAgentCommandManager(org.eclipse.che.ide.api.machine.ExecAgentCommandManager) List(java.util.List) MimeType(org.eclipse.che.ide.MimeType) TestResult(org.eclipse.che.api.testing.shared.TestResult) RegExp(com.google.gwt.regexp.shared.RegExp) ResolveFunction(org.eclipse.che.api.promises.client.js.ResolveFunction) MacroProcessor(org.eclipse.che.ide.api.macro.MacroProcessor) ProcessesPanelPresenter(org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter) Singleton(com.google.inject.Singleton) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) Machine(org.eclipse.che.api.core.model.machine.Machine) RejectFunction(org.eclipse.che.api.promises.client.js.RejectFunction) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

Machine (org.eclipse.che.api.core.model.machine.Machine)32 ArrayList (java.util.ArrayList)15 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)13 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)12 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)12 Matchers.anyString (org.mockito.Matchers.anyString)11 Test (org.testng.annotations.Test)11 Map (java.util.Map)9 Instance (org.eclipse.che.api.machine.server.spi.Instance)9 HashMap (java.util.HashMap)8 List (java.util.List)8 ServerConfImpl (org.eclipse.che.api.machine.server.model.impl.ServerConfImpl)8 ServerException (org.eclipse.che.api.core.ServerException)7 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)7 EnvironmentContext (org.eclipse.che.commons.env.EnvironmentContext)7 Arrays.asList (java.util.Arrays.asList)6 Collections (java.util.Collections)6 Collections.singletonMap (java.util.Collections.singletonMap)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)6 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)6