use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ProcessesPanelPresenter method provideMachineNode.
/**
* Provides machine node:
* <li>creates new machine node when this one not exist or {@code replace} is {@code true}</li>
* <li>returns old machine node when this one exist and {@code replace} is {@code false}</li>
*
* @param machine
* machine to creating node
* @param replace
* existed node will be replaced when {@code replace} is {@code true}
* @return machine node
*/
private ProcessTreeNode provideMachineNode(@NotNull MachineEntity machine, boolean replace) {
final String machineId = machine.getId();
final ProcessTreeNode existedMachineNode = findProcessTreeNodeById(machineId);
if (!replace && existedMachineNode != null) {
return existedMachineNode;
}
// remove existed node
for (ProcessTreeNode node : rootNode.getChildren()) {
if (machine.getConfig().getName().equals(node.getName())) {
rootNode.getChildren().remove(node);
break;
}
}
// create new node
final ProcessTreeNode newMachineNode = new ProcessTreeNode(MACHINE_NODE, rootNode, machine, null, new ArrayList<ProcessTreeNode>());
newMachineNode.setRunning(true);
newMachineNode.setHasTerminalAgent(hasAgent(machine.getDisplayName(), TERMINAL_AGENT) || hasTerminal(machineId));
newMachineNode.setHasSSHAgent(hasAgent(machine.getDisplayName(), SSH_AGENT));
machineNodes.put(machineId, newMachineNode);
// add to children
rootNode.getChildren().add(newMachineNode);
// update the view
view.setProcessesData(rootNode);
// add output for the machine if it is not exist
if (!consoles.containsKey(machine.getConfig().getName())) {
OutputConsole outputConsole = commandConsoleFactory.create(machine.getConfig().getName());
addOutputConsole(machine.getConfig().getName(), newMachineNode, outputConsole, true);
}
return newMachineNode;
}
use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ProcessesPanelPresenter method printMachineOutput.
/**
* Prints text to the machine console.
*
* @param machineName
* machine name
* @param text
* text to be printed
*/
public void printMachineOutput(final String machineName, final String text) {
// Create a temporary machine node to display outputs.
if (!consoles.containsKey(machineName)) {
MachineDto machineDto = dtoFactory.createDto(MachineDto.class).withId(machineName).withStatus(CREATING).withConfig(dtoFactory.createDto(MachineConfigDto.class).withDev("dev-machine".equals(machineName)).withName(machineName).withType("docker"));
provideMachineNode(new MachineItem(machineDto), true);
}
OutputConsole console = consoles.get(machineName);
if (console != null && console instanceof DefaultOutputConsole) {
((DefaultOutputConsole) console).printText(text);
}
}
use of org.eclipse.che.ide.api.outputconsole.OutputConsole in project che by eclipse.
the class ReRunProcessAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
OutputConsole outputConsole = processesPanelPresenter.getContextOutputConsole();
if (outputConsole != null && outputConsole instanceof CommandOutputConsolePresenter) {
CommandOutputConsolePresenter commandOutputConsolePresenter = (CommandOutputConsolePresenter) outputConsole;
commandOutputConsolePresenter.reRunProcessButtonClicked();
}
}
Aggregations