Search in sources :

Example 6 with OutputConsole

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;
}
Also used : CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 7 with OutputConsole

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);
    }
}
Also used : MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) MachineItem(org.eclipse.che.ide.extension.machine.client.machine.MachineItem)

Example 8 with OutputConsole

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();
    }
}
Also used : OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) CommandOutputConsolePresenter(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter)

Aggregations

OutputConsole (org.eclipse.che.ide.api.outputconsole.OutputConsole)8 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)6 DefaultOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole)4 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)3 CommandOutputConsolePresenter (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter)2 Test (org.junit.Test)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 ArrayList (java.util.ArrayList)1 Machine (org.eclipse.che.api.core.model.machine.Machine)1 MachineStatus (org.eclipse.che.api.core.model.machine.MachineStatus)1 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)1 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)1 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)1 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)1 MachineStateEvent (org.eclipse.che.ide.api.machine.events.MachineStateEvent)1 DisplayMode (org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode)1