Search in sources :

Example 21 with ProcessTreeNode

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

the class ProcessesPanelPresenterTest method shouldStopProcessWithoutCloseCommandOutput.

@Test
public void shouldStopProcessWithoutCloseCommandOutput() throws Exception {
    ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
    ProcessTreeNode commandNode = 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);
    when(outputConsole.isFinished()).thenReturn(false);
    presenter.consoles.put(PROCESS_ID, outputConsole);
    //noinspection ConstantConditions
    machineNode.getChildren().add(commandNode);
    when(commandNode.getId()).thenReturn(PROCESS_ID);
    when(view.getNodeIndex(anyString())).thenReturn(0);
    when(machineNode.getChildren()).thenReturn(children);
    when(commandNode.getParent()).thenReturn(machineNode);
    presenter.onStopCommandProcess(commandNode);
    verify(outputConsole).stop();
    verify(view, never()).hideProcessOutput(eq(PROCESS_ID));
    verify(view, never()).removeProcessNode(eq(commandNode));
}
Also used : ArrayList(java.util.ArrayList) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Test(org.junit.Test)

Example 22 with ProcessTreeNode

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

the class ProcessesPanelPresenterTest method shouldAddCommand.

@Test
public void shouldAddCommand() 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);
    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(), anyBoolean());
}
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 23 with ProcessTreeNode

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

the class ProcessesPanelPresenterTest method stopButtonShouldBeHiddenWhenConsoleHasFinishedProcess.

@Test
public void stopButtonShouldBeHiddenWhenConsoleHasFinishedProcess() {
    ProcessTreeNode commandNode = mock(ProcessTreeNode.class);
    when(commandNode.getId()).thenReturn(PROCESS_ID);
    when(outputConsole.isFinished()).thenReturn(true);
    presenter.consoles.put(PROCESS_ID, outputConsole);
    presenter.onTreeNodeSelected(commandNode);
    verify(view).setStopButtonVisibility(PROCESS_ID, false);
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Test(org.junit.Test)

Example 24 with ProcessTreeNode

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

the class ProcessesPanelViewImpl method markProcessHasOutput.

@Override
public void markProcessHasOutput(String processId) {
    if (processId.equals(activeProcessId)) {
        return;
    }
    final ProcessTreeNode treeNode = processTreeNodes.get(processId);
    if (treeNode != null) {
        treeNode.setHasUnreadContent(true);
        treeNode.getTreeNodeElement().getClassList().add(machineResources.getCss().badgeVisible());
    }
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 25 with ProcessTreeNode

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

the class ProcessesPanelViewImpl method addWidget.

@Override
public void addWidget(final String processId, final String title, final SVGResource icon, final IsWidget widget, final boolean machineConsole) {
    final WidgetToShow widgetToShow = new WidgetToShow() {

        @Override
        public IsWidget getWidget() {
            return widget;
        }

        @Override
        public String getTitle() {
            return title;
        }

        @Override
        public SVGResource getIcon() {
            return icon;
        }
    };
    widget2Panels.put(widgetToShow, focusedSubPanel);
    focusedSubPanel.addWidget(widgetToShow, !machineConsole, new SubPanel.WidgetRemovingListener() {

        @Override
        public void onWidgetRemoving(SubPanel.RemoveCallback removeCallback) {
            final ProcessTreeNode treeNode = widget2TreeNodes.get(widgetToShow.getWidget());
            if (treeNode == null) {
                return;
            }
            switch(treeNode.getType()) {
                case COMMAND_NODE:
                    delegate.onCommandTabClosing(treeNode, removeCallback);
                    break;
                case TERMINAL_NODE:
                    delegate.onTerminalTabClosing(treeNode);
                    removeCallback.remove();
                    break;
                case MACHINE_NODE:
                    removeCallback.remove();
                    break;
            }
        }
    });
    processWidgets.put(processId, widgetToShow);
    widget2TreeNodes.put(widgetToShow.getWidget(), processTreeNodes.get(processId));
    showProcessOutput(processId);
}
Also used : WidgetToShow(org.eclipse.che.ide.ui.multisplitpanel.WidgetToShow) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) SubPanel(org.eclipse.che.ide.ui.multisplitpanel.SubPanel)

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