Search in sources :

Example 21 with MachineEntity

use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.

the class ProcessesPanelPresenter method onWorkspaceStarted.

@Override
public void onWorkspaceStarted(WorkspaceStartedEvent event) {
    List<MachineEntity> wsMachines = getMachines(event.getWorkspace());
    if (wsMachines.isEmpty()) {
        return;
    }
    MachineEntity devMachine = null;
    for (MachineEntity machineEntity : wsMachines) {
        if (machineEntity.isDev()) {
            devMachine = machineEntity;
            break;
        }
    }
    ProcessTreeNode machineToSelect = null;
    if (devMachine != null) {
        machineToSelect = provideMachineNode(devMachine, true);
        wsMachines.remove(devMachine);
    }
    for (MachineEntity machine : wsMachines) {
        provideMachineNode(machine, true);
    }
    if (machineToSelect != null) {
        view.selectNode(machineToSelect);
        notifyTreeNodeSelected(machineToSelect);
    } else if (!machineNodes.isEmpty()) {
        machineToSelect = machineNodes.entrySet().iterator().next().getValue();
        view.selectNode(machineToSelect);
        notifyTreeNodeSelected(machineToSelect);
    }
    for (MachineEntity machine : machines.values()) {
        if (RUNNING.equals(machine.getStatus()) && !wsMachines.contains(machine)) {
            provideMachineNode(machine, true);
        }
    }
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 22 with MachineEntity

use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.

the class ProcessesPanelPresenter method hasTerminal.

/**
     * Checks supporting of the terminal for machine which is running out the workspace runtime.
     *
     * @param machineId
     *          machine id
     * @return
     *          <b>true</b> is the terminal url, otherwise return <b>false</b>
     */
private boolean hasTerminal(String machineId) {
    List<MachineEntity> wsMachines = getMachines(appContext.getWorkspace());
    for (MachineEntity machineEntity : wsMachines) {
        if (machineId.equals(machineEntity.getId())) {
            return false;
        }
    }
    final MachineEntity machineEntity = machines.get(machineId);
    return machineEntity != null && machineEntity.getServer(TERMINAL_REFERENCE) != null;
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity)

Example 23 with MachineEntity

use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.

the class ProcessesPanelPresenterTest method shouldReplaceCommandOutput.

@Test
public void shouldReplaceCommandOutput() throws Exception {
    MachineEntity machine = mock(MachineEntity.class);
    when(machine.getId()).thenReturn(MACHINE_ID);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    List<ProcessTreeNode> children = new ArrayList<>();
    ProcessTreeNode commandNode = new ProcessTreeNode(COMMAND_NODE, null, PROCESS_NAME, null, children);
    children.add(commandNode);
    ProcessTreeNode machineNode = new ProcessTreeNode(MACHINE_NODE, null, machine, null, children);
    children.add(machineNode);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    String commandId = commandNode.getId();
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    presenter.consoles.put(commandId, outputConsole);
    when(outputConsole.isFinished()).thenReturn(true);
    when(outputConsole.getTitle()).thenReturn(PROCESS_NAME);
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
    IsWidget widget = mock(IsWidget.class);
    acceptsOneWidgetCaptor.getValue().setWidget(widget);
    verify(view).hideProcessOutput(eq(commandId));
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).getNodeById(anyString());
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)23 ArrayList (java.util.ArrayList)8 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)8 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)5 Test (org.junit.Test)5 Machine (org.eclipse.che.api.core.model.machine.Machine)3 WorkspaceRuntime (org.eclipse.che.api.core.model.workspace.WorkspaceRuntime)3 MachineStateEvent (org.eclipse.che.ide.api.machine.events.MachineStateEvent)3 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)3 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)2 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)2 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)2 Element (elemental.dom.Element)1 Node (elemental.dom.Node)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 DivElement (elemental.html.DivElement)1 SpanElement (elemental.html.SpanElement)1