Search in sources :

Example 6 with ProcessTreeNode

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

the class ProcessesPanelPresenterTest method shouldCloseTerminal.

@Test
public void shouldCloseTerminal() throws Exception {
    ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    TerminalPresenter terminal = mock(TerminalPresenter.class);
    ProcessTreeNode terminalNode = mock(ProcessTreeNode.class);
    when(terminalNode.getId()).thenReturn(PROCESS_ID);
    List<ProcessTreeNode> children = new ArrayList<>();
    children.add(machineNode);
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    presenter.terminals.put(PROCESS_ID, terminal);
    when(view.getNodeIndex(anyString())).thenReturn(0);
    when(machineNode.getChildren()).thenReturn(children);
    when(terminalNode.getParent()).thenReturn(machineNode);
    presenter.onCloseTerminal(terminalNode);
    verify(terminal).stopTerminal();
    verify(terminalNode, times(3)).getId();
    verify(terminalNode).getParent();
    verify(view).getNodeIndex(eq(PROCESS_ID));
    verify(view).hideProcessOutput(eq(PROCESS_ID));
    verify(view).removeProcessNode(eq(terminalNode));
    verify(view).setProcessesData(anyObject());
}
Also used : ArrayList(java.util.ArrayList) 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 7 with ProcessTreeNode

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

the class ProcessesPanelPresenterTest method shouldHideStopProcessButtonAtAddingCommand.

@Test
public void shouldHideStopProcessButtonAtAddingCommand() throws Exception {
    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);
    ProcessTreeNode selectedCommandNode = new ProcessTreeNode(COMMAND_NODE, null, PROCESS_NAME, null, children);
    children.add(selectedCommandNode);
    when(outputConsole.isFinished()).thenReturn(true);
    presenter.consoles.clear();
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    verify(view, never()).hideProcessOutput(anyString());
    verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
    IsWidget widget = mock(IsWidget.class);
    acceptsOneWidgetCaptor.getValue().setWidget(widget);
    verify(view).addProcessNode(anyObject());
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).setProcessesData(anyObject());
    verify(view).getNodeById(anyString());
    verify(view).setStopButtonVisibility(anyString(), eq(false));
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ArrayList(java.util.ArrayList) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Test(org.junit.Test)

Example 8 with ProcessTreeNode

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

the class ReRunProcessAction 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 (processesPanelPresenter.getContextOutputConsole() instanceof CommandOutputConsolePresenter) {
        event.getPresentation().setEnabled(true);
        event.getPresentation().setVisible(true);
        return;
    }
    event.getPresentation().setEnabled(false);
    event.getPresentation().setVisible(false);
}
Also used : CommandOutputConsolePresenter(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 9 with ProcessTreeNode

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

the class StopProcessAction 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 (processesPanelPresenter.getContextOutputConsole() instanceof CommandOutputConsolePresenter && !processesPanelPresenter.getContextOutputConsole().isFinished()) {
        event.getPresentation().setEnabled(true);
        event.getPresentation().setVisible(true);
        return;
    }
    event.getPresentation().setEnabled(false);
    event.getPresentation().setVisible(false);
}
Also used : CommandOutputConsolePresenter(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 10 with ProcessTreeNode

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

the class ProcessesPanelPresenter method newTerminal.

/** Opens new terminal for the selected machine. */
public void newTerminal(Object source) {
    final ProcessTreeNode selectedTreeNode = view.getSelectedTreeNode();
    final MachineEntity devMachine = appContext.getDevMachine();
    if (selectedTreeNode == null && devMachine != null) {
        onAddTerminal(devMachine.getId(), source);
        return;
    }
    if (selectedTreeNode == null) {
        String notificationTitle = localizationConstant.failedToConnectTheTerminal();
        String notificationContent = localizationConstant.machineNotFound("");
        notificationManager.notify(notificationTitle, notificationContent, FAIL, FLOAT_MODE);
        return;
    }
    if (selectedTreeNode.getType() == MACHINE_NODE) {
        MachineEntity machine = (MachineEntity) selectedTreeNode.getData();
        onAddTerminal(machine.getId(), source);
        return;
    }
    ProcessTreeNode parent = selectedTreeNode.getParent();
    if (parent != null && parent.getType() == MACHINE_NODE) {
        MachineEntity machine = (MachineEntity) parent.getData();
        onAddTerminal(machine.getId(), source);
    }
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

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