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