use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldAddMachineWhenMachineCreating.
@Test
public void shouldAddMachineWhenMachineCreating() throws Exception {
MachineEntity machine = mock(MachineEntity.class);
MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
OutputConsole outputConsole = mock(OutputConsole.class);
when(machineConfigDto.getName()).thenReturn(MACHINE_NAME);
when(machine.getConfig()).thenReturn(machineConfigDto);
when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID);
when(commandConsoleFactory.create(eq(MACHINE_NAME))).thenReturn(outputConsole);
MachineStateEvent machineStateEvent = mock(MachineStateEvent.class);
when(machineStateEvent.getMachine()).thenReturn(machine);
verify(eventBus, times(8)).addHandler(anyObject(), machineStateHandlerCaptor.capture());
MachineStateEvent.Handler machineStateHandler = machineStateHandlerCaptor.getAllValues().get(0);
machineStateHandler.onMachineCreating(machineStateEvent);
verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
IsWidget widget = mock(IsWidget.class);
acceptsOneWidgetCaptor.getValue().setWidget(widget);
verify(commandConsoleFactory).create(eq(MACHINE_NAME));
verify(view).addWidget(anyString(), anyString(), anyObject(), anyObject(), anyBoolean());
verify(view).setProcessesData(eq(presenter.rootNode));
}
use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class StopProcessAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
OutputConsole outputConsole = processesPanelPresenter.getContextOutputConsole();
if (outputConsole != null && outputConsole instanceof CommandOutputConsolePresenter) {
CommandOutputConsolePresenter commandOutputConsolePresenter = (CommandOutputConsolePresenter) outputConsole;
commandOutputConsolePresenter.stopProcessButtonClicked();
}
}
use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ProcessesPanelPresenter method onPreviewSsh.
@Override
public void onPreviewSsh(String machineId) {
ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
if (machineTreeNode == null) {
return;
}
Machine machine = (Machine) machineTreeNode.getData();
final OutputConsole defaultConsole = commandConsoleFactory.create("SSH");
addCommandOutput(machineId, defaultConsole);
final String machineName = machine.getConfig().getName();
String sshServiceAddress = getSshServerAddress(machine);
final String machineHost;
final String sshPort;
if (sshServiceAddress != null) {
String[] parts = sshServiceAddress.split(":");
machineHost = parts[0];
sshPort = (parts.length == 2) ? parts[1] : SSH_PORT;
} else {
sshPort = SSH_PORT;
machineHost = "";
}
// user
final String userName;
String user = machine.getRuntime().getProperties().get("config.user");
if (isNullOrEmpty(user)) {
userName = "root";
} else {
userName = user;
}
// ssh key
final String workspaceName = appContext.getWorkspace().getConfig().getName();
Promise<SshPairDto> sshPairDtoPromise = sshServiceClient.getPair("workspace", machine.getWorkspaceId());
sshPairDtoPromise.then(new Operation<SshPairDto>() {
@Override
public void apply(SshPairDto sshPairDto) throws OperationException {
if (defaultConsole instanceof DefaultOutputConsole) {
((DefaultOutputConsole) defaultConsole).enableAutoScroll(false);
((DefaultOutputConsole) defaultConsole).printText(localizationConstant.sshConnectInfo(machineName, machineHost, sshPort, workspaceName, userName, localizationConstant.sshConnectInfoPrivateKey(sshPairDto.getPrivateKey())));
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
if (defaultConsole instanceof DefaultOutputConsole) {
((DefaultOutputConsole) defaultConsole).enableAutoScroll(false);
((DefaultOutputConsole) defaultConsole).printText(localizationConstant.sshConnectInfo(machineName, machineHost, sshPort, workspaceName, userName, localizationConstant.sshConnectInfoNoPrivateKey()));
}
}
});
}
use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldShowErrorWhenMachineNodeIsNull.
@Test
public void shouldShowErrorWhenMachineNodeIsNull() throws Exception {
List<ProcessTreeNode> children = new ArrayList<>();
presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
OutputConsole outputConsole = mock(OutputConsole.class);
presenter.addCommandOutput(MACHINE_ID, outputConsole);
verify(notificationManager).notify(anyString(), anyString(), any(StatusNotification.Status.class), any(DisplayMode.class));
verify(localizationConstant, times(2)).machineNotFound(eq(MACHINE_ID));
}
use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ProcessesPanelPresenter method closeCommandOutput.
private void closeCommandOutput(ProcessTreeNode node, SubPanel.RemoveCallback removeCallback) {
String commandId = node.getId();
OutputConsole console = consoles.get(commandId);
if (console == null) {
removeCallback.remove();
return;
}
if (console.isFinished()) {
console.close();
onStopProcess(node);
consoles.remove(commandId);
consoleCommands.remove(console);
removeCallback.remove();
return;
}
dialogFactory.createConfirmDialog("", localizationConstant.outputsConsoleViewStopProcessConfirmation(console.getTitle()), getConfirmCloseConsoleCallback(console, node, removeCallback), null).show();
}
Aggregations