Search in sources :

Example 31 with ProcessTreeNode

use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.

the class ProcessesPanelPresenter method onDownloadWorkspaceOutput.

@Override
public void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event) {
    Machine devMachine = null;
    for (ProcessTreeNode machineNode : machineNodes.values()) {
        if (!(machineNode.getData() instanceof Machine)) {
            continue;
        }
        Machine machine = (Machine) machineNode.getData();
        if (!machine.getConfig().isDev()) {
            continue;
        }
        devMachine = machine;
        break;
    }
    if (devMachine == null) {
        return;
    }
    String fileName = appContext.getWorkspace().getNamespace() + "-" + appContext.getWorkspace().getConfig().getName() + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ".log";
    download(fileName, getText(devMachine.getId()));
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) ExtendedMachine(org.eclipse.che.api.core.model.workspace.ExtendedMachine) Machine(org.eclipse.che.api.core.model.machine.Machine) Date(java.util.Date)

Example 32 with ProcessTreeNode

use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.

the class ProcessesPanelPresenter method onStopProcess.

private void onStopProcess(ProcessTreeNode node) {
    String processId = node.getId();
    ProcessTreeNode parentNode = node.getParent();
    int processIndex = view.getNodeIndex(processId);
    if (processIndex < 0) {
        return;
    }
    int neighborIndex = processIndex > 0 ? processIndex - 1 : processIndex + 1;
    ProcessTreeNode neighborNode = view.getNodeByIndex(neighborIndex);
    if (neighborNode == null) {
        neighborNode = parentNode;
    }
    removeChildFromMachineNode(node, parentNode);
    view.selectNode(neighborNode);
    notifyTreeNodeSelected(neighborNode);
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 33 with ProcessTreeNode

use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.

the class CloseConsoleAction method updateInPerspective.

@Override
public void updateInPerspective(ActionEvent event) {
    ProcessTreeNode processTreeNode = processesPanelPresenter.getContextTreeNode();
    if (processTreeNode == null) {
        event.getPresentation().setEnabled(false);
        event.getPresentation().setVisible(false);
        return;
    }
    if (ProcessTreeNode.ProcessNodeType.COMMAND_NODE == processTreeNode.getType() || ProcessTreeNode.ProcessNodeType.TERMINAL_NODE == processTreeNode.getType()) {
        event.getPresentation().setEnabled(true);
        event.getPresentation().setVisible(true);
        return;
    }
    event.getPresentation().setEnabled(false);
    event.getPresentation().setVisible(false);
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 34 with ProcessTreeNode

use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode 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)

Example 35 with ProcessTreeNode

use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.

the class ProcessesPanelPresenterTest method shouldShowConfirmDialogWhenCommandHasNotFinished.

@Test
public void shouldShowConfirmDialogWhenCommandHasNotFinished() throws Exception {
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    ProcessTreeNode commandNode = mock(ProcessTreeNode.class);
    when(outputConsole.isFinished()).thenReturn(false);
    presenter.consoles.put(PROCESS_ID, outputConsole);
    when(commandNode.getId()).thenReturn(PROCESS_ID);
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), anyObject(), anyObject())).thenReturn(confirmDialog);
    presenter.onCloseCommandOutputClick(commandNode);
    verify(commandNode).getId();
    verify(view, never()).hideProcessOutput(anyString());
    verify(view, never()).removeProcessNode(anyObject());
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), anyObject(), anyObject());
    verify(confirmDialog).show();
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Aggregations

ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)36 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)12 IsWidget (com.google.gwt.user.client.ui.IsWidget)8 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)8 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)5 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)3 OutputConsole (org.eclipse.che.ide.api.outputconsole.OutputConsole)3 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)3 SubPanel (org.eclipse.che.ide.ui.multisplitpanel.SubPanel)3 Machine (org.eclipse.che.api.core.model.machine.Machine)2 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)2 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 CommandOutputConsolePresenter (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter)2 DefaultOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole)2 WidgetToShow (org.eclipse.che.ide.ui.multisplitpanel.WidgetToShow)2 AcceptsOneWidget (com.google.gwt.user.client.ui.AcceptsOneWidget)1 Focusable (com.google.gwt.user.client.ui.Focusable)1 Date (java.util.Date)1