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