Search in sources :

Example 11 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class MachinePanelPresenter 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) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 12 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class ProcessesPanelPresenterTest method shouldHideStopProcessButtonAtAddingTerminal.

@Test
public void shouldHideStopProcessButtonAtAddingTerminal() throws Exception {
    MachineDto machineDto = mock(MachineDto.class);
    MachineEntity machine = mock(MachineEntity.class);
    when(machine.getId()).thenReturn(MACHINE_ID);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    when(machineConfigDto.isDev()).thenReturn(true);
    when(machine.getStatus()).thenReturn(MachineStatus.RUNNING);
    List<MachineDto> machines = new ArrayList<>(1);
    machines.add(machineDto);
    when(workspaceRuntime.getMachines()).thenReturn(machines);
    when(entityFactory.createMachine(machineDto)).thenReturn(machine);
    ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    List<ProcessTreeNode> children = new ArrayList<>();
    children.add(machineNode);
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    TerminalPresenter terminal = mock(TerminalPresenter.class);
    when(terminalFactory.create(machine, presenter)).thenReturn(terminal);
    IsWidget terminalWidget = mock(IsWidget.class);
    when(terminal.getView()).thenReturn(terminalWidget);
    when(terminalWidget.asWidget()).thenReturn(widget);
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    presenter.onAddTerminal(MACHINE_ID, presenter);
    verify(terminalFactory).create(eq(machine), eq(presenter));
    verify(terminal).getView();
    verify(view, times(2)).setProcessesData(anyObject());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(terminalWidget), anyBoolean());
    verify(view, times(1)).addProcessNode(anyObject());
    verify(terminal).setVisible(eq(true));
    verify(terminal).connect();
    verify(terminal).setListener(anyObject());
    verify(view).setStopButtonVisibility(anyString(), eq(false));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) TerminalPresenter(org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter) Test(org.junit.Test)

Example 13 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class ProcessesPanelPresenter method printMachineOutput.

/**
     * Prints text to the machine console.
     *
     * @param machineName
     *         machine name
     * @param text
     *          text to be printed
     */
public void printMachineOutput(final String machineName, final String text) {
    // Create a temporary machine node to display outputs.
    if (!consoles.containsKey(machineName)) {
        MachineDto machineDto = dtoFactory.createDto(MachineDto.class).withId(machineName).withStatus(CREATING).withConfig(dtoFactory.createDto(MachineConfigDto.class).withDev("dev-machine".equals(machineName)).withName(machineName).withType("docker"));
        provideMachineNode(new MachineItem(machineDto), true);
    }
    OutputConsole console = consoles.get(machineName);
    if (console != null && console instanceof DefaultOutputConsole) {
        ((DefaultOutputConsole) console).printText(text);
    }
}
Also used : MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) MachineItem(org.eclipse.che.ide.extension.machine.client.machine.MachineItem)

Aggregations

MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)13 ArrayList (java.util.ArrayList)7 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)6 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)6 Test (org.junit.Test)5 Machine (org.eclipse.che.api.core.model.machine.Machine)4 WorkspaceRuntime (org.eclipse.che.api.core.model.workspace.WorkspaceRuntime)3 WorkspaceRuntimeDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto)3 IsWidget (com.google.gwt.user.client.ui.IsWidget)2 HashMap (java.util.HashMap)2 ServerDto (org.eclipse.che.api.machine.shared.dto.ServerDto)2 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)2 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)2 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)2 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)2 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)2 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1