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));
}
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());
}
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);
}
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());
}
}
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);
}
Aggregations